2015-07-16 23:40:01 +02:00
|
|
|
// Copyright 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/common/extensions/extensions_client.h"
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/common/cef_switches.h"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "libcef/common/extensions/extensions_api_provider.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
#include "base/logging.h"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "extensions/common/core_extensions_api_provider.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/common/extension_urls.h"
|
|
|
|
#include "extensions/common/features/simple_feature.h"
|
|
|
|
#include "extensions/common/permissions/permission_message_provider.h"
|
|
|
|
#include "extensions/common/url_pattern_set.h"
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
template <class FeatureClass>
|
|
|
|
SimpleFeature* CreateFeature() {
|
|
|
|
return new FeatureClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
CefExtensionsClient::CefExtensionsClient()
|
2017-05-17 11:29:28 +02:00
|
|
|
: webstore_base_url_(extension_urls::kChromeWebstoreBaseURL),
|
2022-08-23 03:37:40 +02:00
|
|
|
new_webstore_base_url_(extension_urls::kNewChromeWebstoreBaseURL),
|
2018-09-04 11:43:21 +02:00
|
|
|
webstore_update_url_(extension_urls::kChromeWebstoreUpdateURL) {
|
|
|
|
AddAPIProvider(std::make_unique<CoreExtensionsAPIProvider>());
|
|
|
|
AddAPIProvider(std::make_unique<CefExtensionsAPIProvider>());
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefExtensionsClient::~CefExtensionsClient() {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2018-09-04 11:43:21 +02:00
|
|
|
void CefExtensionsClient::Initialize() {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-10-20 19:45:20 +02:00
|
|
|
void CefExtensionsClient::InitializeWebStoreUrls(
|
|
|
|
base::CommandLine* command_line) {}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
const PermissionMessageProvider&
|
|
|
|
CefExtensionsClient::GetPermissionMessageProvider() const {
|
2016-07-20 20:03:38 +02:00
|
|
|
return permission_message_provider_;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const std::string CefExtensionsClient::GetProductName() {
|
|
|
|
return "cef";
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsClient::FilterHostPermissions(
|
|
|
|
const URLPatternSet& hosts,
|
|
|
|
URLPatternSet* new_hosts,
|
|
|
|
PermissionIDSet* permissions) const {
|
|
|
|
NOTIMPLEMENTED();
|
|
|
|
}
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
void CefExtensionsClient::SetScriptingAllowlist(
|
|
|
|
const ScriptingAllowlist& allowlist) {
|
|
|
|
scripting_allowlist_ = allowlist;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
const ExtensionsClient::ScriptingAllowlist&
|
|
|
|
CefExtensionsClient::GetScriptingAllowlist() const {
|
|
|
|
// TODO(jamescook): Real allowlist.
|
|
|
|
return scripting_allowlist_;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
URLPatternSet CefExtensionsClient::GetPermittedChromeSchemeHosts(
|
|
|
|
const Extension* extension,
|
|
|
|
const APIPermissionSet& api_permissions) const {
|
|
|
|
return URLPatternSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsClient::IsScriptableURL(const GURL& url,
|
|
|
|
std::string* error) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
const GURL& CefExtensionsClient::GetWebstoreBaseURL() const {
|
|
|
|
return webstore_base_url_;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2022-08-23 03:37:40 +02:00
|
|
|
const GURL& CefExtensionsClient::GetNewWebstoreBaseURL() const {
|
|
|
|
return new_webstore_base_url_;
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
const GURL& CefExtensionsClient::GetWebstoreUpdateURL() const {
|
|
|
|
return webstore_update_url_;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
bool CefExtensionsClient::IsBlocklistUpdateURL(const GURL& url) const {
|
2015-07-16 23:40:01 +02:00
|
|
|
// TODO(rockot): Maybe we want to do something else here. For now we accept
|
2022-01-25 21:26:51 +01:00
|
|
|
// any URL as a blocklist URL because we don't really care.
|
2015-07-16 23:40:01 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace extensions
|