Esempio n. 1
0
        public override Tuple <GeckoSession, GeckoRuntime> CreateNewSession()
        {
            var settings = new GeckoSessionSettings.Builder()
                           .UsePrivateMode(true) //Use private mode in order to never cache anything at each app session
                           .UseTrackingProtection(true)
                           .UserAgentMode(GeckoSessionSettings.UserAgentModeMobile)
                           .SuspendMediaWhenInactive(true)
                           .AllowJavascript(true)
                           .Build();

            GeckoSession _session = new GeckoSession(settings);
            GeckoRuntime _runtime = GeckoRuntime.Create(Context);

            _session.Open(_runtime);
            _session.ProgressDelegate = new ProgressDelegate(this);
            _session.ContentDelegate  = new ContentDelegate(this);

            if (WebApplicationFactory._debugFeatures)
            {
                _runtime.Settings.SetRemoteDebuggingEnabled(true);
                _runtime.Settings.SetConsoleOutputEnabled(true);
            }

            return(Tuple.Create(_session, _runtime));
        }
Esempio n. 2
0
        public override Tuple <GeckoSession, GeckoRuntime> CreateNewSession(bool needSessionOpening, string uri)
        {
            if (!_firstCall)
            {
                GeckoSession newSession = new GeckoSession();
                GeckoRuntime newRuntime = GeckoRuntime.GetDefault(Context);

                //With our scenario this should not happen, but enforcing rule just for sanity check
                if (needSessionOpening)
                {
                    newSession.Open(newRuntime);
                }

                return(new Tuple <GeckoSession, GeckoRuntime>(newSession, newRuntime));
            }

            var settings = new GeckoSessionSettings.Builder()
                           .UsePrivateMode(true) //Use private mode in order to never cache anything at each app session
                           .UseTrackingProtection(true)
                           .UserAgentMode(GeckoSessionSettings.UserAgentModeMobile)
                           .SuspendMediaWhenInactive(true)
                           .AllowJavascript(true)
                           .Build();

            GeckoSession _session = new GeckoSession(settings);
            GeckoRuntime _runtime = GeckoRuntime.GetDefault(Context);

            //Register BlazorMobile iframe listener WebExtension, as GeckoView LoadRequest does not bubble up when navigating through an iFrame.
            //NOTE: Delegate for WebExtension handling seem missing from current Xamarin.GeckoView generated bindings, but the handling will be workarounded through the local BlazorMobile server

            //WARNING: With our implementation, registering a WebExtension is per WebView if the same runtime object is used, not per session
            WebExtensionHelper.RegisterWebExtension(Element as BlazorGeckoView, _runtime, "resource://android/assets/obj/BlazorMobile/web_extensions/iframe_listener/");

            if (needSessionOpening)
            {
                _session.Open(_runtime);
            }

            _session.PromptDelegate     = new BlazorGeckoViewPromptDelegate(this);
            _session.ProgressDelegate   = new BlazorProgressDelegate(this);
            _session.ContentDelegate    = new BlazorContentDelegate(this);
            _session.NavigationDelegate = new BlazorNavigationDelegate(this);

            if (WebApplicationFactory._debugFeatures)
            {
                _runtime.Settings.SetRemoteDebuggingEnabled(true);
                _runtime.Settings.SetConsoleOutputEnabled(true);
            }

            _firstCall = false;

            return(Tuple.Create(_session, _runtime));
        }