コード例 #1
0
ファイル: App.cs プロジェクト: kaagati/spectre
        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)
            });
        }
コード例 #2
0
        public BrowserProcessHandler(RenderDelegate appDelegate)
            : base(typeof (CefBrowserProcessHandler))
        {
            _appDelegate = appDelegate;

            _beforeChildProcessLaunchCallback = OnBeforeChildProcessLaunch;

            MarshalToNative(new CefBrowserProcessHandler {
                Base = DedicatedBase,
                OnBeforeChildProcessLaunch = Marshal.GetFunctionPointerForDelegate(_beforeChildProcessLaunchCallback)
            });
        }
コード例 #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)
            });
        }
コード例 #4
0
ファイル: Application.cs プロジェクト: kaagati/spectre
        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;
        }
コード例 #5
0
ファイル: Application.cs プロジェクト: kaagati/spectre
        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);
        }