/// <summary> /// Stop tracing events on all processes. /// /// This function will fail and return false if a previous call to /// CefEndTracingAsync is already pending or if CefBeginTracing was not called. /// /// |tracing_file| is the path at which tracing data will be written and /// |callback| is the callback that will be executed once all processes have /// sent their trace data. If |tracing_file| is empty a new temporary file path /// will be used. If |callback| is empty no trace data will be written. /// /// This function must be called on the browser process UI thread. /// </summary> public static bool EndTracing(string tracingFile = null, CefEndTracingCallback callback = null) { fixed(char *tracingFile_str = tracingFile) { var n_tracingFile = new cef_string_t(tracingFile_str, tracingFile != null ? tracingFile.Length : 0); var n_callback = callback != null?callback.ToNative() : null; return(libcef.end_tracing(&n_tracingFile, n_callback) != 0); } }
/// <summary> /// Returns a complete URL based on the document base URL and the specified /// partial URL. /// </summary> public string GetCompleteUrl(string partialUrl) { fixed(char *partialUrl_str = partialUrl) { var n_partialUrl = new cef_string_t(partialUrl_str, partialUrl.Length); var n_result = cef_domdocument_t.get_complete_url(_self, &n_partialUrl); return(cef_string_userfree.ToString(n_result)); } }
/// <summary> /// Return the key at the specified zero-based string multimap index. /// </summary> public string GetKey(int index) { cef_string_t n_key = new cef_string_t(); var success = NativeMethods.cef_string_multimap_key(this.handle, index, &n_key) != 0; var result = success ? cef_string_t.ToString(&n_key) : null; cef_string_t.Clear(&n_key); // TODO: throw if failed return(result); }
/// <summary> /// Creates a new cookie manager. If |path| is empty data will be stored in /// memory only. Returns NULL if creation fails. /// </summary> public static CefCookieManager CreateManager(string path) { fixed(char *path_str = path) { var m_path = new cef_string_t(path_str, path != null ? path.Length : 0); var m_cookie_manager = NativeMethods.cef_cookie_manager_create_manager(&m_path); return(CefCookieManager.FromOrDefault(m_cookie_manager)); } }
/// <summary> /// Returns the element attribute named |attrName|. /// </summary> public string GetAttribute(string attrName) { fixed(char *attrName_str = attrName) { var n_attrName = new cef_string_t(attrName_str, attrName.Length); var n_result = cef_domnode_t.get_element_attribute(_self, &n_attrName); return(cef_string_userfree.ToString(n_result)); } }
/// <summary> /// Parses the specified |json_string| and returns a dictionary or list /// representation. If JSON parsing fails this method returns NULL. /// </summary> public static CefValue ParseJson(string value, CefJsonParserOptions options) { fixed(char *value_str = value) { var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); var n_result = libcef.parse_json(&n_value, options); return(CefValue.FromNativeOrNull(n_result)); } }
/// <summary> /// Start tracing events on all processes. Tracing is initialized asynchronously /// and |callback| will be executed on the UI thread after initialization is /// complete. /// /// If CefBeginTracing was called previously, or if a CefEndTracingAsync call is /// pending, CefBeginTracing will fail and return false. /// /// |categories| is a comma-delimited list of category wildcards. A category can /// have an optional '-' prefix to make it an excluded category. Having both /// included and excluded categories in the same list is not supported. /// /// Example: "test_MyTest*" /// Example: "test_MyTest*,test_OtherStuff" /// Example: "-excluded_category1,-excluded_category2" /// /// This function must be called on the browser process UI thread. /// </summary> public static bool BeginTracing(string categories = null, CefCompletionCallback callback = null) { fixed(char *categories_str = categories) { var n_categories = new cef_string_t(categories_str, categories != null ? categories.Length : 0); var n_callback = callback != null?callback.ToNative() : null; return(libcef.begin_tracing(&n_categories, n_callback) != 0); } }
/// <summary> /// Unescapes |text| and returns the result. Unescaping consists of looking for /// the exact pattern "%XX" where each X is a hex digit and converting to the /// character with the numerical value of those digits (e.g. "i%20=%203%3b" /// unescapes to "i = 3;"). If |convert_to_utf8| is true this function will /// attempt to interpret the initial decoded result as UTF-8. If the result is /// convertable into UTF-8 it will be returned as converted. Otherwise the /// initial decoded result will be returned. The |unescape_rule| parameter /// supports further customization the decoding process. /// </summary> public static string UriDecode(string text, bool convertToUtf8, CefUriUnescapeRules unescapeRule) { fixed(char *text_str = text) { var n_text = new cef_string_t(text_str, text != null ? text.Length : 0); var n_result = libcef.uridecode(&n_text, convertToUtf8 ? 1 : 0, unescapeRule); return(cef_string_userfree.ToString(n_result)); } }
/// <summary> /// Returns the mime type for the specified file extension or an empty string if /// unknown. /// </summary> public static string GetMimeType(string extension) { fixed(char *extension_str = extension) { var n_extension = new cef_string_t(extension_str, extension != null ? extension.Length : 0); var n_result = libcef.get_mime_type(&n_extension); return(cef_string_userfree.ToString(n_result)); } }
/// <summary> /// Set the program part of the command line string (the first item). /// </summary> public void SetProgram(string value) { // if (value == null) throw new ArgumentNullException("value"); fixed(char *value_str = value) { var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); cef_command_line_t.set_program(_self, &n_value); } }
/// <summary> /// Add a check item to the menu. Returns true (1) on success. /// </summary> public unsafe virtual bool AddCheckItem(int commandId, string label) { fixed(char *s1 = label) { var cstr1 = new cef_string_t { Str = s1, Length = label != null ? label.Length : 0 }; return(SafeCall(NativeInstance->AddCheckItem(commandId, &cstr1) != 0)); } }
/// <summary> /// Set the label at the specified |index|. Returns true (1) on success. /// </summary> public unsafe virtual bool SetLabelAt(int index, string label) { fixed(char *s1 = label) { var cstr1 = new cef_string_t { Str = s1, Length = label != null ? label.Length : 0 }; return(SafeCall(NativeInstance->SetLabelAt(index, &cstr1) != 0)); } }
/// <summary> /// Insert a radio item in the menu at the specified |index|. Only a single /// item with the specified |group_id| can be checked at a time. Returns true /// (1) on success. /// </summary> public unsafe virtual bool InsertRadioItemAt(int index, int commandId, string label, int groupId) { fixed(char *s2 = label) { var cstr2 = new cef_string_t { Str = s2, Length = label != null ? label.Length : 0 }; return(SafeCall(NativeInstance->InsertRadioItemAt(index, commandId, &cstr2, groupId) != 0)); } }
/// <summary> /// Moves the cursor to the attribute with the specified local name and /// namespace URI. Returns true if the cursor position was set successfully. /// </summary> public bool MoveToAttribute(string localName, string namespaceUri) { fixed(char *localName_str = localName) fixed(char *namespaceUri_str = namespaceUri) { var n_localName = new cef_string_t(localName_str, localName != null ? localName.Length : 0); var n_namespaceUri = new cef_string_t(namespaceUri_str, namespaceUri != null ? namespaceUri.Length : 0); return(cef_xml_reader_t.move_to_attribute_bylname(_self, &n_localName, &n_namespaceUri) != 0); } }
/// <summary> /// Returns the frame with the specified name, or NULL if not found. /// </summary> public unsafe virtual CefFrame GetFrame(string name) { fixed(char *s0 = name) { var cstr0 = new cef_string_t { Str = s0, Length = name != null ? name.Length : 0 }; return(SafeCall(CefFrame.Wrap(CefFrame.Create, NativeInstance->GetFrame(&cstr0)))); } }
private static cef_v8value_t *CreateStringInternal(string value) { fixed(char *s = value) { var cstr = new cef_string_t { Str = s, Length = (value != null ? value.Length : 0) }; return(CefNativeApi.cef_v8value_create_string(&cstr)); } }
/// <summary> /// Add a sub-menu to the menu. The new sub-menu is returned. /// </summary> public unsafe virtual CefMenuModel AddSubMenu(int commandId, string label) { fixed(char *s1 = label) { var cstr1 = new cef_string_t { Str = s1, Length = label != null ? label.Length : 0 }; return(SafeCall(CefMenuModel.Wrap(CefMenuModel.Create, NativeInstance->AddSubMenu(commandId, &cstr1)))); } }
/// <summary> /// Register a custom scheme. This function should not be called for the built- /// in HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes. /// See cef_scheme_options_t for possible values for |options|. /// This function may be called on any thread. It should only be called once /// per unique |scheme_name| value. If |scheme_name| is already registered or /// if an error occurs this function will return false (0). /// </summary> public unsafe virtual bool AddCustomScheme(string schemeName, int options) { fixed(char *s0 = schemeName) { var cstr0 = new cef_string_t { Str = s0, Length = schemeName != null ? schemeName.Length : 0 }; return(SafeCall(NativeInstance->AddCustomScheme(&cstr0, options) != 0)); } }
/// <summary> /// Insert a sub-menu in the menu at the specified |index|. The new sub-menu is /// returned. /// </summary> public unsafe virtual CefMenuModel InsertSubMenuAt(int index, int commandId, string label) { fixed(char *s2 = label) { var cstr2 = new cef_string_t { Str = s2, Length = label != null ? label.Length : 0 }; return(SafeCall(CefMenuModel.Wrap(CefMenuModel.Create, NativeInstance->InsertSubMenuAt(index, commandId, &cstr2)))); } }
/// <summary> /// Returns the frame with the specified name, or NULL if not found. /// </summary> public CefFrame GetFrame(string name) { fixed(char *name_str = name) { var n_name = new cef_string_t(name_str, name.Length); return(CefFrame.FromNativeOrNull( cef_browser_t.get_frame(_self, &n_name) )); } }
/// <summary> /// Sets the font list for the specified |index|. Specify an |index| value of /// -1 to set the default font. If |font_list| is NULL the system font will be /// used. Returns true (1) on success. The format is /// " /// <FONT /// _FAMILY_LIST>,[STYLES] /// <SIZE /// >", where: - FONT_FAMILY_LIST is a comma- /// separated list of font family names, - STYLES is an optional space- /// separated list of style names (case-sensitive /// "Bold" and "Italic" are supported), and /// - SIZE is an integer font size in pixels with the suffix "px". /// Here are examples of valid font description strings: - "Arial, Helvetica, /// Bold Italic 14px" - "Arial, 14px" /// </summary> public unsafe virtual bool SetFontListAt(int index, string fontList) { fixed(char *s1 = fontList) { var cstr1 = new cef_string_t { Str = s1, Length = fontList != null ? fontList.Length : 0 }; return(SafeCall(NativeInstance->SetFontListAt(index, &cstr1) != 0)); } }
/// <summary> /// Create a new CefV8Value object of type function. This method should only be /// called from within the scope of a CefRenderProcessHandler, CefV8Handler or /// CefV8Accessor callback, or in combination with calling Enter() and Exit() /// on a stored CefV8Context reference. /// </summary> public static CefV8Value CreateFunction(string name, CefV8Handler handler) { fixed(char *name_str = name) { var n_name = new cef_string_t(name_str, name != null ? name.Length : 0); return(CefV8Value.FromNative( cef_v8value_t.create_function(&n_name, handler.ToNative()) )); } }
/// <summary> /// Set the value for the element attribute named |attrName|. Returns true on /// success. /// </summary> public bool SetAttribute(string attrName, string value) { fixed(char *attrName_str = attrName) fixed(char *value_str = value) { var n_attrName = new cef_string_t(attrName_str, attrName.Length); var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); return(cef_domnode_t.set_element_attribute(_self, &n_attrName, &n_value) != 0); } }
/// <summary> /// Returns the value with the specified identifier on success. Returns NULL /// if this method is called incorrectly or an exception is thrown. /// </summary> public CefV8Value GetValue(string key) { fixed(char *key_str = key) { var n_key = new cef_string_t(key_str, key != null ? key.Length : 0); return(CefV8Value.FromNativeOrNull( cef_v8value_t.get_value_bykey(_self, &n_key) )); } }
/// <summary> /// Returns true if the command line contains the given switch. /// </summary> public bool HasSwitch(string name) { // TODO: use CheckSwitchName method fixed(char *name_str = name) { var n_name = new cef_string_t(name_str, name.Length); return(cef_command_line_t.has_switch(_self, &n_name) != 0); } }
/// <summary> /// Create a new CefV8Value object of type string. /// </summary> public static CefV8Value CreateString(string value) { fixed(char *value_str = value) { var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); return(CefV8Value.FromNative( cef_v8value_t.create_string(&n_value) )); } }
/// <summary> /// Escapes characters in |text| which are unsuitable for use as a query /// parameter value. Everything except alphanumerics and -_.!~*'() will be /// converted to "%XX". If |use_plus| is true spaces will change to "+". The /// result is basically the same as encodeURIComponent in Javacript. /// </summary> public static string UriEncode(string text, bool usePlus) { fixed(char *text_str = text) { var n_text = new cef_string_t(text_str, text != null ? text.Length : 0); var n_result = libcef.uriencode(&n_text, usePlus ? 1 : 0); return(cef_string_userfree.ToString(n_result)); } }
/// <summary> /// Load the contents of |string_val| with the specified dummy |url|. |url| /// should have a standard scheme (for example, http scheme) or behaviors like /// link clicks and web security restrictions may not behave as expected. /// </summary> public void LoadString(string content, string url) { fixed(char *content_str = content) fixed(char *url_str = url) { var n_content = new cef_string_t(content_str, content != null ? content.Length : 0); var n_url = new cef_string_t(url_str, url != null ? url.Length : 0); cef_frame_t.load_string(_self, &n_content, &n_url); } }
/// <summary> /// Sets the value at the specified key as type string. Returns true if the /// value was set successfully. /// </summary> public bool SetString(string key, string value) { fixed(char *key_str = key) fixed(char *value_str = value) { var n_key = new cef_string_t(key_str, key != null ? key.Length : 0); var n_value = new cef_string_t(value_str, value != null ? value.Length : 0); return(cef_dictionary_value_t.set_string(_self, &n_key, &n_value) != 0); } }
/// <summary> /// Execute a string of JavaScript code in this frame. The |script_url| /// parameter is the URL where the script in question can be found, if any. /// The renderer may request this URL to show the developer the source of the /// error. The |start_line| parameter is the base line number to use for error /// reporting. /// </summary> public void ExecuteJavaScript(string code, string url, int line) { fixed(char *code_str = code) fixed(char *url_str = url) { var n_code = new cef_string_t(code_str, code != null ? code.Length : 0); var n_url = new cef_string_t(url_str, url != null ? url.Length : 0); cef_frame_t.execute_java_script(_self, &n_code, &n_url, line); } }