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, cef_popup_features_t* popupFeatures, cef_window_info_t* windowInfo, cef_client_t** client, cef_browser_settings_t* settings, 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_popupFeatures = new CefPopupFeatures(popupFeatures);
            var m_windowInfo = CefWindowInfo.FromNative(windowInfo);
            var m_client = CefClient.FromNative(*client);
            var m_settings = new CefBrowserSettings(settings);
            var m_noJavascriptAccess = (*no_javascript_access) != 0;

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

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

            *no_javascript_access = m_noJavascriptAccess ? 1 : 0;

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

            return result ? 1 : 0;
        }
Exemplo n.º 2
0
        private int get(cef_v8accessor_t* self, cef_string_t* name, cef_v8value_t* @object, cef_v8value_t** retval, cef_string_t* exception)
        {
            CheckSelf(self);

            var m_name = cef_string_t.ToString(name);
            var m_obj = CefV8Value.FromNative(@object);
            CefV8Value m_returnValue;
            string mException;

            var handled = Get(m_name, m_obj, out m_returnValue, out mException);

            if (handled)
            {
                if (mException != null)
                {
                    cef_string_t.Copy(mException, exception);
                }
                else if (m_returnValue != null)
                {
                    *retval = m_returnValue.ToNative();
                }
            }

            return handled ? 1 : 0;
        }
        private void is_unstable(cef_web_plugin_unstable_callback_t* self, cef_string_t* path, int unstable)
        {
            CheckSelf(self);

            var m_path = cef_string_t.ToString(path);
            IsUnstable(m_path, unstable != 0);
        }
Exemplo n.º 4
0
 public static void Copy(string value, cef_string_t* str)
 {
     fixed (char* value_ptr = value)
     {
         libcef.string_set(value_ptr, value != null ? (UIntPtr)value.Length : UIntPtr.Zero, str, 1); // FIXME: do not ignore result
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add a check item to the menu. Returns true on success.
 /// </summary>
 public bool AddCheckItem(int commandId, string label)
 {
     fixed (char* label_str = label)
     {
         var n_label = new cef_string_t(label_str, label.Length);
         return cef_menu_model_t.add_check_item(_self, commandId, &n_label) != 0;
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Add a radio item to the menu. Only a single item with the specified
 /// |group_id| can be checked at a time. Returns true on success.
 /// </summary>
 public bool AddRadioItem(int commandId, string label, int groupId)
 {
     fixed (char* label_str = label)
     {
         var n_label = new cef_string_t(label_str, label.Length);
         return cef_menu_model_t.add_radio_item(_self, commandId, &n_label, groupId) != 0;
     }
 }
 /// <summary>
 /// Call to continue the download. Set |download_path| to the full file path
 /// for the download including the file name or leave blank to use the
 /// suggested name and the default temp directory. Set |show_dialog| to true
 /// if you do wish to show the default "Save As" dialog.
 /// </summary>
 public void Continue(string downloadPath, bool showDialog)
 {
     fixed (char* downloadPath_ptr = downloadPath)
     {
         var n_downloadPath = new cef_string_t(downloadPath_ptr, downloadPath != null ? downloadPath.Length : 0);
         cef_before_download_callback_t.cont(_self, &n_downloadPath, showDialog ? 1 : 0);
     }
 }
        private void on_title_change(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* title)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mTitle = cef_string_t.ToString(title);

            OnTitleChange(mBrowser, mTitle);
        }
        /// <summary>
        /// Returns true if the current dictionary has a value for the given key.
        /// </summary>
        public bool HasKey(string key)
        {
            fixed (char* key_str = key)
            {
                var n_key = new cef_string_t(key_str, key != null ? key.Length : 0);

                return cef_dictionary_value_t.has_key(_self, &n_key) != 0;
            }
        }
Exemplo n.º 10
0
        private int on_tooltip(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* text)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mText = cef_string_t.ToString(text);

            return OnTooltip(mBrowser, mText) ? 1 : 0;
        }
        private void on_cancel_geolocation_permission(cef_geolocation_handler_t* self, cef_browser_t* browser, cef_string_t* requesting_url, int request_id)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_requesting_url = cef_string_t.ToString(requesting_url);

            OnCancelGeolocationPermission(m_browser, m_requesting_url, request_id);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Moves the cursor to the specified file in the archive. If |caseSensitive|
        /// is true then the search will be case sensitive. Returns true if the cursor
        /// position was set successfully.
        /// </summary>
        public bool MoveToFile(string fileName, bool caseSensitive)
        {
            fixed (char* fileName_str = fileName)
            {
                var n_fileName = new cef_string_t(fileName_str, fileName != null ? fileName.Length : 0);

                return cef_zip_reader_t.move_to_file(_self, &n_fileName, caseSensitive ? 1 : 0) != 0;
            }
        }
Exemplo n.º 13
0
        private void on_status_message(cef_display_handler_t* self, cef_browser_t* browser, cef_string_t* value)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mValue = cef_string_t.ToString(value);

            OnStatusMessage(mBrowser, mValue);
        }
        /// <summary>
        /// Continue the JS dialog request. Set |success| to true if the OK button was
        /// pressed. The |user_input| value should be specified for prompt dialogs.
        /// </summary>
        public void Continue(bool success, string userInput)
        {
            fixed (char* userInput_str = userInput)
            {
                var n_userInput = new cef_string_t(userInput_str, userInput != null ? userInput.Length : 0);

                cef_jsdialog_callback_t.cont(_self, success ? 1 : 0, &n_userInput);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Add a sub-menu to the menu. The new sub-menu is returned.
 /// </summary>
 public CefMenuModel AddSubMenu(int commandId, string label)
 {
     fixed (char* label_str = label)
     {
         var n_label = new cef_string_t(label_str, label.Length);
         return CefMenuModel.FromNative(
             cef_menu_model_t.add_sub_menu(_self, commandId, &n_label)
             );
     }
 }
        private void on_request_geolocation_permission(cef_geolocation_handler_t* self, cef_browser_t* browser, cef_string_t* requesting_url, int request_id, cef_geolocation_callback_t* callback)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_requesting_url = cef_string_t.ToString(requesting_url);
            var m_callback = CefGeolocationCallback.FromNative(callback);

            OnRequestGeolocationPermission(m_browser, m_requesting_url, request_id, m_callback);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Create a new CefProcessMessage object with the specified name.
 /// </summary>
 public static CefProcessMessage Create(string name)
 {
     fixed (char* name_str = name)
     {
         var n_name = new cef_string_t(name_str, name != null ? name.Length : 0);
         return CefProcessMessage.FromNative(
             cef_process_message_t.create(&n_name)
             );
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Returns the document element with the specified ID value.
 /// </summary>
 public CefDomNode GetElementById(string id)
 {
     fixed (char* id_str = id)
     {
         var n_id = new cef_string_t(id_str, id.Length);
         return CefDomNode.FromNativeOrNull(
             cef_domdocument_t.get_element_by_id(_self, &n_id)
             );
     }
 }
Exemplo n.º 19
0
        private void on_address_change(cef_display_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, cef_string_t* url)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mFrame = CefFrame.FromNative(frame);
            var mUrl = cef_string_t.ToString(url);

            OnAddressChange(mBrowser, mFrame, mUrl);
        }
Exemplo n.º 20
0
        private int on_before_unload_dialog(cef_jsdialog_handler_t* self, cef_browser_t* browser, cef_string_t* message_text, int is_reload, cef_jsdialog_callback_t* callback)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_message_text = cef_string_t.ToString(message_text);
            var m_callback = CefJSDialogCallback.FromNative(callback);

            return OnBeforeUnloadDialog(m_browser, m_message_text, is_reload != 0, m_callback) ? 1 : 0;
        }
Exemplo n.º 21
0
        /// <summary>
        /// The post data element will represent a file.
        /// </summary>
        public void SetToFile(string fileName)
        {
            if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("Argument can't be null or empty.", "fileName");

            fixed (char* fileName_str = fileName)
            {
                var n_fileName = new cef_string_t(fileName_str, fileName.Length);
                cef_post_data_element_t.set_to_file(_self, &n_fileName);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Creates a new cookie manager. If |path| is empty data will be stored in
        /// memory only. Otherwise, data will be stored at the specified |path|. To
        /// persist session cookies (cookies without an expiry date or validity
        /// interval) set |persist_session_cookies| to true. Session cookies are
        /// generally intended to be transient and most Web browsers do not persist
        /// them. Returns NULL if creation fails.
        /// </summary>
        public static CefCookieManager Create(string path, bool persistSessionCookies)
        {
            fixed (char* path_str = path)
            {
                var n_path = new cef_string_t(path_str, path != null ? path.Length : 0);

                return CefCookieManager.FromNativeOrNull(
                    cef_cookie_manager_t.create_manager(&n_path, persistSessionCookies ? 1 : 0)
                    );
            }
        }
Exemplo n.º 23
0
        private void on_load_error(cef_load_handler_t* self, cef_browser_t* browser, cef_frame_t* frame, CefErrorCode errorCode, cef_string_t* errorText, cef_string_t* failedUrl)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_frame = CefFrame.FromNative(frame);
            var m_errorText = cef_string_t.ToString(errorText);
            var m_failedUrl = cef_string_t.ToString(failedUrl);

            OnLoadError(m_browser, m_frame, errorCode, m_errorText, m_failedUrl);
        }
Exemplo n.º 24
0
        private void on_before_command_line_processing(cef_app_t* self, cef_string_t* process_type, cef_command_line_t* command_line)
        {
            CheckSelf(self);

            var processType = cef_string_t.ToString(process_type);
            var m_commandLine = CefCommandLine.FromNative(command_line);

            OnBeforeCommandLineProcessing(processType, m_commandLine);

            m_commandLine.Dispose();
        }
Exemplo n.º 25
0
        /// <summary>
        /// Create a new CefStreamWriter object for a file.
        /// </summary>
        public static CefStreamWriter Create(string fileName)
        {
            if (string.IsNullOrEmpty(fileName)) throw new ArgumentNullException("fileName");

            fixed (char* fileName_str = fileName)
            {
                var n_fileName = new cef_string_t(fileName_str, fileName != null ? fileName.Length : 0);
                return CefStreamWriter.FromNative(
                    cef_stream_writer_t.create_for_file(&n_fileName)
                    );
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Create a new CefXmlReader object. The returned object's methods can only
        /// be called from the thread that created the object.
        /// </summary>
        public static CefXmlReader Create(CefStreamReader stream, CefXmlEncoding encodingType, string uri)
        {
            if (stream == null) throw new ArgumentNullException("stream");

            fixed (char* uri_str = uri)
            {
                var n_uri = new cef_string_t(uri_str, uri != null ? uri.Length : 0);
                return CefXmlReader.FromNative(
                    cef_xml_reader_t.create(stream.ToNative(), encodingType, &n_uri)
                    );
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Visit a subset of cookies. The results are filtered by the given url
        /// scheme, host, domain and path. If |includeHttpOnly| is true HTTP-only
        /// cookies will also be included in the results. The returned cookies are
        /// ordered by longest path, then by earliest creation date. Returns false if
        /// cookies cannot be accessed.
        /// </summary>
        public bool VisitUrlCookies(string url, bool includeHttpOnly, CefCookieVisitor visitor)
        {
            if (string.IsNullOrEmpty(url)) throw new ArgumentNullException("url");
            if (visitor == null) throw new ArgumentNullException("visitor");

            fixed (char* url_str = url)
            {
                var n_url = new cef_string_t(url_str, url.Length);

                return cef_cookie_manager_t.visit_url_cookies(_self, &n_url, includeHttpOnly ? 1 : 0, visitor.ToNative()) != 0;
            }
        }
        private int get_localized_string(cef_resource_bundle_handler_t* self, int message_id, cef_string_t* @string)
        {
            CheckSelf(self);

            var value = GetLocalizedString(message_id);

            if (value != null)
            {
                cef_string_t.Copy(value, @string);
                return 1;
            }
            else return 0;
        }
Exemplo n.º 29
0
        private void on_before_download(cef_download_handler_t* self, cef_browser_t* browser, cef_download_item_t* download_item, cef_string_t* suggested_name, cef_before_download_callback_t* callback)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_download_item = CefDownloadItem.FromNative(download_item);
            var m_suggested_name = cef_string_t.ToString(suggested_name);
            var m_callback = CefBeforeDownloadCallback.FromNative(callback);

            OnBeforeDownload(m_browser, m_download_item, m_suggested_name, m_callback);

            m_download_item.Dispose();
        }
Exemplo n.º 30
0
        private int on_file_dialog(cef_dialog_handler_t* self, cef_browser_t* browser, CefFileDialogMode mode, cef_string_t* title, cef_string_t* default_file_name, cef_string_list* accept_types, cef_file_dialog_callback_t* callback)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mTitle = cef_string_t.ToString(title);
            var mDefaultFileName = cef_string_t.ToString(default_file_name);
            var mAcceptTypes = cef_string_list.ToArray(accept_types);
            var mCallback = CefFileDialogCallback.FromNative(callback);

            var result = OnFileDialog(mBrowser, mode, mTitle, mDefaultFileName, mAcceptTypes, mCallback);

            return result ? 1 : 0;
        }
Exemplo n.º 31
0
        public static cef_string_list *From(string[] list)
        {
            var result = libcef.string_list_alloc();

            if (list != null && list.Length > 0)
            {
                for (var i = 0; i < list.Length; i++)
                {
                    var item = list[i];
                    fixed(char *item_str = item)
                    {
                        var n_item = new cef_string_t(item_str, item != null ? item.Length : 0);

                        libcef.string_list_append(result, &n_item);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 32
0
        public static cef_string_multimap *From(NameValueCollection collection)
        {
            var result = libcef.string_multimap_alloc();

            foreach (string key in collection)
            {
                fixed(char *key_ptr = key)
                {
                    var n_key = new cef_string_t(key_ptr, key.Length);

                    foreach (var value in collection.GetValues(key))
                    {
                        fixed(char *value_ptr = value)
                        {
                            var n_value = new cef_string_t(value_ptr, value.Length);

                            libcef.string_multimap_append(result, &n_key, &n_value);
                        }
                    }
                }
            }

            return(result);
        }