Ejemplo n.º 1
0
        public override void AwakeFromNib()
        {
            XcbWebView = new XcbWebView(this);

            UIDelegate     = new XIWebUIDelegate();
            PolicyDelegate = new XIWebPolicyDelegate();

            RegisterViewClass <XIMapViewWebDocumentView, XIMapViewWebDocumentRepresentation> (
                "application/x-inspector-map-view");

            if (WebKitPrefs.DeveloperExtrasEnabled)
            {
                using (NativeExceptionHandler.Trap()) {
                    try {
                        WebInspector = this.GetInspector();
                    } catch (Exception e) {
                        Log.Error(TAG, "private WebKit API may have been removed", e);
                    }
                }

                switch (Prefs.Developer.StartupWebInspectorPane.GetValue())
                {
                case Prefs.Developer.WebInspectorPane.Console:
                    WebInspector?.ShowConsole(this);
                    break;

                case Prefs.Developer.WebInspectorPane.ElementTree:
                    WebInspector?.Show(this);
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public static InspectViewMaterial Create(InspectView inspectView, bool renderImage = true)
        {
            if (inspectView == null)
            {
                throw new ArgumentNullException(nameof(inspectView));
            }

            if (Math.Abs(inspectView.Width) < Single.Epsilon ||
                Math.Abs(inspectView.Height) < Single.Epsilon)
            {
                return(null);
            }

            if (renderImage && inspectView.BestCapturedImage != null)
            {
                try {
                    NativeExceptionHandler.Trap();
                    return(new InspectViewMaterial(inspectView.BestCapturedImage));
                } catch (Exception e) {
                    Log.Error(TAG, $"Exception creating NSImage from byte[] " +
                              $"(length={inspectView.CapturedImage.Length})", e);
                } finally {
                    NativeExceptionHandler.Release();
                }
            }

            return(new InspectViewMaterial(inspectView.Width, inspectView.Height));
        }
Ejemplo n.º 3
0
 public static void DisableAutomaticWindowTabbing()
 {
     using (NativeExceptionHandler.Trap()) {
         try {
             if (bool_objc_msgSend_IntPtr(
                     nsWindowClassPtr,
                     respondsToSelectorSel,
                     setAllowsAutomaticWindowTabbingSel))
             {
                 void_objc_msgSend_bool(
                     nsWindowClassPtr,
                     setAllowsAutomaticWindowTabbingSel,
                     false);
             }
         } catch (Exception e) {
             Log.Error(TAG, e);
         }
     }
 }
Ejemplo n.º 4
0
        public void Register(IHub hub, SentryOptions options)
        {
            options.AddEventProcessor(new FormsEventProcessor(options));

            _nativeHandler = new NativeExceptionHandler();

#if !NETSTANDARD
            options.AddEventProcessor(new NativeEventProcessor(options));
#endif
            XamlLogger = new DelegateLogListener((arg1, arg2) =>
            {
                if (LogXamlErrors)
                {
                    SentrySdk.AddBreadcrumb(arg2, $"XamlLogger.{arg1}", level: BreadcrumbLevel.Warning);
                }
            });

            if (LogXamlErrors)
            {
                Log.Listeners.Add(XamlLogger);
            }

            //If initialized from the Android/IOS project, the current application is not going to be set in time, so wait a bit...
            Task.Run(async() =>
            {
                for (int i = 0; i < 5 && Application.Current is null; i++)
                {
                    await Task.Delay(1000);
                }
                if (Application.Current is null)
                {
                    options.DiagnosticLogger.Log(SentryLevel.Warning, "ContribSentry.Forms timeout for tracking Application.Current. Navigation tracking is going to be disabled");
                }
                else
                {
                    Application.Current.PageAppearing         += Current_PageAppearing;
                    Application.Current.PageDisappearing      += Current_PageDisappearing;
                    Application.Current.RequestedThemeChanged += Current_RequestedThemeChanged;
                }
            });
        }