1 // Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // The contents of this file must follow a specific format in order to 33 // support the CEF translator tool. See the translator.README.txt file in the 34 // tools directory for more information. 35 // 36 37 #ifndef CEF_INCLUDE_CEF_EXTENSION_H_ 38 #define CEF_INCLUDE_CEF_EXTENSION_H_ 39 #pragma once 40 41 #include "include/cef_base.h" 42 #include "include/cef_values.h" 43 44 class CefExtensionHandler; 45 class CefRequestContext; 46 47 /// 48 // Object representing an extension. Methods may be called on any thread unless 49 // otherwise indicated. 50 /// 51 /*--cef(source=library)--*/ 52 class CefExtension : public CefBaseRefCounted { 53 public: 54 /// 55 // Returns the unique extension identifier. This is calculated based on the 56 // extension public key, if available, or on the extension path. See 57 // https://developer.chrome.com/extensions/manifest/key for details. 58 /// 59 /*--cef()--*/ 60 virtual CefString GetIdentifier() = 0; 61 62 /// 63 // Returns the absolute path to the extension directory on disk. This value 64 // will be prefixed with PK_DIR_RESOURCES if a relative path was passed to 65 // CefRequestContext::LoadExtension. 66 /// 67 /*--cef()--*/ 68 virtual CefString GetPath() = 0; 69 70 /// 71 // Returns the extension manifest contents as a CefDictionaryValue object. See 72 // https://developer.chrome.com/extensions/manifest for details. 73 /// 74 /*--cef()--*/ 75 virtual CefRefPtr<CefDictionaryValue> GetManifest() = 0; 76 77 /// 78 // Returns true if this object is the same extension as |that| object. 79 // Extensions are considered the same if identifier, path and loader context 80 // match. 81 /// 82 /*--cef()--*/ 83 virtual bool IsSame(CefRefPtr<CefExtension> that) = 0; 84 85 /// 86 // Returns the handler for this extension. Will return NULL for internal 87 // extensions or if no handler was passed to CefRequestContext::LoadExtension. 88 /// 89 /*--cef()--*/ 90 virtual CefRefPtr<CefExtensionHandler> GetHandler() = 0; 91 92 /// 93 // Returns the request context that loaded this extension. Will return NULL 94 // for internal extensions or if the extension has been unloaded. See the 95 // CefRequestContext::LoadExtension documentation for more information about 96 // loader contexts. Must be called on the browser process UI thread. 97 /// 98 /*--cef()--*/ 99 virtual CefRefPtr<CefRequestContext> GetLoaderContext() = 0; 100 101 /// 102 // Returns true if this extension is currently loaded. Must be called on the 103 // browser process UI thread. 104 /// 105 /*--cef()--*/ 106 virtual bool IsLoaded() = 0; 107 108 /// 109 // Unload this extension if it is not an internal extension and is currently 110 // loaded. Will result in a call to CefExtensionHandler::OnExtensionUnloaded 111 // on success. 112 /// 113 /*--cef()--*/ 114 virtual void Unload() = 0; 115 }; 116 117 #endif // CEF_INCLUDE_CEF_EXTENSION_H_ 118