Example #1
0
        /// <summary>
        /// Load an extension.
        ///
        /// If extension resources will be read from disk using the default load
        /// implementation then |rootDirectory| should be the absolute path to the
        /// extension resources directory and |manifest| should be NULL. If extension
        /// resources will be provided by the client (e.g. via CfxRequestHandler
        /// and/or CfxExtensionHandler) then |rootDirectory| should be a path
        /// component unique to the extension (if not absolute this will be internally
        /// prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the
        /// contents that would otherwise be read from the "manifest.json" file on
        /// disk.
        ///
        /// The loaded extension will be accessible in all contexts sharing the same
        /// storage (HasExtension returns true (1)). However, only the context on which
        /// this function was called is considered the loader (DidLoadExtension returns
        /// true (1)) and only the loader will receive CfxRequestContextHandler
        /// callbacks for the extension.
        ///
        /// CfxExtensionHandler.OnExtensionLoaded will be called on load success or
        /// CfxExtensionHandler.OnExtensionLoadFailed will be called on load
        /// failure.
        ///
        /// If the extension specifies a background script via the "background"
        /// manifest key then CfxExtensionHandler.OnBeforeBackgroundBrowser will be
        /// called to create the background browser. See that function for additional
        /// information about background scripts.
        ///
        /// For visible extension views the client application should evaluate the
        /// manifest to determine the correct extension URL to load and then pass that
        /// URL to the CfxBrowserHost.CreateBrowser* function after the extension
        /// has loaded. For example, the client can look for the "browser_action"
        /// manifest key as documented at
        /// https://developer.chrome.com/extensions/browserAction. Extension URLs take
        /// the form "chrome-extension://&lt;extension_id>/&lt;path>".
        ///
        /// Browsers that host extensions differ from normal browsers as follows:
        ///  - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit
        ///    chrome://extensions-support for the list of extension APIs currently
        ///    supported by CEF.
        ///  - Main frame navigation to non-extension content is blocked.
        ///  - Pinch-zooming is disabled.
        ///  - CfxBrowserHost.GetExtension returns the hosted extension.
        ///  - CfxBrowserHost.IsBackgroundHost returns true for background hosts.
        ///
        /// See https://developer.chrome.com/extensions for extension implementation
        /// and usage documentation.
        /// </summary>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
        /// </remarks>
        public void LoadExtension(string rootDirectory, CfxDictionaryValue manifest, CfxExtensionHandler handler)
        {
            var rootDirectory_pinned = new PinnedString(rootDirectory);

            CfxApi.RequestContext.cfx_request_context_load_extension(NativePtr, rootDirectory_pinned.Obj.PinnedPtr, rootDirectory_pinned.Length, CfxDictionaryValue.Unwrap(manifest), CfxExtensionHandler.Unwrap(handler));
            rootDirectory_pinned.Obj.Free();
        }
        /// <summary>
        /// Sets the value at the specified key as type dict. Returns true (1) 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>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
        /// </remarks>
        public bool SetDictionary(string key, CfxDictionaryValue value)
        {
            var key_pinned = new PinnedString(key);
            var __retval   = CfxApi.DictionaryValue.cfx_dictionary_value_set_dictionary(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length, CfxDictionaryValue.Unwrap(value));

            key_pinned.Obj.Free();
            return(0 != __retval);
        }
        /// <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>
        /// <remarks>
        /// See also the original CEF documentation in
        /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
        /// </remarks>
        public CfxDictionaryValue GetDictionary(string key)
        {
            var key_pinned = new PinnedString(key);
            var __retval   = CfxApi.DictionaryValue.cfx_dictionary_value_get_dictionary(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length);

            key_pinned.Obj.Free();
            return(CfxDictionaryValue.Wrap(__retval));
        }
 internal static CfxDictionaryValue Wrap(IntPtr nativePtr)
 {
     if (nativePtr == IntPtr.Zero)
     {
         return(null);
     }
     lock (weakCache) {
         var wrapper = (CfxDictionaryValue)weakCache.Get(nativePtr);
         if (wrapper == null)
         {
             wrapper = new CfxDictionaryValue(nativePtr);
             weakCache.Add(wrapper);
         }
         else
         {
             CfxApi.cfx_release(nativePtr);
         }
         return(wrapper);
     }
 }
Example #5
0
 /// <summary>
 /// Sets the value at the specified index as type dict. Returns true (1) 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetDictionary(int index, CfxDictionaryValue value)
 {
     return(0 != CfxApi.cfx_list_value_set_dictionary(NativePtr, index, CfxDictionaryValue.Unwrap(value)));
 }
Example #6
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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public CfxDictionaryValue GetDictionary(int index)
 {
     return(CfxDictionaryValue.Wrap(CfxApi.cfx_list_value_get_dictionary(NativePtr, index)));
 }
 /// <summary>
 /// Creates a new object that is not owned by any other object.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public static CfxDictionaryValue Create()
 {
     return(CfxDictionaryValue.Wrap(CfxApi.DictionaryValue.cfx_dictionary_value_create()));
 }
Example #8
0
 /// <summary>
 /// Sets the value at the specified key as type dict. Returns true (1) 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetDictionary(string key, CfxDictionaryValue value)
 {
     var key_pinned = new PinnedString(key);
     var __retval = CfxApi.cfx_dictionary_value_set_dictionary(NativePtr, key_pinned.Obj.PinnedPtr, key_pinned.Length, CfxDictionaryValue.Unwrap(value));
     key_pinned.Obj.Free();
     return 0 != __retval;
 }
 /// <summary>
 /// Returns true (1) if this object and |that| object have an equivalent
 /// underlying value but are not necessarily the same object.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool IsEqual(CfxDictionaryValue that)
 {
     return(0 != CfxApi.DictionaryValue.cfx_dictionary_value_is_equal(NativePtr, CfxDictionaryValue.Unwrap(that)));
 }
 /// <summary>
 /// Sets the underlying value as type dict. Returns true (1) if the value was
 /// set successfully. This object keeps a reference to |value| and ownership of
 /// the underlying data remains unchanged.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetDictionary(CfxDictionaryValue value)
 {
     return(0 != CfxApi.Value.cfx_value_set_dictionary(NativePtr, CfxDictionaryValue.Unwrap(value)));
 }
 /// <summary>
 /// Returns true (1) if this object and |that| object have the same underlying
 /// data. If true (1) modifications to this object will also affect |that|
 /// object and vice-versa.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool IsSame(CfxDictionaryValue that)
 {
     return(0 != CfxApi.cfx_dictionary_value_is_same(NativePtr, CfxDictionaryValue.Unwrap(that)));
 }
Example #12
0
 /// <summary>
 /// Sets the value at the specified index as type dict. Returns true (1) 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetDictionary(ulong index, CfxDictionaryValue value)
 {
     return(0 != CfxApi.ListValue.cfx_list_value_set_dictionary(NativePtr, (UIntPtr)index, CfxDictionaryValue.Unwrap(value)));
 }
Example #13
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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public CfxDictionaryValue GetDictionary(ulong index)
 {
     return(CfxDictionaryValue.Wrap(CfxApi.ListValue.cfx_list_value_get_dictionary(NativePtr, (UIntPtr)index)));
 }
Example #14
0
 internal static CfxDictionaryValue Wrap(IntPtr nativePtr)
 {
     if(nativePtr == IntPtr.Zero) return null;
     lock(weakCache) {
         var wrapper = (CfxDictionaryValue)weakCache.Get(nativePtr);
         if(wrapper == null) {
             wrapper = new CfxDictionaryValue(nativePtr);
             weakCache.Add(wrapper);
         } else {
             CfxApi.cfx_release(nativePtr);
         }
         return wrapper;
     }
 }
Example #15
0
 /// <summary>
 /// Sets the value at the specified index as type dict. Returns true (1) 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>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool SetDictionary(int index, CfxDictionaryValue value)
 {
     return 0 != CfxApi.cfx_list_value_set_dictionary(NativePtr, index, CfxDictionaryValue.Unwrap(value));
 }
 /// <summary>
 /// Returns a writable copy of this object. If |excludeNullChildren| is true
 /// (1) any NULL dictionaries or lists will be excluded from the copy.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public CfxDictionaryValue Copy(bool excludeEmptyChildren)
 {
     return(CfxDictionaryValue.Wrap(CfxApi.DictionaryValue.cfx_dictionary_value_copy(NativePtr, excludeEmptyChildren ? 1 : 0)));
 }
Example #17
0
 /// <summary>
 /// Returns all preferences as a dictionary. If |includeDefaults| is true (1)
 /// 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 function must be called on the browser process UI
 /// thread.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>.
 /// </remarks>
 public CfxDictionaryValue GetAllPreferences(bool includeDefaults)
 {
     return(CfxDictionaryValue.Wrap(CfxApi.cfx_request_context_get_all_preferences(NativePtr, includeDefaults ? 1 : 0)));
 }
Example #18
0
 /// <summary>
 /// Returns true (1) if this object and |that| object have the same underlying
 /// data. If true (1) modifications to this object will also affect |that|
 /// object and vice-versa.
 /// </summary>
 /// <remarks>
 /// See also the original CEF documentation in
 /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_values_capi.h">cef/include/capi/cef_values_capi.h</see>.
 /// </remarks>
 public bool IsSame(CfxDictionaryValue that)
 {
     return 0 != CfxApi.cfx_dictionary_value_is_same(NativePtr, CfxDictionaryValue.Unwrap(that));
 }