1 // Copyright (c) 2012 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_WEB_PLUGIN_H_ 38 #define CEF_INCLUDE_CEF_WEB_PLUGIN_H_ 39 40 #include "include/cef_base.h" 41 42 class CefBrowser; 43 44 /// 45 // Information about a specific web plugin. 46 /// 47 /*--cef(source=library)--*/ 48 class CefWebPluginInfo : public virtual CefBaseRefCounted { 49 public: 50 /// 51 // Returns the plugin name. 52 /// 53 /*--cef()--*/ 54 virtual CefString GetName() = 0; 55 56 /// 57 // Returns the plugin file path (DLL/bundle/library). 58 /// 59 /*--cef()--*/ 60 virtual CefString GetPath() = 0; 61 62 /// 63 // Returns the version of the plugin (may be OS-specific). 64 /// 65 /*--cef()--*/ 66 virtual CefString GetVersion() = 0; 67 68 /// 69 // Returns a description of the plugin from the version information. 70 /// 71 /*--cef()--*/ 72 virtual CefString GetDescription() = 0; 73 }; 74 75 /// 76 // Interface to implement for visiting web plugin information. The methods of 77 // this class will be called on the browser process UI thread. 78 /// 79 /*--cef(source=client)--*/ 80 class CefWebPluginInfoVisitor : public virtual CefBaseRefCounted { 81 public: 82 /// 83 // Method that will be called once for each plugin. |count| is the 0-based 84 // index for the current plugin. |total| is the total number of plugins. 85 // Return false to stop visiting plugins. This method may never be called if 86 // no plugins are found. 87 /// 88 /*--cef()--*/ 89 virtual bool Visit(CefRefPtr<CefWebPluginInfo> info, 90 int count, 91 int total) = 0; 92 }; 93 94 /// 95 // Visit web plugin information. Can be called on any thread in the browser 96 // process. 97 /// 98 /*--cef()--*/ 99 void CefVisitWebPluginInfo(CefRefPtr<CefWebPluginInfoVisitor> visitor); 100 101 /// 102 // Cause the plugin list to refresh the next time it is accessed regardless 103 // of whether it has already been loaded. Can be called on any thread in the 104 // browser process. 105 /// 106 /*--cef()--*/ 107 void CefRefreshWebPlugins(); 108 109 /// 110 // Unregister an internal plugin. This may be undone the next time 111 // CefRefreshWebPlugins() is called. Can be called on any thread in the browser 112 // process. 113 /// 114 /*--cef()--*/ 115 void CefUnregisterInternalWebPlugin(const CefString& path); 116 117 /// 118 // Register a plugin crash. Can be called on any thread in the browser process 119 // but will be executed on the IO thread. 120 /// 121 /*--cef()--*/ 122 void CefRegisterWebPluginCrash(const CefString& path); 123 124 /// 125 // Interface to implement for receiving unstable plugin information. The methods 126 // of this class will be called on the browser process IO thread. 127 /// 128 /*--cef(source=client)--*/ 129 class CefWebPluginUnstableCallback : public virtual CefBaseRefCounted { 130 public: 131 /// 132 // Method that will be called for the requested plugin. |unstable| will be 133 // true if the plugin has reached the crash count threshold of 3 times in 120 134 // seconds. 135 /// 136 /*--cef()--*/ 137 virtual void IsUnstable(const CefString& path, bool unstable) = 0; 138 }; 139 140 /// 141 // Query if a plugin is unstable. Can be called on any thread in the browser 142 // process. 143 /// 144 /*--cef()--*/ 145 void CefIsWebPluginUnstable(const CefString& path, 146 CefRefPtr<CefWebPluginUnstableCallback> callback); 147 148 /// 149 // Implement this interface to receive notification when CDM registration is 150 // complete. The methods of this class will be called on the browser process 151 // UI thread. 152 /// 153 /*--cef(source=client)--*/ 154 class CefRegisterCdmCallback : public virtual CefBaseRefCounted { 155 public: 156 /// 157 // Method that will be called when CDM registration is complete. |result| 158 // will be CEF_CDM_REGISTRATION_ERROR_NONE if registration completed 159 // successfully. Otherwise, |result| and |error_message| will contain 160 // additional information about why registration failed. 161 /// 162 /*--cef(optional_param=error_message)--*/ 163 virtual void OnCdmRegistrationComplete(cef_cdm_registration_error_t result, 164 const CefString& error_message) = 0; 165 }; 166 167 /// 168 // Register the Widevine CDM plugin. 169 // 170 // The client application is responsible for downloading an appropriate 171 // platform-specific CDM binary distribution from Google, extracting the 172 // contents, and building the required directory structure on the local machine. 173 // The CefBrowserHost::StartDownload method and CefZipArchive class can be used 174 // to implement this functionality in CEF. Contact Google via 175 // https://www.widevine.com/contact.html for details on CDM download. 176 // 177 // |path| is a directory that must contain the following files: 178 // 1. manifest.json file from the CDM binary distribution (see below). 179 // 2. widevinecdm file from the CDM binary distribution (e.g. 180 // widevinecdm.dll on on Windows, libwidevinecdm.dylib on OS X, 181 // libwidevinecdm.so on Linux). 182 // 183 // If any of these files are missing or if the manifest file has incorrect 184 // contents the registration will fail and |callback| will receive a |result| 185 // value of CEF_CDM_REGISTRATION_ERROR_INCORRECT_CONTENTS. 186 // 187 // The manifest.json file must contain the following keys: 188 // A. "os": Supported OS (e.g. "mac", "win" or "linux"). 189 // B. "arch": Supported architecture (e.g. "ia32" or "x64"). 190 // C. "x-cdm-module-versions": Module API version (e.g. "4"). 191 // D. "x-cdm-interface-versions": Interface API version (e.g. "8"). 192 // E. "x-cdm-host-versions": Host API version (e.g. "8"). 193 // F. "version": CDM version (e.g. "1.4.8.903"). 194 // G. "x-cdm-codecs": List of supported codecs (e.g. "vp8,vp09,avc1"). 195 // 196 // A through E are used to verify compatibility with the current Chromium 197 // version. If the CDM is not compatible the registration will fail and 198 // |callback| will receive a |result| value of 199 // CEF_CDM_REGISTRATION_ERROR_INCOMPATIBLE. 200 // 201 // |callback| will be executed asynchronously once registration is complete. 202 // 203 // On Linux this function must be called before CefInitialize() and the 204 // registration cannot be changed during runtime. If registration is not 205 // supported at the time that CefRegisterWidevineCdm() is called then |callback| 206 // will receive a |result| value of CEF_CDM_REGISTRATION_ERROR_NOT_SUPPORTED. 207 /// 208 /*--cef(optional_param=callback)--*/ 209 void CefRegisterWidevineCdm(const CefString& path, 210 CefRefPtr<CefRegisterCdmCallback> callback); 211 212 #endif // CEF_INCLUDE_CEF_WEB_PLUGIN_H_ 213