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/browser/extensions/extensions_browser_client.h"
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "libcef/browser/browser_context.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/browser/extensions/component_extension_resource_manager.h"
|
2017-08-04 00:55:19 +02:00
|
|
|
#include "libcef/browser/extensions/extension_system.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/browser/extensions/extension_system_factory.h"
|
2015-07-24 02:06:56 +02:00
|
|
|
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/browser/extensions/extensions_api_client.h"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "libcef/browser/extensions/extensions_browser_api_provider.h"
|
2017-08-04 00:55:19 +02:00
|
|
|
#include "libcef/browser/request_context_impl.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2016-07-18 23:22:22 +02:00
|
|
|
#include "chrome/browser/browser_process.h"
|
2016-08-04 14:37:53 +02:00
|
|
|
#include "chrome/browser/extensions/chrome_url_request_util.h"
|
2016-07-18 23:22:22 +02:00
|
|
|
#include "chrome/browser/extensions/event_router_forwarder.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "content/public/browser/browser_context.h"
|
|
|
|
#include "content/public/browser/browser_thread.h"
|
|
|
|
#include "content/public/browser/render_frame_host.h"
|
2023-01-03 00:34:43 +01:00
|
|
|
#include "extensions/browser/api/core_extensions_browser_api_provider.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/api/extensions_api_client.h"
|
2020-02-10 18:10:17 +01:00
|
|
|
#include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/api/runtime/runtime_api_delegate.h"
|
|
|
|
#include "extensions/browser/app_sorting.h"
|
|
|
|
#include "extensions/browser/event_router.h"
|
|
|
|
#include "extensions/browser/extension_host_delegate.h"
|
2020-02-10 18:10:17 +01:00
|
|
|
#include "extensions/browser/extensions_browser_interface_binders.h"
|
|
|
|
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
2020-06-09 19:48:00 +02:00
|
|
|
#include "extensions/browser/kiosk/kiosk_delegate.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/url_request_util.h"
|
2020-02-10 18:10:17 +01:00
|
|
|
#include "extensions/common/api/mime_handler.mojom.h"
|
2016-06-21 00:59:23 +02:00
|
|
|
#include "extensions/common/constants.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
using content::BrowserContext;
|
|
|
|
using content::BrowserThread;
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void BindMimeHandlerService(
|
|
|
|
content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<extensions::mime_handler::MimeHandlerService>
|
|
|
|
receiver) {
|
|
|
|
auto* web_contents = content::WebContents::FromRenderFrameHost(frame_host);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!web_contents) {
|
2020-02-10 18:10:17 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-02-10 18:10:17 +01:00
|
|
|
|
|
|
|
auto* guest_view =
|
|
|
|
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!guest_view) {
|
2020-02-10 18:10:17 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-02-10 18:10:17 +01:00
|
|
|
extensions::MimeHandlerServiceImpl::Create(guest_view->GetStreamWeakPtr(),
|
|
|
|
std::move(receiver));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindBeforeUnloadControl(
|
|
|
|
content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<extensions::mime_handler::BeforeUnloadControl>
|
|
|
|
receiver) {
|
|
|
|
auto* web_contents = content::WebContents::FromRenderFrameHost(frame_host);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!web_contents) {
|
2020-02-10 18:10:17 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-02-10 18:10:17 +01:00
|
|
|
|
|
|
|
auto* guest_view =
|
|
|
|
extensions::MimeHandlerViewGuest::FromWebContents(web_contents);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!guest_view) {
|
2020-02-10 18:10:17 +01:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-02-10 18:10:17 +01:00
|
|
|
guest_view->FuseBeforeUnloadControl(std::move(receiver));
|
|
|
|
}
|
|
|
|
|
2020-06-09 19:48:00 +02:00
|
|
|
// Dummy KiosDelegate that always returns false
|
|
|
|
class CefKioskDelegate : public extensions::KioskDelegate {
|
|
|
|
public:
|
|
|
|
CefKioskDelegate() = default;
|
|
|
|
~CefKioskDelegate() override = default;
|
|
|
|
|
|
|
|
// KioskDelegate overrides:
|
|
|
|
bool IsAutoLaunchedKioskApp(const ExtensionId& id) const override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
} // namespace
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
CefExtensionsBrowserClient::CefExtensionsBrowserClient()
|
2022-04-19 20:42:47 +02:00
|
|
|
: api_client_(new CefExtensionsAPIClient) {
|
2018-09-04 11:43:21 +02:00
|
|
|
AddAPIProvider(std::make_unique<CoreExtensionsBrowserAPIProvider>());
|
|
|
|
AddAPIProvider(std::make_unique<CefExtensionsBrowserAPIProvider>());
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefExtensionsBrowserClient::~CefExtensionsBrowserClient() {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
// static
|
|
|
|
CefExtensionsBrowserClient* CefExtensionsBrowserClient::Get() {
|
|
|
|
return static_cast<CefExtensionsBrowserClient*>(
|
|
|
|
ExtensionsBrowserClient::Get());
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsShuttingDown() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::AreExtensionsDisabled(
|
|
|
|
const base::CommandLine& command_line,
|
|
|
|
BrowserContext* context) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
|
2020-01-15 14:36:24 +01:00
|
|
|
return GetOriginalContext(context) != nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::IsSameContext(BrowserContext* first,
|
|
|
|
BrowserContext* second) {
|
2016-08-24 11:28:52 +02:00
|
|
|
// Returns true if |first| and |second| share the same underlying
|
2019-03-22 23:11:51 +01:00
|
|
|
// CefBrowserContext.
|
2019-03-24 01:39:54 +01:00
|
|
|
return GetOriginalContext(first) == GetOriginalContext(second);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::HasOffTheRecordContext(
|
|
|
|
BrowserContext* context) {
|
2017-08-04 00:55:19 +02:00
|
|
|
// CEF doesn't use incognito contexts.
|
2015-07-16 23:40:01 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
|
|
|
|
BrowserContext* context) {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
|
|
|
|
BrowserContext* context) {
|
2020-07-01 02:57:00 +02:00
|
|
|
auto cef_browser_context = CefBrowserContext::FromBrowserContext(context);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (cef_browser_context) {
|
2020-07-01 02:57:00 +02:00
|
|
|
return cef_browser_context->AsBrowserContext();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-07-01 02:57:00 +02:00
|
|
|
return nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2022-09-26 21:30:45 +02:00
|
|
|
content::BrowserContext*
|
|
|
|
CefExtensionsBrowserClient::GetRedirectedContextInIncognito(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
bool force_guest_profile,
|
|
|
|
bool force_system_profile) {
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
content::BrowserContext*
|
|
|
|
CefExtensionsBrowserClient::GetContextForRegularAndIncognito(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
bool force_guest_profile,
|
|
|
|
bool force_system_profile) {
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
content::BrowserContext* CefExtensionsBrowserClient::GetRegularProfile(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
bool force_guest_profile,
|
|
|
|
bool force_system_profile) {
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsGuestSession(BrowserContext* context) const {
|
2015-07-16 23:40:01 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::IsExtensionIncognitoEnabled(
|
|
|
|
const std::string& extension_id,
|
|
|
|
content::BrowserContext* context) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::CanExtensionCrossIncognito(
|
|
|
|
const Extension* extension,
|
|
|
|
content::BrowserContext* context) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
base::FilePath CefExtensionsBrowserClient::GetBundleResourcePath(
|
|
|
|
const network::ResourceRequest& request,
|
|
|
|
const base::FilePath& extension_resources_path,
|
2019-07-16 19:59:21 +02:00
|
|
|
int* resource_id) const {
|
2019-05-01 21:09:59 +02:00
|
|
|
return chrome_url_request_util::GetBundleResourcePath(
|
2019-07-16 19:59:21 +02:00
|
|
|
request, extension_resources_path, resource_id);
|
2018-03-20 21:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsBrowserClient::LoadResourceFromResourceBundle(
|
|
|
|
const network::ResourceRequest& request,
|
2020-02-10 18:10:17 +01:00
|
|
|
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
2018-03-20 21:15:08 +01:00
|
|
|
const base::FilePath& resource_relative_path,
|
2019-07-16 19:59:21 +02:00
|
|
|
const int resource_id,
|
2021-07-23 18:40:13 +02:00
|
|
|
scoped_refptr<net::HttpResponseHeaders> headers,
|
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderClient> client) {
|
2019-05-01 21:09:59 +02:00
|
|
|
chrome_url_request_util::LoadResourceFromResourceBundle(
|
2019-07-16 19:59:21 +02:00
|
|
|
request, std::move(loader), resource_relative_path, resource_id,
|
2021-07-23 18:40:13 +02:00
|
|
|
std::move(headers), std::move(client));
|
2018-03-20 21:15:08 +01:00
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
bool CefExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
2021-01-28 00:13:12 +01:00
|
|
|
const network::ResourceRequest& request,
|
|
|
|
network::mojom::RequestDestination destination,
|
2017-12-07 22:44:24 +01:00
|
|
|
ui::PageTransition page_transition,
|
|
|
|
int child_id,
|
2015-07-16 23:40:01 +02:00
|
|
|
bool is_incognito,
|
|
|
|
const Extension* extension,
|
2017-12-07 22:44:24 +01:00
|
|
|
const ExtensionSet& extensions,
|
|
|
|
const ProcessMap& process_map) {
|
2015-07-16 23:40:01 +02:00
|
|
|
bool allowed = false;
|
|
|
|
if (url_request_util::AllowCrossRendererResourceLoad(
|
2021-01-28 00:13:12 +01:00
|
|
|
request, destination, page_transition, child_id, is_incognito,
|
2017-12-07 22:44:24 +01:00
|
|
|
extension, extensions, process_map, &allowed)) {
|
2015-07-16 23:40:01 +02:00
|
|
|
return allowed;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Couldn't determine if resource is allowed. Block the load.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrefService* CefExtensionsBrowserClient::GetPrefServiceForContext(
|
|
|
|
BrowserContext* context) {
|
2020-07-01 02:57:00 +02:00
|
|
|
return CefBrowserContext::FromBrowserContext(context)
|
|
|
|
->AsProfile()
|
|
|
|
->GetPrefs();
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
|
|
|
|
content::BrowserContext* context,
|
2019-07-16 19:59:21 +02:00
|
|
|
std::vector<EarlyExtensionPrefsObserver*>* observers) const {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
ProcessManagerDelegate* CefExtensionsBrowserClient::GetProcessManagerDelegate()
|
|
|
|
const {
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<ExtensionHostDelegate>
|
2015-07-16 23:40:01 +02:00
|
|
|
CefExtensionsBrowserClient::CreateExtensionHostDelegate() {
|
2017-08-04 00:55:19 +02:00
|
|
|
// CEF does not use the ExtensionHost constructor that calls this method.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2016-04-27 22:38:52 +02:00
|
|
|
return std::unique_ptr<ExtensionHostDelegate>();
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
|
|
|
|
const Extension* extension,
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& url,
|
|
|
|
ExtensionHost** host) {
|
2020-07-01 02:57:00 +02:00
|
|
|
auto cef_browser_context =
|
|
|
|
CefBrowserContext::FromBrowserContext(browser_context);
|
2017-08-04 00:55:19 +02:00
|
|
|
|
|
|
|
// A CEF representation should always exist.
|
|
|
|
CefRefPtr<CefExtension> cef_extension =
|
2020-07-01 02:57:00 +02:00
|
|
|
cef_browser_context->GetExtension(extension->id());
|
2017-08-04 00:55:19 +02:00
|
|
|
DCHECK(cef_extension);
|
|
|
|
if (!cef_extension) {
|
|
|
|
// Cancel the background host creation.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Always use the same request context that the extension was registered with.
|
|
|
|
// GetLoaderContext() will return NULL for internal extensions.
|
|
|
|
CefRefPtr<CefRequestContext> request_context =
|
|
|
|
cef_extension->GetLoaderContext();
|
|
|
|
if (!request_context) {
|
|
|
|
// Cancel the background host creation.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
CefBrowserCreateParams create_params;
|
2021-04-15 01:28:22 +02:00
|
|
|
create_params.url = url.spec();
|
2017-08-04 00:55:19 +02:00
|
|
|
create_params.request_context = request_context;
|
|
|
|
|
|
|
|
CefRefPtr<CefExtensionHandler> handler = cef_extension->GetHandler();
|
|
|
|
if (handler.get() && handler->OnBeforeBackgroundBrowser(
|
2021-04-15 01:28:22 +02:00
|
|
|
cef_extension, create_params.url,
|
|
|
|
create_params.client, create_params.settings)) {
|
2017-08-04 00:55:19 +02:00
|
|
|
// Cancel the background host creation.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This triggers creation of the background host.
|
|
|
|
create_params.extension = extension;
|
2021-04-21 00:52:34 +02:00
|
|
|
create_params.extension_host_type = mojom::ViewType::kExtensionBackgroundPage;
|
2017-08-04 00:55:19 +02:00
|
|
|
|
|
|
|
// Browser creation may fail under certain rare circumstances. Fail the
|
|
|
|
// background host creation in that case.
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser =
|
|
|
|
AlloyBrowserHostImpl::Create(create_params);
|
2017-08-04 00:55:19 +02:00
|
|
|
if (browser) {
|
2020-07-03 22:13:27 +02:00
|
|
|
*host = browser->GetExtensionHost();
|
2017-08-04 00:55:19 +02:00
|
|
|
DCHECK(*host);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
bool CefExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
|
|
|
|
// TODO(jamescook): We might want to tell extensions when app_shell updates.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void CefExtensionsBrowserClient::PermitExternalProtocolHandler() {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2018-07-24 00:32:02 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsInDemoMode() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsScreensaverInDemoMode(
|
|
|
|
const std::string& app_id) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
bool CefExtensionsBrowserClient::IsAppModeForcedForApp(
|
|
|
|
const ExtensionId& extension_id) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsLoggedInAsPublicAccount() {
|
2015-10-09 17:23:12 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
ExtensionSystemProvider*
|
|
|
|
CefExtensionsBrowserClient::GetExtensionSystemFactory() {
|
|
|
|
return CefExtensionSystemFactory::GetInstance();
|
|
|
|
}
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
void CefExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
2020-06-09 19:48:00 +02:00
|
|
|
mojo::BinderMapWithContext<content::RenderFrameHost*>* map,
|
2020-02-10 18:10:17 +01:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
|
|
|
const Extension* extension) const {
|
|
|
|
PopulateExtensionFrameBinders(map, render_frame_host, extension);
|
|
|
|
|
|
|
|
map->Add<extensions::mime_handler::MimeHandlerService>(
|
|
|
|
base::BindRepeating(&BindMimeHandlerService));
|
|
|
|
map->Add<extensions::mime_handler::BeforeUnloadControl>(
|
|
|
|
base::BindRepeating(&BindBeforeUnloadControl));
|
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<RuntimeAPIDelegate>
|
2015-07-16 23:40:01 +02:00
|
|
|
CefExtensionsBrowserClient::CreateRuntimeAPIDelegate(
|
|
|
|
content::BrowserContext* context) const {
|
|
|
|
// TODO(extensions): Implement to support Apps.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2016-08-31 13:25:56 +02:00
|
|
|
return nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const ComponentExtensionResourceManager*
|
|
|
|
CefExtensionsBrowserClient::GetComponentExtensionResourceManager() {
|
2022-04-19 20:42:47 +02:00
|
|
|
if (!resource_manager_) {
|
|
|
|
resource_manager_ =
|
|
|
|
std::make_unique<CefComponentExtensionResourceManager>();
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
return resource_manager_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefExtensionsBrowserClient::BroadcastEventToRenderers(
|
2015-08-14 16:41:08 +02:00
|
|
|
events::HistogramValue histogram_value,
|
2015-07-16 23:40:01 +02:00
|
|
|
const std::string& event_name,
|
2022-05-19 12:28:44 +02:00
|
|
|
base::Value::List args,
|
2019-10-01 15:55:16 +02:00
|
|
|
bool dispatch_to_off_the_record_profiles) {
|
2017-05-17 11:29:28 +02:00
|
|
|
g_browser_process->extension_event_router_forwarder()
|
|
|
|
->BroadcastEventToRenderers(histogram_value, event_name, std::move(args),
|
2019-10-01 15:55:16 +02:00
|
|
|
GURL(), dispatch_to_off_the_record_profiles);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ExtensionCache* CefExtensionsBrowserClient::GetExtensionCache() {
|
|
|
|
// Only used by Chrome via ExtensionService.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefExtensionsBrowserClient::IsMinBrowserVersionSupported(
|
|
|
|
const std::string& min_version) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
ExtensionWebContentsObserver*
|
|
|
|
CefExtensionsBrowserClient::GetExtensionWebContentsObserver(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
return CefExtensionWebContentsObserver::FromWebContents(web_contents);
|
|
|
|
}
|
|
|
|
|
2016-10-21 21:52:29 +02:00
|
|
|
KioskDelegate* CefExtensionsBrowserClient::GetKioskDelegate() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!kiosk_delegate_) {
|
2020-06-09 19:48:00 +02:00
|
|
|
kiosk_delegate_.reset(new CefKioskDelegate());
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2020-06-09 19:48:00 +02:00
|
|
|
return kiosk_delegate_.get();
|
2016-10-21 21:52:29 +02:00
|
|
|
}
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
bool CefExtensionsBrowserClient::IsLockScreenContext(
|
|
|
|
content::BrowserContext* context) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
std::string CefExtensionsBrowserClient::GetApplicationLocale() {
|
|
|
|
return g_browser_process->GetApplicationLocale();
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
} // namespace extensions
|