Example #1
0
        public App(RenderDelegate appDelegate)
            : base(typeof (CefApp))
        {
            _delegate = appDelegate;
            _browserProcessHandler = new BrowserProcessHandler(appDelegate);
            _renderProcessHandler = new RenderProcessHandler(appDelegate);
            _resourceBundleHandler = new ResourceBundleHandler(appDelegate);

            _getResourceBundleHandlerCallback = OnGetResourceBundleHandler;
            _getRenderProcessHandlerCallback = GetRenderProcessHandler;
            _getBrowserProcessHandlerCallback = OnGetBrowserProcessHandler;

            _beforeCommandLineProcessingCallback = OnBeforeCommandLineProcessing;
            _registerCustomSchemeCallback = OnRegisterCustomScheme;

            MarshalToNative(new CefApp {
                Base = DedicatedBase,
                OnBeforeCommandLineProcessing =
                    Marshal.GetFunctionPointerForDelegate(_beforeCommandLineProcessingCallback),
                CefCallbackGetRenderProcessHandler =
                    Marshal.GetFunctionPointerForDelegate(_getRenderProcessHandlerCallback),
                OnRegisterCustomSchemes =
                    Marshal.GetFunctionPointerForDelegate(_registerCustomSchemeCallback),
                CefCallbackGetBrowserProcessHandler =
                    Marshal.GetFunctionPointerForDelegate(_getBrowserProcessHandlerCallback),
                CefCallbackGetResourceBundleHandler =
                    Marshal.GetFunctionPointerForDelegate(_getResourceBundleHandlerCallback)
            });
        }
Example #2
0
        public BrowserProcessHandler(RenderDelegate appDelegate)
            : base(typeof (CefBrowserProcessHandler))
        {
            _appDelegate = appDelegate;

            _beforeChildProcessLaunchCallback = OnBeforeChildProcessLaunch;

            MarshalToNative(new CefBrowserProcessHandler {
                Base = DedicatedBase,
                OnBeforeChildProcessLaunch = Marshal.GetFunctionPointerForDelegate(_beforeChildProcessLaunchCallback)
            });
        }
Example #3
0
        //private readonly AppDelegate _appDelegate;
        public ResourceBundleHandler(RenderDelegate appDelegate)
            : base(typeof (CefResourceBundleHandler))
        {
            //_appDelegate = appDelegate;
            _getDataResourceCallback = OnGetDataResource;
            _getlocalizedStringCallback = OnGetLocalizedString;

            MarshalToNative(new CefResourceBundleHandler {
                Base = DedicatedBase,
                GetDataResource = Marshal.GetFunctionPointerForDelegate(_getDataResourceCallback),
                GetLocalizedString = Marshal.GetFunctionPointerForDelegate(_getlocalizedStringCallback)
            });
        }
Example #4
0
        private bool Initialize(IntPtr mainArgs, RenderDelegate del = null)
        {
            _app = new App(del ?? new RenderDelegate());

            Reference.Increment(_app.Handle);
            var exitCode = CefAppCapi.CefExecuteProcess(mainArgs, _app.Handle);
            IsRootProcess = exitCode < 0;
            if (!IsRootProcess) {
                return true;
            }

            Reference.Increment(_app.Handle);
            var result = CefAppCapi.CefInitialize(mainArgs, Settings.Handle, _app.Handle);
            IsInitialized = Convert.ToBoolean(result);
            return IsInitialized;
        }
Example #5
0
        public bool Initialize(RenderDelegate del = null)
        {
            var handle = IntPtr.Zero;

            if (Platform.IsLinux) {
                var commandLine = Environment.GetCommandLineArgs();
                handle = AppArguments.CreateForLinux(commandLine);
            }

            if (Platform.IsWindows) {
                var module = Assembly.GetEntryAssembly().ManifestModule;
                var hInstance = Marshal.GetHINSTANCE(module);
                handle = AppArguments.CreateForWindows(hInstance);
            }
            return Initialize(handle, del);
        }