• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   // CefExtension methods.
27   CefString GetIdentifier() override;
28   CefString GetPath() override;
29   CefRefPtr<CefDictionaryValue> GetManifest() override;
30   bool IsSame(CefRefPtr<CefExtension> that) override;
31   CefRefPtr<CefExtensionHandler> GetHandler() override;
32   CefRefPtr<CefRequestContext> GetLoaderContext() override;
33   bool IsLoaded() override;
34   void Unload() override;
35 
36   void OnExtensionLoaded();
37   void OnExtensionUnloaded();
38 
39   // Use this instead of the GetLoaderContext version during
40   // CefRequestContext destruction.
loader_context()41   CefRequestContext* loader_context() const { return loader_context_; }
42 
43  private:
44   CefString id_;
45   CefString path_;
46   CefRefPtr<CefDictionaryValue> manifest_;
47 
48   CefRequestContext* loader_context_;
49   CefRefPtr<CefExtensionHandler> handler_;
50 
51   // Only accessed on the UI thread.
52   bool unloaded_ = false;
53 
54   IMPLEMENT_REFCOUNTING(CefExtensionImpl);
55   DISALLOW_COPY_AND_ASSIGN(CefExtensionImpl);
56 };
57 
58 #endif  // CEF_LIBCEF_BROWSER_EXTENSION_IMPL_H_
59