コード例 #1
0
        /// <summary>
        /// Create a new browser window using the window parameters specified by |windowInfo|.
        /// All values will be copied internally and the actual window will be created on the UI thread.
        /// This method call will not block.
        /// </summary>
        public static void Create(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 result = NativeMethods.cef_browser_create(
                        windowInfo.NativePointer,
                        client.GetNativePointerAndAddRef(),
                        &n_url,
                        settings.NativePointer
                        );

                    if (result == 0)
                    {
                        throw new InvalidOperationException("CefBrowser.Create error.");
                    }
                }
        }
コード例 #2
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);
            }
        }