• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Chromium Embedded Framework Authors.
2 // Portions copyright 2014 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 
6 #include "libcef/common/extensions/extensions_client.h"
7 
8 #include <utility>
9 
10 #include "libcef/common/cef_switches.h"
11 #include "libcef/common/extensions/extensions_api_provider.h"
12 
13 #include "base/logging.h"
14 #include "extensions/common/core_extensions_api_provider.h"
15 #include "extensions/common/extension_urls.h"
16 #include "extensions/common/features/simple_feature.h"
17 #include "extensions/common/permissions/permission_message_provider.h"
18 #include "extensions/common/url_pattern_set.h"
19 
20 namespace extensions {
21 
22 namespace {
23 
24 template <class FeatureClass>
CreateFeature()25 SimpleFeature* CreateFeature() {
26   return new FeatureClass;
27 }
28 
29 }  // namespace
30 
CefExtensionsClient()31 CefExtensionsClient::CefExtensionsClient()
32     : webstore_base_url_(extension_urls::kChromeWebstoreBaseURL),
33       webstore_update_url_(extension_urls::kChromeWebstoreUpdateURL) {
34   AddAPIProvider(std::make_unique<CoreExtensionsAPIProvider>());
35   AddAPIProvider(std::make_unique<CefExtensionsAPIProvider>());
36 }
37 
~CefExtensionsClient()38 CefExtensionsClient::~CefExtensionsClient() {}
39 
Initialize()40 void CefExtensionsClient::Initialize() {}
41 
InitializeWebStoreUrls(base::CommandLine * command_line)42 void CefExtensionsClient::InitializeWebStoreUrls(
43     base::CommandLine* command_line) {}
44 
45 const PermissionMessageProvider&
GetPermissionMessageProvider() const46 CefExtensionsClient::GetPermissionMessageProvider() const {
47   return permission_message_provider_;
48 }
49 
GetProductName()50 const std::string CefExtensionsClient::GetProductName() {
51   return "cef";
52 }
53 
FilterHostPermissions(const URLPatternSet & hosts,URLPatternSet * new_hosts,PermissionIDSet * permissions) const54 void CefExtensionsClient::FilterHostPermissions(
55     const URLPatternSet& hosts,
56     URLPatternSet* new_hosts,
57     PermissionIDSet* permissions) const {
58   NOTIMPLEMENTED();
59 }
60 
SetScriptingAllowlist(const ScriptingAllowlist & allowlist)61 void CefExtensionsClient::SetScriptingAllowlist(
62     const ScriptingAllowlist& allowlist) {
63   scripting_allowlist_ = allowlist;
64 }
65 
66 const ExtensionsClient::ScriptingAllowlist&
GetScriptingAllowlist() const67 CefExtensionsClient::GetScriptingAllowlist() const {
68   // TODO(jamescook): Real allowlist.
69   return scripting_allowlist_;
70 }
71 
GetPermittedChromeSchemeHosts(const Extension * extension,const APIPermissionSet & api_permissions) const72 URLPatternSet CefExtensionsClient::GetPermittedChromeSchemeHosts(
73     const Extension* extension,
74     const APIPermissionSet& api_permissions) const {
75   return URLPatternSet();
76 }
77 
IsScriptableURL(const GURL & url,std::string * error) const78 bool CefExtensionsClient::IsScriptableURL(const GURL& url,
79                                           std::string* error) const {
80   return true;
81 }
82 
GetWebstoreBaseURL() const83 const GURL& CefExtensionsClient::GetWebstoreBaseURL() const {
84   return webstore_base_url_;
85 }
86 
GetWebstoreUpdateURL() const87 const GURL& CefExtensionsClient::GetWebstoreUpdateURL() const {
88   return webstore_update_url_;
89 }
90 
IsBlocklistUpdateURL(const GURL & url) const91 bool CefExtensionsClient::IsBlocklistUpdateURL(const GURL& url) const {
92   // TODO(rockot): Maybe we want to do something else here. For now we accept
93   // any URL as a blocklist URL because we don't really care.
94   return true;
95 }
96 
97 }  // namespace extensions
98