コード例 #1
0
 /// <summary>
 /// Called before a new popup window is created.
 /// The |parentBrowser| parameter will point to the parent browser window.
 /// The |popupFeatures| parameter will contain information about the style of popup window requested.
 /// Return false to have the framework create the new popup window based on the parameters in |windowInfo|.
 /// Return true to cancel creation of the popup window.
 /// By default, a newly created popup window will have the same client and settings as the parent window.
 /// To change the client for the new window modify the object that |client| points to.
 /// To change the settings for the new window modify the |settings| structure.
 /// </summary>
 protected virtual bool OnBeforePopup(
     CefBrowser parentBrowser,
     CefPopupFeatures popupFeatures,
     CefWindowInfo windowInfo,
     string url,
     ref CefClient client,
     CefBrowserSettings settings
     )
 {
     return false;
 }
コード例 #2
0
        private void Form_Load(object sender, EventArgs e)
        {
            var config = new CefSettings();
            config.MultiThreadedMessageLoop = true;
            config.CachePath = Path.GetDirectoryName(Application.ExecutablePath) + "/cache";
            config.LogFile = Path.GetDirectoryName(Application.ExecutablePath) + "/cef.log";
            config.LogSeverity = CefLogSeverity.Warning;

            Cef.Initialize(config);

            var settings = new CefBrowserSettings();
            webView = new CefWebBrowser(settings, ConfigurationManager.ConnectionStrings["HomeUrl"].ConnectionString);
            webView.Dock = DockStyle.Fill;
            webView.Parent = this;
            webView.BringToFront();
            this.Controls.Add(webView);
        }
コード例 #3
0
        /// <summary>
        /// Create a new browser window using the window parameters specified by |windowInfo|.
        /// This method should only be called on the UI thread.
        /// </summary>
        public static CefBrowser CreateSync(CefWindowInfo windowInfo, CefClient client, string url, CefBrowserSettings settings)
        {
            if (windowInfo == null) throw new ArgumentNullException("windowInfo");
            if (client == null) throw new ArgumentNullException("client");
            if (settings == null) throw new ArgumentNullException("settings");

            fixed (char* url_str = url)
            {
                cef_string_t n_url = new cef_string_t(url_str, url != null ? url.Length : 0);

                var browser = NativeMethods.cef_browser_create_sync(
                    windowInfo.NativePointer,
                    client.GetNativePointerAndAddRef(),
                    &n_url,
                    settings.NativePointer
                    );

                if (browser == null) throw new InvalidOperationException("CefBrowser.CreateSync error.");

                return CefBrowser.From(browser);
            }
        }