1 // Copyright (c) 2017 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_ 6 #define CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_ 7 #pragma once 8 9 #include <memory> 10 11 #include "include/cef_extension.h" 12 #include "include/cef_extension_handler.h" 13 #include "include/cef_request_context.h" 14 15 namespace extensions { 16 class Extension; 17 } 18 19 // CefNavigationEntry implementation 20 class CefExtensionImpl : public CefExtension { 21 public: 22 CefExtensionImpl(const extensions::Extension* extension, 23 CefRequestContext* loader_context, 24 CefRefPtr<CefExtensionHandler> handler); 25 26 CefExtensionImpl(const CefExtensionImpl&) = delete; 27 CefExtensionImpl& operator=(const CefExtensionImpl&) = delete; 28 29 // CefExtension methods. 30 CefString GetIdentifier() override; 31 CefString GetPath() override; 32 CefRefPtr<CefDictionaryValue> GetManifest() override; 33 bool IsSame(CefRefPtr<CefExtension> that) override; 34 CefRefPtr<CefExtensionHandler> GetHandler() override; 35 CefRefPtr<CefRequestContext> GetLoaderContext() override; 36 bool IsLoaded() override; 37 void Unload() override; 38 39 void OnExtensionLoaded(); 40 void OnExtensionUnloaded(); 41 42 // Use this instead of the GetLoaderContext version during 43 // CefRequestContext destruction. loader_context()44 CefRequestContext* loader_context() const { return loader_context_; } 45 46 private: 47 CefString id_; 48 CefString path_; 49 CefRefPtr<CefDictionaryValue> manifest_; 50 51 CefRequestContext* loader_context_; 52 CefRefPtr<CefExtensionHandler> handler_; 53 54 // Only accessed on the UI thread. 55 bool unloaded_ = false; 56 57 IMPLEMENT_REFCOUNTING(CefExtensionImpl); 58 }; 59 60 #endif // CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_ 61