private void on_browser_created(cef_render_process_handler_t *self, cef_browser_t *browser, cef_dictionary_value_t *extra_info)
        {
            CheckSelf(self);

            var m_browser   = CefBrowser.FromNative(browser);
            var m_extraInfo = CefDictionaryValue.FromNative(extra_info);

            OnBrowserCreated(m_browser, m_extraInfo);
        }
        /// <summary>
        /// Returns the value at the specified key as type dictionary. The returned
        /// value will reference existing data and modifications to the value will
        /// modify this object.
        /// </summary>
        public CefDictionaryValue GetDictionary(string key)
        {
            fixed(char *key_str = key)
            {
                var n_key    = new cef_string_t(key_str, key != null ? key.Length : 0);
                var n_result = cef_dictionary_value_t.get_dictionary(_self, &n_key);

                return(CefDictionaryValue.FromNative(n_result));
            }
        }
Exemple #3
0
        /// <summary>
        /// Execute a method call over the DevTools protocol. This is a more structured
        /// version of SendDevToolsMessage. |message_id| is an incremental number that
        /// uniquely identifies the message (pass 0 to have the next number assigned
        /// automatically based on previous values). |method| is the method name.
        /// |params| are the method parameters, which may be empty. See the DevTools
        /// protocol documentation (linked above) for details of supported methods and
        /// the expected |params| dictionary contents. This method will return the
        /// assigned message ID if called on the UI thread and the message was
        /// successfully submitted for validation, otherwise 0. See the
        /// SendDevToolsMessage documentation for additional usage information.
        /// </summary>
        public int ExecuteDevToolsMethod(int messageId, string method, CefDictionaryValue parameters)
        {
            fixed(char *method_str = method)
            {
                var n_method = new cef_string_t(method_str, method != null ? method.Length : 0);

                return(cef_browser_host_t.execute_dev_tools_method(
                           _self, messageId, &n_method, parameters.ToNative()));
            }
        }
        /// <summary>
        /// Sets the value at the specified key as type dict. Returns true if the
        /// value was set successfully. If |value| is currently owned by another object
        /// then the value will be copied and the |value| reference will not change.
        /// Otherwise, ownership will be transferred to this object and the |value|
        /// reference will be invalidated.
        /// </summary>
        public bool SetDictionary(string key, CefDictionaryValue value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

            fixed(char *key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return(cef_dictionary_value_t.set_dictionary(_self, &n_key, value.ToNative()) != 0);
            }
        }
Exemple #5
0
        private int on_before_popup(cef_life_span_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_string_t *target_url, cef_string_t *target_frame_name, CefWindowOpenDisposition target_disposition, int user_gesture, cef_popup_features_t *popupFeatures, cef_window_info_t *windowInfo, cef_client_t **client, cef_browser_settings_t *settings, cef_dictionary_value_t **extra_info, int *no_javascript_access)
        {
            CheckSelf(self);

            var m_browser            = CefBrowser.FromNative(browser);
            var m_frame              = CefFrame.FromNative(frame);
            var m_targetUrl          = cef_string_t.ToString(target_url);
            var m_targetFrameName    = cef_string_t.ToString(target_frame_name);
            var m_userGesture        = user_gesture != 0;
            var m_popupFeatures      = new CefPopupFeatures(popupFeatures);
            var m_windowInfo         = CefWindowInfo.FromNative(windowInfo);
            var m_client             = CefClient.FromNative(*client);
            var m_settings           = new CefBrowserSettings(settings);
            var m_extraInfo          = CefDictionaryValue.FromNativeOrNull(*extra_info);
            var m_noJavascriptAccess = (*no_javascript_access) != 0;

            var o_extraInfo = m_extraInfo;
            var o_client    = m_client;
            var result      = OnBeforePopup(m_browser, m_frame, m_targetUrl, m_targetFrameName, target_disposition, m_userGesture, m_popupFeatures, m_windowInfo, ref m_client, m_settings, ref m_extraInfo, ref m_noJavascriptAccess);

            if ((object)o_client != m_client && m_client != null)
            {
                *client = m_client.ToNative();
            }

            if ((object)o_extraInfo != m_extraInfo)
            {
                *extra_info = m_extraInfo != null?m_extraInfo.ToNative() : null;
            }

            *no_javascript_access = m_noJavascriptAccess ? 1 : 0;

            m_popupFeatures.Dispose();
            m_windowInfo.Dispose();
            m_settings.Dispose();

            return(result ? 1 : 0);
        }
 /// <summary>
 /// Sets the underlying value as type dict. Returns true if the value was set
 /// successfully. This object keeps a reference to |value| and ownership of the
 /// underlying data remains unchanged.
 /// </summary>
 public bool SetDictionary(CefDictionaryValue value)
 {
     return(cef_value_t.set_dictionary(_self, value.ToNative()) != 0);
 }
Exemple #7
0
 /// <summary>
 /// Sets the value at the specified index as type dict. Returns true if the
 /// value was set successfully. After calling this method the |value| object
 /// will no longer be valid. If |value| is currently owned by another object
 /// then the value will be copied and the |value| reference will not change.
 /// Otherwise, ownership will be transferred to this object and the |value|
 /// reference will be invalidated.
 /// </summary>
 public bool SetDictionary(int index, CefDictionaryValue value)
 {
     return cef_list_value_t.set_dictionary(_self, index, value.ToNative()) != 0;
 }
 /// <summary>
 /// Returns a writable copy of this object. If |exclude_empty_children| is true
 /// any empty dictionaries or lists will be excluded from the copy.
 /// </summary>
 public CefDictionaryValue Copy(bool excludeEmptyChildren)
 {
     return(CefDictionaryValue.FromNative(
                cef_dictionary_value_t.copy(_self, excludeEmptyChildren ? 1 : 0)
                ));
 }
 /// <summary>
 /// Returns true if this object and |that| object have an equivalent underlying
 /// value but are not necessarily the same object.
 /// </summary>
 public bool IsEqual(CefDictionaryValue that)
 {
     return(cef_dictionary_value_t.is_equal(_self, that.ToNative()) != 0);
 }
 /// <summary>
 /// Returns true if this object and |that| object have the same underlying
 /// data. If true modifications to this object will also affect |that| object
 /// and vice-versa.
 /// </summary>
 public bool IsSame(CefDictionaryValue that)
 {
     return(cef_dictionary_value_t.is_same(_self, that.ToNative()) != 0);
 }
Exemple #11
0
        /// <summary>
        /// Sets the value at the specified key as type dict. Returns true if the
        /// value was set successfully. After calling this method the |value| object
        /// will no longer be valid. If |value| is currently owned by another object
        /// then the value will be copied and the |value| reference will not change.
        /// Otherwise, ownership will be transferred to this object and the |value|
        /// reference will be invalidated.
        /// </summary>
        public bool SetDictionary(string key, CefDictionaryValue value)
        {
            if (value == null) throw new ArgumentNullException("value");

            fixed (char* key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);
                return cef_dictionary_value_t.set_dictionary(_self, &n_key, value.ToNative()) != 0;
            }
        }
 /// <summary>
 /// Called after a browser has been created. When browsing cross-origin a new
 /// browser will be created before the old browser with the same identifier is
 /// destroyed. |extra_info| is a read-only value originating from
 /// CefBrowserHost::CreateBrowser(), CefBrowserHost::CreateBrowserSync(),
 /// CefLifeSpanHandler::OnBeforePopup() or CefBrowserView::CreateBrowserView().
 /// </summary>
 protected virtual void OnBrowserCreated(CefBrowser browser, CefDictionaryValue extraInfo)
 {
 }
 /// <summary>
 /// Returns the underlying value as type dictionary. The returned reference may
 /// become invalid if the value is owned by another object or if ownership is
 /// transferred to another object in the future. To maintain a reference to
 /// the value after assigning ownership to a dictionary or list pass this
 /// object to the SetValue() method instead of passing the returned reference
 /// to SetDictionary().
 /// </summary>
 public CefDictionaryValue GetDictionary()
 {
     return(CefDictionaryValue.FromNative(
                cef_value_t.get_dictionary(_self)
                ));
 }
Exemple #14
0
 /// <summary>
 /// Sets the value at the specified index as type dict. Returns true if the
 /// value was set successfully. If |value| is currently owned by another object
 /// then the value will be copied and the |value| reference will not change.
 /// Otherwise, ownership will be transferred to this object and the |value|
 /// reference will be invalidated.
 /// </summary>
 public bool SetDictionary(int index, CefDictionaryValue value)
 {
     return(cef_list_value_t.set_dictionary(_self, checked ((UIntPtr)index), value.ToNative()) != 0);
 }
Exemple #15
0
 /// <summary>
 /// Returns the value at the specified index as type dictionary. The returned
 /// value will reference existing data and modifications to the value will
 /// modify this object.
 /// </summary>
 public CefDictionaryValue GetDictionary(int index)
 {
     return(CefDictionaryValue.FromNativeOrNull(
                cef_list_value_t.get_dictionary(_self, checked ((UIntPtr)index))
                ));
 }
 /// <summary>
 /// Sets the value at the specified index as type dict. Returns true if the
 /// value was set successfully. If |value| is currently owned by another object
 /// then the value will be copied and the |value| reference will not change.
 /// Otherwise, ownership will be transferred to this object and the |value|
 /// reference will be invalidated.
 /// </summary>
 public bool SetDictionary(int index, CefDictionaryValue value)
 {
     return(cef_list_value_t.set_dictionary(_self, index, value.ToNative()) != 0);
 }
Exemple #17
0
 /// <summary>
 /// Called on the UI thread before a new popup browser is created. The
 /// |browser| and |frame| values represent the source of the popup request. The
 /// |target_url| and |target_frame_name| values indicate where the popup
 /// browser should navigate and may be empty if not specified with the request.
 /// The |target_disposition| value indicates where the user intended to open
 /// the popup (e.g. current tab, new tab, etc). The |user_gesture| value will
 /// be true if the popup was opened via explicit user gesture (e.g. clicking a
 /// link) or false if the popup opened automatically (e.g. via the
 /// DomContentLoaded event). The |popupFeatures| structure contains additional
 /// information about the requested popup window. To allow creation of the
 /// popup browser optionally modify |windowInfo|, |client|, |settings| and
 /// |no_javascript_access| and return false. To cancel creation of the popup
 /// browser return true. The |client| and |settings| values will default to the
 /// source browser's values. If the |no_javascript_access| value is set to
 /// false the new browser will not be scriptable and may not be hosted in the
 /// same renderer process as the source browser. Any modifications to
 /// |windowInfo| will be ignored if the parent browser is wrapped in a
 /// CefBrowserView. Popup browser creation will be canceled if the parent
 /// browser is destroyed before the popup browser creation completes (indicated
 /// by a call to OnAfterCreated for the popup browser). The |extra_info|
 /// parameter provides an opportunity to specify extra information specific
 /// to the created popup browser that will be passed to
 /// CefRenderProcessHandler::OnBrowserCreated() in the render process.
 /// </summary>
 protected virtual bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
 {
     return(false);
 }
        /// <summary>
        /// Returns all preferences as a dictionary. If |include_defaults| is true then
        /// preferences currently at their default value will be included. The returned
        /// object contains a copy of the underlying preference values and
        /// modifications to the returned object will not modify the underlying
        /// preference values. This method must be called on the browser process UI
        /// thread.
        /// </summary>
        public CefDictionaryValue GetAllPreferences(bool includeDefaults)
        {
            var n_result = cef_request_context_t.get_all_preferences(_self, includeDefaults ? 1 : 0);

            return(CefDictionaryValue.FromNative(n_result));
        }
 /// <summary>
 /// Creates a new object that is not owned by any other object.
 /// </summary>
 public static CefDictionaryValue Create()
 {
     return(CefDictionaryValue.FromNative(
                cef_dictionary_value_t.create()
                ));
 }
        /// <summary>
        /// Create a new browser window using the window parameters specified by
        /// |windowInfo|. If |request_context| is empty the global request context
        /// will be used. This method can only be called on the browser process UI
        /// thread. The optional |extra_info| parameter provides an opportunity to
        /// specify extra information specific to the created browser that will be
        /// passed to CefRenderProcessHandler::OnBrowserCreated() in the render
        /// process.
        /// </summary>
        public static CefBrowser CreateBrowserSync(CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, string url, CefDictionaryValue extraInfo = null, CefRequestContext requestContext = null)
        {
            if (windowInfo == null)
            {
                throw new ArgumentNullException("windowInfo");
            }
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            // TODO: [ApiUsage] if windowInfo.WindowRenderingDisabled && client doesn't provide RenderHandler implementation -> throw exception

            var n_windowInfo = windowInfo.ToNative();
            var n_client     = client.ToNative();
            var n_settings   = settings.ToNative();
            var n_extraInfo  = extraInfo != null?extraInfo.ToNative() : null;

            var n_requestContext = requestContext != null?requestContext.ToNative() : null;

            fixed(char *url_ptr = url)
            {
                cef_string_t n_url     = new cef_string_t(url_ptr, url != null ? url.Length : 0);
                var          n_browser = cef_browser_host_t.create_browser_sync(n_windowInfo, n_client, &n_url, n_settings, n_extraInfo, n_requestContext);

                return(CefBrowser.FromNative(n_browser));
            }

            // TODO: free n_ structs ?
        }
Exemple #21
0
 /// <summary>
 /// Returns the extension manifest contents as a CefDictionaryValue object. See
 /// https://developer.chrome.com/extensions/manifest for details.
 /// </summary>
 public CefDictionaryValue GetManifest()
 {
     return(CefDictionaryValue.FromNativeOrNull(
                cef_extension_t.get_manifest(_self)
                ));
 }