2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 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.
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_content_browser_client.h"
|
2012-09-11 00:19:19 +02:00
|
|
|
|
|
|
|
#include <algorithm>
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <utility>
|
2012-09-11 00:19:19 +02:00
|
|
|
|
2019-01-17 10:56:52 +01:00
|
|
|
#include "include/cef_version.h"
|
2020-07-01 02:57:00 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_context.h"
|
2020-09-22 21:54:02 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
2020-06-28 20:29:44 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_browser_main.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "libcef/browser/browser_context.h"
|
2012-12-30 12:17:49 +01:00
|
|
|
#include "libcef/browser/browser_info.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "libcef/browser/browser_info_manager.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/browser/browser_message_filter.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "libcef/browser/browser_platform_delegate.h"
|
2014-04-15 21:02:30 +02:00
|
|
|
#include "libcef/browser/context.h"
|
2019-02-12 19:43:44 +01:00
|
|
|
#include "libcef/browser/devtools/devtools_manager_delegate.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/browser/extensions/extension_system.h"
|
2019-05-01 21:09:59 +02:00
|
|
|
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
2013-03-07 02:20:24 +01:00
|
|
|
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "libcef/browser/net/chrome_scheme_handler.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "libcef/browser/net/throttle_handler.h"
|
|
|
|
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
2019-07-12 22:44:43 +02:00
|
|
|
#include "libcef/browser/net_service/login_delegate.h"
|
2019-04-24 04:50:25 +02:00
|
|
|
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
|
|
|
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
2015-09-25 13:59:30 +02:00
|
|
|
#include "libcef/browser/plugins/plugin_service_filter.h"
|
2015-10-17 02:44:00 +02:00
|
|
|
#include "libcef/browser/prefs/renderer_prefs.h"
|
2013-03-08 01:41:26 +01:00
|
|
|
#include "libcef/browser/speech_recognition_manager_delegate.h"
|
2015-02-11 19:15:04 +01:00
|
|
|
#include "libcef/browser/ssl_info_impl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/browser/thread_util.h"
|
2016-10-27 19:57:12 +02:00
|
|
|
#include "libcef/browser/x509_certificate_impl.h"
|
2020-06-28 20:29:44 +02:00
|
|
|
#include "libcef/common/alloy/alloy_content_client.h"
|
2020-06-28 23:05:36 +02:00
|
|
|
#include "libcef/common/app_manager.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/common/cef_messages.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/common/cef_switches.h"
|
2012-09-27 19:07:31 +02:00
|
|
|
#include "libcef/common/command_line_impl.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/common/extensions/extensions_util.h"
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "libcef/common/net/scheme_registration.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "libcef/common/request_impl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "base/base_switches.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/command_line.h"
|
2013-02-27 18:56:03 +01:00
|
|
|
#include "base/files/file_path.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "base/json/json_reader.h"
|
2012-09-11 00:19:19 +02:00
|
|
|
#include "base/path_service.h"
|
2019-02-01 17:42:40 +01:00
|
|
|
#include "base/stl_util.h"
|
2019-03-24 19:41:42 +01:00
|
|
|
#include "base/threading/thread_restrictions.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "cef/grit/cef_resources.h"
|
2018-07-09 22:10:03 +02:00
|
|
|
#include "chrome/browser/browser_process.h"
|
2020-09-14 22:26:31 +02:00
|
|
|
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
2021-01-28 00:13:12 +01:00
|
|
|
#include "chrome/browser/net/profile_network_context_service.h"
|
|
|
|
#include "chrome/browser/net/profile_network_context_service_factory.h"
|
2019-03-21 01:23:23 +01:00
|
|
|
#include "chrome/browser/net/system_network_context_manager.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/browser/plugins/plugin_info_host_impl.h"
|
2019-05-01 21:09:59 +02:00
|
|
|
#include "chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.h"
|
2019-07-24 23:12:00 +02:00
|
|
|
#include "chrome/browser/plugins/plugin_utils.h"
|
2017-02-14 23:27:19 +01:00
|
|
|
#include "chrome/browser/profiles/profile.h"
|
2019-09-25 15:59:51 +02:00
|
|
|
#include "chrome/browser/profiles/renderer_updater.h"
|
|
|
|
#include "chrome/browser/profiles/renderer_updater_factory.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "chrome/browser/spellchecker/spell_check_host_chrome_impl.h"
|
2020-07-23 21:46:57 +02:00
|
|
|
#include "chrome/common/chrome_content_client.h"
|
2019-03-21 01:23:23 +01:00
|
|
|
#include "chrome/common/chrome_paths.h"
|
2013-02-06 21:41:54 +01:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
2019-09-25 15:59:51 +02:00
|
|
|
#include "chrome/common/google_url_loader_throttle.h"
|
|
|
|
#include "chrome/common/pref_names.h"
|
2019-05-01 21:09:59 +02:00
|
|
|
#include "chrome/common/webui_url_constants.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "chrome/grit/browser_resources.h"
|
2017-12-27 22:38:34 +01:00
|
|
|
#include "chrome/grit/generated_resources.h"
|
2019-07-16 19:59:21 +02:00
|
|
|
#include "chrome/services/printing/printing_service.h"
|
2020-09-14 22:26:31 +02:00
|
|
|
#include "components/content_settings/core/browser/cookie_settings.h"
|
2021-03-04 23:36:57 +01:00
|
|
|
#include "components/embedder_support/switches.h"
|
|
|
|
#include "components/embedder_support/user_agent_utils.h"
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "components/spellcheck/common/spellcheck.mojom.h"
|
2019-02-21 01:42:36 +01:00
|
|
|
#include "components/version_info/version_info.h"
|
2015-09-25 13:59:30 +02:00
|
|
|
#include "content/browser/plugin_service_impl.h"
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "content/browser/renderer_host/render_frame_host_impl.h"
|
2017-04-27 20:59:31 +02:00
|
|
|
#include "content/public/browser/browser_context.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "content/public/browser/browser_ppapi_host.h"
|
2017-04-27 20:59:31 +02:00
|
|
|
#include "content/public/browser/browser_thread.h"
|
2015-05-19 19:55:58 +02:00
|
|
|
#include "content/public/browser/client_certificate_delegate.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "content/public/browser/navigation_handle.h"
|
2019-11-12 17:11:44 +01:00
|
|
|
#include "content/public/browser/overlay_window.h"
|
2015-10-21 20:17:09 +02:00
|
|
|
#include "content/public/browser/page_navigator.h"
|
2012-09-28 00:52:15 +02:00
|
|
|
#include "content/public/browser/quota_permission_context.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "content/public/browser/render_frame_host.h"
|
2012-04-04 20:18:09 +02:00
|
|
|
#include "content/public/browser/render_process_host.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "content/public/browser/render_view_host.h"
|
2015-11-10 21:18:16 +01:00
|
|
|
#include "content/public/browser/render_widget_host.h"
|
2015-04-08 17:43:00 +02:00
|
|
|
#include "content/public/browser/render_widget_host_view.h"
|
2017-04-27 20:59:31 +02:00
|
|
|
#include "content/public/browser/storage_partition.h"
|
2019-05-01 21:09:59 +02:00
|
|
|
#include "content/public/browser/web_ui_url_loader_factory.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/common/content_switches.h"
|
2014-04-30 19:14:40 +02:00
|
|
|
#include "content/public/common/storage_quota_params.h"
|
2019-04-30 22:45:13 +02:00
|
|
|
#include "content/public/common/url_constants.h"
|
2019-01-17 10:56:52 +01:00
|
|
|
#include "content/public/common/user_agent.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/extension_message_filter.h"
|
2018-04-19 17:44:42 +02:00
|
|
|
#include "extensions/browser/extension_protocols.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/extension_registry.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "extensions/browser/extensions_browser_client.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
|
2018-05-21 14:54:08 +02:00
|
|
|
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
|
2020-08-29 00:39:23 +02:00
|
|
|
#include "extensions/browser/info_map.h"
|
|
|
|
#include "extensions/browser/process_map.h"
|
2020-04-22 22:21:08 +02:00
|
|
|
#include "extensions/browser/url_loader_factory_manager.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/common/constants.h"
|
2015-10-14 20:23:08 +02:00
|
|
|
#include "extensions/common/switches.h"
|
2019-07-16 19:59:21 +02:00
|
|
|
#include "mojo/public/cpp/bindings/remote.h"
|
2019-11-12 17:11:44 +01:00
|
|
|
#include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
|
2019-07-12 22:44:43 +02:00
|
|
|
#include "net/base/auth.h"
|
2015-05-19 19:55:58 +02:00
|
|
|
#include "net/ssl/ssl_cert_request_info.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "ppapi/host/ppapi_host.h"
|
2020-08-29 00:39:23 +02:00
|
|
|
#include "sandbox/policy/switches.h"
|
2019-04-16 16:38:48 +02:00
|
|
|
#include "services/network/public/cpp/network_switches.h"
|
2019-07-16 19:59:21 +02:00
|
|
|
#include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "services/service_manager/public/mojom/connector.mojom.h"
|
2017-04-27 20:59:31 +02:00
|
|
|
#include "storage/browser/quota/quota_settings.h"
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
2020-03-30 22:13:42 +02:00
|
|
|
#include "third_party/blink/public/mojom/insecure_input/insecure_input_service.mojom.h"
|
|
|
|
#include "third_party/blink/public/mojom/prerender/prerender.mojom.h"
|
2018-04-19 17:44:42 +02:00
|
|
|
#include "third_party/blink/public/web/web_window_features.h"
|
2018-10-02 14:14:11 +02:00
|
|
|
#include "third_party/widevine/cdm/buildflags.h"
|
2017-12-27 22:38:34 +01:00
|
|
|
#include "ui/base/l10n/l10n_util.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
2012-10-22 22:56:38 +02:00
|
|
|
#include "ui/base/ui_base_switches.h"
|
2013-07-24 22:15:18 +02:00
|
|
|
#include "url/gurl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-10-14 17:56:41 +02:00
|
|
|
#if defined(OS_LINUX)
|
|
|
|
#include "libcef/common/widevine_loader.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MAC)
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "base/debug/leak_annotations.h"
|
2016-12-12 11:05:29 +01:00
|
|
|
#include "chrome/common/chrome_paths.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/crash/content/browser/crash_handler_host_linux.h"
|
2020-04-14 21:31:00 +02:00
|
|
|
#include "components/crash/core/app/breakpad_linux.h"
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "content/public/common/content_descriptors.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
#if defined(OS_MAC)
|
2020-02-10 18:10:17 +01:00
|
|
|
#include "net/ssl/client_cert_store_mac.h"
|
2019-01-18 17:47:03 +01:00
|
|
|
#include "services/video_capture/public/mojom/constants.mojom.h"
|
|
|
|
#endif
|
|
|
|
|
2015-06-12 01:00:09 +02:00
|
|
|
#if defined(OS_WIN)
|
2020-02-10 18:10:17 +01:00
|
|
|
#include "net/ssl/client_cert_store_win.h"
|
2015-06-12 01:00:09 +02:00
|
|
|
#include "sandbox/win/src/sandbox_policy.h"
|
|
|
|
#endif
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
#if defined(USE_NSS_CERTS)
|
|
|
|
#include "net/ssl/client_cert_store_nss.h"
|
|
|
|
#endif
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
#if BUILDFLAG(HAS_SPELLCHECK_PANEL)
|
|
|
|
#include "chrome/browser/spellchecker/spell_check_panel_host_impl.h"
|
|
|
|
#endif
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
namespace {
|
|
|
|
|
2015-04-02 17:21:46 +02:00
|
|
|
class CefQuotaCallbackImpl : public CefRequestCallback {
|
2012-09-28 00:52:15 +02:00
|
|
|
public:
|
2020-03-04 01:29:39 +01:00
|
|
|
using CallbackType = content::QuotaPermissionContext::PermissionCallback;
|
|
|
|
|
|
|
|
explicit CefQuotaCallbackImpl(CallbackType callback)
|
|
|
|
: callback_(std::move(callback)) {}
|
2014-07-02 20:25:22 +02:00
|
|
|
|
2012-09-28 00:52:15 +02:00
|
|
|
~CefQuotaCallbackImpl() {
|
|
|
|
if (!callback_.is_null()) {
|
|
|
|
// The callback is still pending. Cancel it now.
|
|
|
|
if (CEF_CURRENTLY_ON_IOT()) {
|
2020-03-04 01:29:39 +01:00
|
|
|
RunNow(std::move(callback_), false);
|
2012-09-28 00:52:15 +02:00
|
|
|
} else {
|
2020-03-04 01:29:39 +01:00
|
|
|
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefQuotaCallbackImpl::RunNow,
|
|
|
|
std::move(callback_), false));
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void Continue(bool allow) override {
|
2012-09-28 00:52:15 +02:00
|
|
|
if (CEF_CURRENTLY_ON_IOT()) {
|
|
|
|
if (!callback_.is_null()) {
|
2020-03-04 01:29:39 +01:00
|
|
|
RunNow(std::move(callback_), allow);
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-04 01:29:39 +01:00
|
|
|
CEF_POST_TASK(CEF_IOT, base::BindOnce(&CefQuotaCallbackImpl::Continue,
|
|
|
|
this, allow));
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void Cancel() override { Continue(false); }
|
2012-09-28 00:52:15 +02:00
|
|
|
|
2020-03-04 01:29:39 +01:00
|
|
|
CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); }
|
2012-09-28 00:52:15 +02:00
|
|
|
|
|
|
|
private:
|
2020-03-04 01:29:39 +01:00
|
|
|
static void RunNow(CallbackType callback, bool allow) {
|
2012-09-28 00:52:15 +02:00
|
|
|
CEF_REQUIRE_IOT();
|
2020-03-04 01:29:39 +01:00
|
|
|
std::move(callback).Run(
|
2017-05-17 11:29:28 +02:00
|
|
|
allow ? content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW
|
|
|
|
: content::QuotaPermissionContext::
|
|
|
|
QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
|
2020-03-04 01:29:39 +01:00
|
|
|
CallbackType callback_;
|
2012-09-28 00:52:15 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefQuotaCallbackImpl);
|
2014-07-01 00:30:29 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefQuotaCallbackImpl);
|
2012-09-28 00:52:15 +02:00
|
|
|
};
|
|
|
|
|
2015-04-02 17:21:46 +02:00
|
|
|
class CefAllowCertificateErrorCallbackImpl : public CefRequestCallback {
|
2013-04-04 19:50:35 +02:00
|
|
|
public:
|
2020-02-10 18:10:17 +01:00
|
|
|
typedef base::OnceCallback<void(content::CertificateRequestResultType)>
|
2014-07-02 20:25:22 +02:00
|
|
|
CallbackType;
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
explicit CefAllowCertificateErrorCallbackImpl(CallbackType callback)
|
|
|
|
: callback_(std::move(callback)) {}
|
2013-04-04 19:50:35 +02:00
|
|
|
|
2015-04-02 17:21:46 +02:00
|
|
|
~CefAllowCertificateErrorCallbackImpl() {
|
|
|
|
if (!callback_.is_null()) {
|
|
|
|
// The callback is still pending. Cancel it now.
|
|
|
|
if (CEF_CURRENTLY_ON_UIT()) {
|
2020-02-10 18:10:17 +01:00
|
|
|
RunNow(std::move(callback_), false);
|
2015-04-02 17:21:46 +02:00
|
|
|
} else {
|
2020-02-10 18:10:17 +01:00
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_UIT,
|
|
|
|
base::BindOnce(&CefAllowCertificateErrorCallbackImpl::RunNow,
|
|
|
|
std::move(callback_), false));
|
2015-04-02 17:21:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void Continue(bool allow) override {
|
2013-04-04 19:50:35 +02:00
|
|
|
if (CEF_CURRENTLY_ON_UIT()) {
|
|
|
|
if (!callback_.is_null()) {
|
2020-02-10 18:10:17 +01:00
|
|
|
RunNow(std::move(callback_), allow);
|
2013-04-04 19:50:35 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CEF_POST_TASK(CEF_UIT,
|
2017-05-17 11:29:28 +02:00
|
|
|
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
|
|
|
|
this, allow));
|
2013-04-04 19:50:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void Cancel() override { Continue(false); }
|
2015-04-02 17:21:46 +02:00
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
CallbackType Disconnect() WARN_UNUSED_RESULT { return std::move(callback_); }
|
2013-04-04 19:50:35 +02:00
|
|
|
|
|
|
|
private:
|
2020-02-10 18:10:17 +01:00
|
|
|
static void RunNow(CallbackType callback, bool allow) {
|
2015-05-07 16:37:50 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
2020-02-10 18:10:17 +01:00
|
|
|
std::move(callback).Run(
|
|
|
|
allow ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
|
|
|
|
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
2015-04-02 17:21:46 +02:00
|
|
|
}
|
|
|
|
|
2014-07-02 20:25:22 +02:00
|
|
|
CallbackType callback_;
|
2013-04-04 19:50:35 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefAllowCertificateErrorCallbackImpl);
|
2014-07-01 00:30:29 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefAllowCertificateErrorCallbackImpl);
|
2013-04-04 19:50:35 +02:00
|
|
|
};
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
class CefSelectClientCertificateCallbackImpl
|
|
|
|
: public CefSelectClientCertificateCallback {
|
2016-10-27 19:57:12 +02:00
|
|
|
public:
|
|
|
|
explicit CefSelectClientCertificateCallbackImpl(
|
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate)
|
2017-05-17 11:29:28 +02:00
|
|
|
: delegate_(std::move(delegate)) {}
|
2016-10-27 19:57:12 +02:00
|
|
|
|
|
|
|
~CefSelectClientCertificateCallbackImpl() {
|
|
|
|
// If Select has not been called, call it with NULL to continue without any
|
|
|
|
// client certificate.
|
|
|
|
if (delegate_)
|
2020-01-15 14:36:24 +01:00
|
|
|
DoSelect(nullptr);
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Select(CefRefPtr<CefX509Certificate> cert) override {
|
|
|
|
if (delegate_)
|
|
|
|
DoSelect(cert);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void DoSelect(CefRefPtr<CefX509Certificate> cert) {
|
|
|
|
if (CEF_CURRENTLY_ON_UIT()) {
|
|
|
|
RunNow(std::move(delegate_), cert);
|
|
|
|
} else {
|
2020-03-04 01:29:39 +01:00
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_UIT,
|
|
|
|
base::BindOnce(&CefSelectClientCertificateCallbackImpl::RunNow,
|
|
|
|
std::move(delegate_), cert));
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RunNow(
|
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate,
|
|
|
|
CefRefPtr<CefX509Certificate> cert) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
|
|
|
if (cert) {
|
|
|
|
CefX509CertificateImpl* certImpl =
|
|
|
|
static_cast<CefX509CertificateImpl*>(cert.get());
|
2020-03-04 01:29:39 +01:00
|
|
|
certImpl->AcquirePrivateKey(base::BindOnce(
|
|
|
|
&CefSelectClientCertificateCallbackImpl::RunWithPrivateKey,
|
|
|
|
std::move(delegate), cert));
|
2017-07-27 01:19:27 +02:00
|
|
|
return;
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
delegate->ContinueWithCertificate(nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RunWithPrivateKey(
|
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate,
|
|
|
|
CefRefPtr<CefX509Certificate> cert,
|
|
|
|
scoped_refptr<net::SSLPrivateKey> key) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
DCHECK(cert);
|
|
|
|
|
|
|
|
if (key) {
|
|
|
|
CefX509CertificateImpl* certImpl =
|
|
|
|
static_cast<CefX509CertificateImpl*>(cert.get());
|
|
|
|
delegate->ContinueWithCertificate(certImpl->GetInternalCertObject(), key);
|
|
|
|
} else {
|
|
|
|
delegate->ContinueWithCertificate(nullptr, nullptr);
|
|
|
|
}
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefSelectClientCertificateCallbackImpl);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefSelectClientCertificateCallbackImpl);
|
|
|
|
};
|
|
|
|
|
2012-09-28 00:52:15 +02:00
|
|
|
class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
|
|
|
public:
|
2017-05-17 11:29:28 +02:00
|
|
|
CefQuotaPermissionContext() {}
|
2012-09-28 00:52:15 +02:00
|
|
|
|
|
|
|
// The callback will be dispatched on the IO thread.
|
2017-05-17 11:29:28 +02:00
|
|
|
void RequestQuotaPermission(const content::StorageQuotaParams& params,
|
|
|
|
int render_process_id,
|
2020-03-04 01:29:39 +01:00
|
|
|
PermissionCallback callback) override {
|
2018-02-15 01:12:09 +01:00
|
|
|
if (params.storage_type != blink::mojom::StorageType::kPersistent) {
|
2012-09-28 00:52:15 +02:00
|
|
|
// To match Chrome behavior we only support requesting quota with this
|
|
|
|
// interface for Persistent storage type.
|
2020-03-04 01:29:39 +01:00
|
|
|
std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
2012-09-28 00:52:15 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handled = false;
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser =
|
|
|
|
AlloyBrowserHostImpl::GetBrowserForFrameRoute(render_process_id,
|
|
|
|
params.render_frame_id);
|
2012-09-28 00:52:15 +02:00
|
|
|
if (browser.get()) {
|
|
|
|
CefRefPtr<CefClient> client = browser->GetClient();
|
|
|
|
if (client.get()) {
|
|
|
|
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
|
|
|
if (handler.get()) {
|
|
|
|
CefRefPtr<CefQuotaCallbackImpl> callbackImpl(
|
2020-03-04 01:29:39 +01:00
|
|
|
new CefQuotaCallbackImpl(std::move(callback)));
|
2017-05-17 11:29:28 +02:00
|
|
|
handled = handler->OnQuotaRequest(
|
|
|
|
browser.get(), params.origin_url.spec(), params.requested_size,
|
|
|
|
callbackImpl.get());
|
2020-03-04 01:29:39 +01:00
|
|
|
if (!handled) {
|
|
|
|
// May return nullptr if the client has already executed the
|
|
|
|
// callback.
|
|
|
|
callback = callbackImpl->Disconnect();
|
|
|
|
}
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-04 01:29:39 +01:00
|
|
|
if (!handled && !callback.is_null()) {
|
2012-09-28 00:52:15 +02:00
|
|
|
// Disallow the request by default.
|
2020-03-04 01:29:39 +01:00
|
|
|
std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefQuotaPermissionContext() override {}
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefQuotaPermissionContext);
|
2012-09-28 00:52:15 +02:00
|
|
|
};
|
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MAC)
|
2013-11-21 23:43:36 +01:00
|
|
|
breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
|
|
|
|
const std::string& process_type) {
|
2016-12-12 11:05:29 +01:00
|
|
|
base::FilePath dumps_path;
|
2018-05-14 13:24:05 +02:00
|
|
|
base::PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path);
|
2013-11-21 23:43:36 +01:00
|
|
|
{
|
|
|
|
ANNOTATE_SCOPED_MEMORY_LEAK;
|
2016-12-12 11:05:29 +01:00
|
|
|
// Uploads will only occur if a non-empty crash URL is specified in
|
2020-06-28 20:29:44 +02:00
|
|
|
// AlloyMainDelegate::InitCrashReporter.
|
2013-11-21 23:43:36 +01:00
|
|
|
breakpad::CrashHandlerHostLinux* crash_handler =
|
2017-05-17 11:29:28 +02:00
|
|
|
new breakpad::CrashHandlerHostLinux(process_type, dumps_path,
|
|
|
|
true /* upload */);
|
2013-11-21 23:43:36 +01:00
|
|
|
crash_handler->StartUploaderThread();
|
|
|
|
return crash_handler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-07 22:44:33 +02:00
|
|
|
int GetCrashSignalFD(const base::CommandLine& command_line) {
|
2013-11-21 23:43:36 +01:00
|
|
|
if (!breakpad::IsCrashReporterEnabled())
|
|
|
|
return -1;
|
|
|
|
|
2015-10-14 20:23:08 +02:00
|
|
|
// Extensions have the same process type as renderers.
|
|
|
|
if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
|
2020-01-15 14:36:24 +01:00
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
2015-10-14 20:23:08 +02:00
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost("extension");
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
std::string process_type =
|
|
|
|
command_line.GetSwitchValueASCII(switches::kProcessType);
|
|
|
|
|
|
|
|
if (process_type == switches::kRendererProcess) {
|
2020-01-15 14:36:24 +01:00
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
2013-11-21 23:43:36 +01:00
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost(process_type);
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process_type == switches::kPpapiPluginProcess) {
|
2020-01-15 14:36:24 +01:00
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
2013-11-21 23:43:36 +01:00
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost(process_type);
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process_type == switches::kGpuProcess) {
|
2020-01-15 14:36:24 +01:00
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = nullptr;
|
2013-11-21 23:43:36 +01:00
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost(process_type);
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2020-08-29 00:39:23 +02:00
|
|
|
#endif // defined(OS_POSIX) && !defined(OS_MAC)
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
// From chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc.
|
|
|
|
void BindPluginInfoHost(
|
|
|
|
int render_process_id,
|
2019-11-12 17:11:44 +01:00
|
|
|
mojo::PendingAssociatedReceiver<chrome::mojom::PluginInfoHost> receiver) {
|
2019-10-01 15:55:16 +02:00
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
|
content::RenderProcessHost* host =
|
|
|
|
content::RenderProcessHost::FromID(render_process_id);
|
|
|
|
if (!host)
|
|
|
|
return;
|
2019-06-05 16:15:45 +02:00
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
|
2019-11-12 17:11:44 +01:00
|
|
|
mojo::MakeSelfOwnedAssociatedReceiver(
|
2019-10-01 15:55:16 +02:00
|
|
|
std::make_unique<PluginInfoHostImpl>(render_process_id, profile),
|
2019-11-12 17:11:44 +01:00
|
|
|
std::move(receiver));
|
2019-06-05 16:15:45 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
base::FilePath GetRootCachePath() {
|
|
|
|
// The CefContext::ValidateCachePath method enforces the requirement that all
|
|
|
|
// cache_path values be either equal to or a child of root_cache_path.
|
|
|
|
return base::FilePath(
|
|
|
|
CefString(&CefContext::Get()->settings().root_cache_path));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Register BrowserInterfaceBroker's GetInterface() handler callbacks for
|
|
|
|
// chrome-specific document-scoped interfaces.
|
|
|
|
// Stub implementations to silence "Empty binder for interface
|
|
|
|
// blink.mojom.[Name] for the frame/document scope" errors.
|
|
|
|
// Based on chrome/browser/chrome_browser_interface_binders.cc.
|
|
|
|
void PopulateChromeFrameBinders(
|
2020-06-09 19:48:00 +02:00
|
|
|
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
|
2020-03-30 22:13:42 +02:00
|
|
|
map->Add<blink::mojom::InsecureInputService>(base::BindRepeating(
|
|
|
|
[](content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<blink::mojom::InsecureInputService> receiver) {
|
|
|
|
}));
|
|
|
|
|
|
|
|
map->Add<blink::mojom::PrerenderProcessor>(base::BindRepeating(
|
|
|
|
[](content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<blink::mojom::PrerenderProcessor> receiver) {}));
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
} // namespace
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::AlloyContentBrowserClient() {
|
2015-09-25 13:59:30 +02:00
|
|
|
plugin_service_filter_.reset(new CefPluginServiceFilter);
|
|
|
|
content::PluginServiceImpl::GetInstance()->SetFilter(
|
|
|
|
plugin_service_filter_.get());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::~AlloyContentBrowserClient() {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2019-07-16 19:59:21 +02:00
|
|
|
std::unique_ptr<content::BrowserMainParts>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateBrowserMainParts(
|
2012-04-03 03:34:16 +02:00
|
|
|
const content::MainFunctionParams& parameters) {
|
2020-06-28 20:29:44 +02:00
|
|
|
browser_main_parts_ = new AlloyBrowserMainParts(parameters);
|
2019-07-16 19:59:21 +02:00
|
|
|
return base::WrapUnique(browser_main_parts_);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::RenderProcessWillLaunch(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::RenderProcessHost* host) {
|
2014-10-07 22:44:33 +02:00
|
|
|
const int id = host->GetID();
|
2016-11-23 21:54:29 +01:00
|
|
|
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
|
2014-10-07 22:44:33 +02:00
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
host->AddFilter(new CefBrowserMessageFilter(id));
|
2014-10-07 22:44:33 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
2017-05-17 11:29:28 +02:00
|
|
|
host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
|
2015-07-16 23:40:01 +02:00
|
|
|
host->AddFilter(
|
2016-11-23 21:54:29 +01:00
|
|
|
new extensions::ExtensionsGuestViewMessageFilter(id, profile));
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2015-12-03 20:48:26 +01:00
|
|
|
// If the renderer process crashes then the host may already have
|
|
|
|
// CefBrowserInfoManager as an observer. Try to remove it first before adding
|
|
|
|
// to avoid DCHECKs.
|
|
|
|
host->RemoveObserver(CefBrowserInfoManager::GetInstance());
|
2015-11-17 19:20:13 +01:00
|
|
|
host->AddObserver(CefBrowserInfoManager::GetInstance());
|
|
|
|
|
2019-09-25 15:59:51 +02:00
|
|
|
// Forwards dynamic parameters to CefRenderThreadObserver.
|
|
|
|
Profile* original_profile = profile->GetOriginalProfile();
|
|
|
|
RendererUpdaterFactory::GetForProfile(original_profile)
|
|
|
|
->InitializeRenderer(host);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::ShouldUseProcessPerSite(
|
2015-07-16 23:40:01 +02:00
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& effective_url) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!effective_url.SchemeIs(extensions::kExtensionScheme))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
extensions::ExtensionRegistry* registry =
|
|
|
|
extensions::ExtensionRegistry::Get(browser_context);
|
|
|
|
if (!registry)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const extensions::Extension* extension =
|
|
|
|
registry->enabled_extensions().GetByID(effective_url.host());
|
|
|
|
if (!extension)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// TODO(extensions): Extra checks required if type is TYPE_HOSTED_APP.
|
|
|
|
|
|
|
|
// Hosted apps that have script access to their background page must use
|
|
|
|
// process per site, since all instances can make synchronous calls to the
|
|
|
|
// background window. Other extensions should use process per site as well.
|
|
|
|
return true;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2019-03-13 22:27:37 +01:00
|
|
|
// Based on
|
|
|
|
// ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess.
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::BrowserContext* browser_context,
|
2019-03-13 22:27:37 +01:00
|
|
|
const GURL& effective_site_url) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return false;
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
const extensions::Extension* extension =
|
|
|
|
extensions::ExtensionRegistry::Get(browser_context)
|
|
|
|
->enabled_extensions()
|
|
|
|
.GetExtensionOrAppByURL(effective_site_url);
|
2019-03-13 22:27:37 +01:00
|
|
|
// Isolate all extensions.
|
2019-06-05 16:15:45 +02:00
|
|
|
return extension != nullptr;
|
2019-03-13 22:27:37 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::OverrideURLLoaderFactoryParams(
|
2020-04-22 22:21:08 +02:00
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const url::Origin& origin,
|
|
|
|
bool is_for_isolated_world,
|
|
|
|
network::mojom::URLLoaderFactoryParams* factory_params) {
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
extensions::URLLoaderFactoryManager::OverrideURLLoaderFactoryParams(
|
|
|
|
browser_context, origin, is_for_isolated_world, factory_params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::GetAdditionalWebUISchemes(
|
2019-04-30 22:45:13 +02:00
|
|
|
std::vector<std::string>* additional_schemes) {
|
|
|
|
// Any schemes listed here are treated as WebUI schemes but do not get WebUI
|
|
|
|
// bindings. Also, view-source is allowed for these schemes. WebUI schemes
|
|
|
|
// will not be passed to HandleExternalProtocol.
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::GetAdditionalViewSourceSchemes(
|
2019-04-30 22:45:13 +02:00
|
|
|
std::vector<std::string>* additional_schemes) {
|
|
|
|
GetAdditionalWebUISchemes(additional_schemes);
|
|
|
|
|
|
|
|
additional_schemes->push_back(extensions::kExtensionScheme);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
2019-04-30 22:45:13 +02:00
|
|
|
std::vector<std::string>* additional_allowed_schemes) {
|
|
|
|
ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
|
|
|
additional_allowed_schemes);
|
|
|
|
additional_allowed_schemes->push_back(content::kChromeDevToolsScheme);
|
|
|
|
additional_allowed_schemes->push_back(content::kChromeUIScheme);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::IsWebUIAllowedToMakeNetworkRequests(
|
2019-04-30 22:45:13 +02:00
|
|
|
const url::Origin& origin) {
|
|
|
|
return scheme::IsWebUIAllowedToMakeNetworkRequests(origin);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::IsHandledURL(const GURL& url) {
|
2013-06-04 19:41:37 +02:00
|
|
|
if (!url.is_valid())
|
|
|
|
return false;
|
|
|
|
const std::string& scheme = url.scheme();
|
2015-08-26 00:33:31 +02:00
|
|
|
DCHECK_EQ(scheme, base::ToLowerASCII(scheme));
|
2013-06-04 19:41:37 +02:00
|
|
|
|
|
|
|
if (scheme::IsInternalHandledScheme(scheme))
|
|
|
|
return true;
|
|
|
|
|
2020-06-28 23:05:36 +02:00
|
|
|
return CefAppManager::Get()->HasCustomScheme(scheme);
|
2013-06-04 19:41:37 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::SiteInstanceGotProcess(
|
2016-07-20 20:03:38 +02:00
|
|
|
content::SiteInstance* site_instance) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If this isn't an extension renderer there's nothing to do.
|
|
|
|
const extensions::Extension* extension = GetExtension(site_instance);
|
|
|
|
if (!extension)
|
|
|
|
return;
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
auto browser_context =
|
|
|
|
static_cast<AlloyBrowserContext*>(site_instance->GetBrowserContext());
|
2016-07-20 20:03:38 +02:00
|
|
|
|
|
|
|
extensions::ProcessMap::Get(browser_context)
|
2017-05-17 11:29:28 +02:00
|
|
|
->Insert(extension->id(), site_instance->GetProcess()->GetID(),
|
2016-07-20 20:03:38 +02:00
|
|
|
site_instance->GetId());
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::SiteInstanceDeleting(
|
2016-07-20 20:03:38 +02:00
|
|
|
content::SiteInstance* site_instance) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// May be NULL during shutdown.
|
|
|
|
if (!extensions::ExtensionsBrowserClient::Get())
|
|
|
|
return;
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
// May be NULL during shutdown.
|
|
|
|
if (!site_instance->HasProcess())
|
|
|
|
return;
|
|
|
|
|
2016-07-20 20:03:38 +02:00
|
|
|
// If this isn't an extension renderer there's nothing to do.
|
|
|
|
const extensions::Extension* extension = GetExtension(site_instance);
|
|
|
|
if (!extension)
|
|
|
|
return;
|
|
|
|
|
2020-07-01 02:57:00 +02:00
|
|
|
auto browser_context =
|
|
|
|
static_cast<AlloyBrowserContext*>(site_instance->GetBrowserContext());
|
2016-07-20 20:03:38 +02:00
|
|
|
|
|
|
|
extensions::ProcessMap::Get(browser_context)
|
2017-05-17 11:29:28 +02:00
|
|
|
->Remove(extension->id(), site_instance->GetProcess()->GetID(),
|
2016-07-20 20:03:38 +02:00
|
|
|
site_instance->GetId());
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::BindHostReceiverForRenderer(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::RenderProcessHost* render_process_host,
|
|
|
|
mojo::GenericPendingReceiver receiver) {
|
|
|
|
if (auto host_receiver = receiver.As<spellcheck::mojom::SpellCheckHost>()) {
|
|
|
|
SpellCheckHostChromeImpl::Create(render_process_host->GetID(),
|
|
|
|
std::move(host_receiver));
|
2019-07-16 19:59:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-12-07 22:44:24 +01:00
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
#if BUILDFLAG(HAS_SPELLCHECK_PANEL)
|
|
|
|
if (auto panel_host_receiver =
|
|
|
|
receiver.As<spellcheck::mojom::SpellCheckPanelHost>()) {
|
|
|
|
SpellCheckPanelHostImpl::Create(render_process_host->GetID(),
|
|
|
|
std::move(panel_host_receiver));
|
2019-07-16 19:59:21 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-10-01 15:55:16 +02:00
|
|
|
#endif // BUILDFLAG(HAS_SPELLCHECK_PANEL)
|
2017-05-31 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::AppendExtraCommandLineSwitches(
|
2017-05-17 11:29:28 +02:00
|
|
|
base::CommandLine* command_line,
|
|
|
|
int child_process_id) {
|
|
|
|
const base::CommandLine* browser_cmd = base::CommandLine::ForCurrentProcess();
|
2012-09-10 18:13:51 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
// Propagate the following switches to all command lines (along with any
|
|
|
|
// associated values) if present in the browser command line.
|
|
|
|
static const char* const kSwitchNames[] = {
|
2014-01-10 20:49:43 +01:00
|
|
|
switches::kDisablePackLoading,
|
2020-08-29 00:39:23 +02:00
|
|
|
#if defined(OS_MAC)
|
2017-01-27 01:14:56 +01:00
|
|
|
switches::kFrameworkDirPath,
|
2019-07-25 17:47:46 +02:00
|
|
|
switches::kMainBundlePath,
|
2017-01-27 01:14:56 +01:00
|
|
|
#endif
|
2012-10-25 23:19:20 +02:00
|
|
|
switches::kLocalesDirPath,
|
2012-09-10 18:13:51 +02:00
|
|
|
switches::kLogFile,
|
|
|
|
switches::kLogSeverity,
|
2014-10-28 00:12:21 +01:00
|
|
|
switches::kResourcesDirPath,
|
2021-03-04 23:36:57 +01:00
|
|
|
embedder_support::kUserAgent,
|
2021-04-27 18:39:09 +02:00
|
|
|
switches::kUserAgentProductAndVersion,
|
2012-09-10 18:13:51 +02:00
|
|
|
};
|
2015-01-09 18:22:10 +01:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
2019-02-01 17:42:40 +01:00
|
|
|
base::size(kSwitchNames));
|
2012-09-10 18:13:51 +02:00
|
|
|
}
|
|
|
|
|
2013-06-10 20:48:09 +02:00
|
|
|
const std::string& process_type =
|
2012-04-03 03:34:16 +02:00
|
|
|
command_line->GetSwitchValueASCII(switches::kProcessType);
|
|
|
|
if (process_type == switches::kRendererProcess) {
|
2012-09-10 18:13:51 +02:00
|
|
|
// Propagate the following switches to the renderer command line (along with
|
|
|
|
// any associated values) if present in the browser command line.
|
|
|
|
static const char* const kSwitchNames[] = {
|
2018-02-03 01:01:36 +01:00
|
|
|
switches::kDisableExtensions,
|
|
|
|
switches::kDisablePdfExtension,
|
|
|
|
switches::kDisablePlugins,
|
2019-07-17 20:47:27 +02:00
|
|
|
switches::kDisablePrintPreview,
|
2018-02-03 01:01:36 +01:00
|
|
|
switches::kDisableScrollBounce,
|
|
|
|
switches::kDisableSpellChecking,
|
|
|
|
switches::kEnableSpeechInput,
|
|
|
|
switches::kUncaughtExceptionStackSize,
|
2019-04-16 16:38:48 +02:00
|
|
|
network::switches::kUnsafelyTreatInsecureOriginAsSecure,
|
2012-09-10 18:13:51 +02:00
|
|
|
};
|
2015-01-09 18:22:10 +01:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
2019-02-01 17:42:40 +01:00
|
|
|
base::size(kSwitchNames));
|
2015-10-14 20:23:08 +02:00
|
|
|
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
content::RenderProcessHost* process =
|
|
|
|
content::RenderProcessHost::FromID(child_process_id);
|
2020-07-01 02:57:00 +02:00
|
|
|
auto browser_context = process->GetBrowserContext();
|
|
|
|
CefBrowserContext* cef_browser_context =
|
|
|
|
process ? CefBrowserContext::FromBrowserContext(browser_context)
|
|
|
|
: nullptr;
|
|
|
|
if (cef_browser_context) {
|
|
|
|
if (cef_browser_context->IsPrintPreviewSupported()) {
|
2019-07-17 20:47:27 +02:00
|
|
|
command_line->AppendSwitch(switches::kEnablePrintPreview);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Based on ChromeContentBrowserClientExtensionsPart::
|
|
|
|
// AppendExtraRendererCommandLineSwitches
|
2020-07-01 02:57:00 +02:00
|
|
|
if (extensions::ProcessMap::Get(browser_context)
|
|
|
|
->Contains(process->GetID())) {
|
2019-07-17 20:47:27 +02:00
|
|
|
command_line->AppendSwitch(extensions::switches::kExtensionProcess);
|
|
|
|
}
|
2015-10-14 20:23:08 +02:00
|
|
|
}
|
|
|
|
}
|
2018-02-15 01:12:09 +01:00
|
|
|
} else {
|
|
|
|
// Propagate the following switches to non-renderer command line (along with
|
|
|
|
// any associated values) if present in the browser command line.
|
|
|
|
static const char* const kSwitchNames[] = {
|
|
|
|
switches::kLang,
|
|
|
|
};
|
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
2019-02-01 17:42:40 +01:00
|
|
|
base::size(kSwitchNames));
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2012-09-27 19:07:31 +02:00
|
|
|
|
2013-06-10 20:48:09 +02:00
|
|
|
#if defined(OS_LINUX)
|
2020-10-08 21:54:42 +02:00
|
|
|
if (process_type == switches::kZygoteProcess) {
|
2018-10-02 14:14:11 +02:00
|
|
|
#if BUILDFLAG(ENABLE_WIDEVINE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
2020-08-29 00:39:23 +02:00
|
|
|
if (!browser_cmd->HasSwitch(sandbox::policy::switches::kNoSandbox)) {
|
2016-10-14 17:56:41 +02:00
|
|
|
// Pass the Widevine CDM path to the Zygote process. See comments in
|
2018-04-19 17:44:42 +02:00
|
|
|
// CefWidevineLoader::AddContentDecryptionModules.
|
2016-10-14 17:56:41 +02:00
|
|
|
const base::FilePath& cdm_path = CefWidevineLoader::GetInstance()->path();
|
|
|
|
if (!cdm_path.empty())
|
|
|
|
command_line->AppendSwitchPath(switches::kWidevineCdmPath, cdm_path);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-25 22:22:47 +01:00
|
|
|
if (browser_cmd->HasSwitch(switches::kBrowserSubprocessPath)) {
|
|
|
|
// Force use of the sub-process executable path for the zygote process.
|
|
|
|
const base::FilePath& subprocess_path =
|
|
|
|
browser_cmd->GetSwitchValuePath(switches::kBrowserSubprocessPath);
|
|
|
|
if (!subprocess_path.empty())
|
|
|
|
command_line->SetProgram(subprocess_path);
|
|
|
|
}
|
2013-06-10 20:48:09 +02:00
|
|
|
}
|
|
|
|
#endif // defined(OS_LINUX)
|
|
|
|
|
2020-06-28 23:05:36 +02:00
|
|
|
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
|
2012-09-27 19:07:31 +02:00
|
|
|
if (app.get()) {
|
|
|
|
CefRefPtr<CefBrowserProcessHandler> handler =
|
|
|
|
app->GetBrowserProcessHandler();
|
|
|
|
if (handler.get()) {
|
|
|
|
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
|
|
|
new CefCommandLineImpl(command_line, false, false));
|
|
|
|
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
|
2020-01-15 14:36:24 +01:00
|
|
|
commandLinePtr->Detach(nullptr);
|
2012-09-27 19:07:31 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetApplicationLocale() {
|
2018-07-09 22:10:03 +02:00
|
|
|
return g_browser_process->GetApplicationLocale();
|
|
|
|
}
|
|
|
|
|
2019-03-21 01:23:23 +01:00
|
|
|
scoped_refptr<network::SharedURLLoaderFactory>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetSystemSharedURLLoaderFactory() {
|
2019-03-21 01:23:23 +01:00
|
|
|
DCHECK(
|
|
|
|
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ||
|
|
|
|
!content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI));
|
|
|
|
|
|
|
|
if (!SystemNetworkContextManager::GetInstance())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return SystemNetworkContextManager::GetInstance()
|
|
|
|
->GetSharedURLLoaderFactory();
|
|
|
|
}
|
|
|
|
|
|
|
|
network::mojom::NetworkContext*
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetSystemNetworkContext() {
|
2019-03-21 01:23:23 +01:00
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
|
DCHECK(SystemNetworkContextManager::GetInstance());
|
|
|
|
return SystemNetworkContextManager::GetInstance()->GetContext();
|
|
|
|
}
|
|
|
|
|
2019-06-05 16:15:45 +02:00
|
|
|
scoped_refptr<content::QuotaPermissionContext>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateQuotaPermissionContext() {
|
2012-09-28 00:52:15 +02:00
|
|
|
return new CefQuotaPermissionContext();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
content::MediaObserver* AlloyContentBrowserClient::GetMediaObserver() {
|
2013-03-07 02:20:24 +01:00
|
|
|
return CefMediaCaptureDevicesDispatcher::GetInstance();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-03-08 01:41:26 +01:00
|
|
|
content::SpeechRecognitionManagerDelegate*
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateSpeechRecognitionManagerDelegate() {
|
2014-10-07 22:44:33 +02:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
if (command_line->HasSwitch(switches::kEnableSpeechInput))
|
2013-03-08 01:41:26 +01:00
|
|
|
return new CefSpeechRecognitionManagerDelegate();
|
|
|
|
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2013-03-08 01:41:26 +01:00
|
|
|
}
|
|
|
|
|
2018-11-03 02:15:09 +01:00
|
|
|
content::GeneratedCodeCacheSettings
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetGeneratedCodeCacheSettings(
|
2018-11-03 02:15:09 +01:00
|
|
|
content::BrowserContext* context) {
|
|
|
|
// If we pass 0 for size, disk_cache will pick a default size using the
|
|
|
|
// heuristics based on available disk size. These are implemented in
|
|
|
|
// disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc.
|
|
|
|
const base::FilePath& cache_path = context->GetPath();
|
|
|
|
return content::GeneratedCodeCacheSettings(!cache_path.empty() /* enabled */,
|
|
|
|
0 /* size */, cache_path);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::AllowCertificateError(
|
2015-12-09 17:10:16 +01:00
|
|
|
content::WebContents* web_contents,
|
2013-04-04 19:50:35 +02:00
|
|
|
int cert_error,
|
|
|
|
const net::SSLInfo& ssl_info,
|
|
|
|
const GURL& request_url,
|
2019-07-16 19:59:21 +02:00
|
|
|
bool is_main_frame_request,
|
2013-04-04 19:50:35 +02:00
|
|
|
bool strict_enforcement,
|
2020-02-10 18:10:17 +01:00
|
|
|
base::OnceCallback<void(content::CertificateRequestResultType)> callback) {
|
2013-04-04 19:50:35 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
2019-07-16 19:59:21 +02:00
|
|
|
if (!is_main_frame_request) {
|
2013-04-04 19:50:35 +02:00
|
|
|
// A sub-resource has a certificate error. The user doesn't really
|
|
|
|
// have a context for making the right decision, so block the request
|
|
|
|
// hard.
|
2020-02-10 18:10:17 +01:00
|
|
|
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
2013-04-04 19:50:35 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser =
|
|
|
|
AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
2013-04-04 19:50:35 +02:00
|
|
|
if (!browser.get())
|
|
|
|
return;
|
|
|
|
CefRefPtr<CefClient> client = browser->GetClient();
|
|
|
|
if (!client.get())
|
|
|
|
return;
|
|
|
|
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
|
|
|
if (!handler.get())
|
|
|
|
return;
|
|
|
|
|
2015-02-11 19:15:04 +01:00
|
|
|
CefRefPtr<CefSSLInfo> cef_ssl_info = new CefSSLInfoImpl(ssl_info);
|
|
|
|
|
2016-01-27 18:57:48 +01:00
|
|
|
CefRefPtr<CefAllowCertificateErrorCallbackImpl> callbackImpl(
|
2020-02-10 18:10:17 +01:00
|
|
|
new CefAllowCertificateErrorCallbackImpl(std::move(callback)));
|
2013-04-04 19:50:35 +02:00
|
|
|
|
2013-06-04 19:41:37 +02:00
|
|
|
bool proceed = handler->OnCertificateError(
|
2015-02-11 19:15:04 +01:00
|
|
|
browser.get(), static_cast<cef_errorcode_t>(cert_error),
|
|
|
|
request_url.spec(), cef_ssl_info, callbackImpl.get());
|
2017-01-17 18:49:23 +01:00
|
|
|
if (!proceed) {
|
2020-02-10 18:10:17 +01:00
|
|
|
// |callback| may be null if the user executed it despite returning false.
|
|
|
|
callback = callbackImpl->Disconnect();
|
|
|
|
if (!callback.is_null()) {
|
|
|
|
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
|
|
|
}
|
2017-01-17 18:49:23 +01:00
|
|
|
}
|
2013-04-04 19:50:35 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
base::OnceClosure AlloyContentBrowserClient::SelectClientCertificate(
|
2015-05-19 19:55:58 +02:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
net::SSLCertRequestInfo* cert_request_info,
|
2017-07-27 01:19:27 +02:00
|
|
|
net::ClientCertIdentityList client_certs,
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
2016-10-27 19:57:12 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestHandler> handler;
|
2020-09-22 21:54:02 +02:00
|
|
|
CefRefPtr<AlloyBrowserHostImpl> browser =
|
|
|
|
AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
2016-10-27 19:57:12 +02:00
|
|
|
if (browser.get()) {
|
|
|
|
CefRefPtr<CefClient> client = browser->GetClient();
|
|
|
|
if (client.get())
|
|
|
|
handler = client->GetRequestHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!handler.get()) {
|
2017-07-27 01:19:27 +02:00
|
|
|
delegate->ContinueWithCertificate(nullptr, nullptr);
|
2019-09-04 17:13:32 +02:00
|
|
|
return base::OnceClosure();
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
2016-10-27 21:44:31 +02:00
|
|
|
CefRequestHandler::X509CertificateList certs;
|
2017-07-27 01:19:27 +02:00
|
|
|
for (net::ClientCertIdentityList::iterator iter = client_certs.begin();
|
2017-05-31 17:33:30 +02:00
|
|
|
iter != client_certs.end(); iter++) {
|
2017-07-27 01:19:27 +02:00
|
|
|
certs.push_back(new CefX509CertificateImpl(std::move(*iter)));
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefSelectClientCertificateCallbackImpl> callbackImpl(
|
|
|
|
new CefSelectClientCertificateCallbackImpl(std::move(delegate)));
|
|
|
|
|
|
|
|
bool proceed = handler->OnSelectClientCertificate(
|
|
|
|
browser.get(), cert_request_info->is_proxy,
|
|
|
|
cert_request_info->host_and_port.host(),
|
2017-05-17 11:29:28 +02:00
|
|
|
cert_request_info->host_and_port.port(), certs, callbackImpl.get());
|
2016-10-27 19:57:12 +02:00
|
|
|
|
|
|
|
if (!proceed && !certs.empty()) {
|
|
|
|
callbackImpl->Select(certs[0]);
|
2015-05-19 19:55:58 +02:00
|
|
|
}
|
2019-09-04 17:13:32 +02:00
|
|
|
return base::OnceClosure();
|
2015-05-19 19:55:58 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::CanCreateWindow(
|
2017-05-31 17:33:30 +02:00
|
|
|
content::RenderFrameHost* opener,
|
2013-02-08 01:07:41 +01:00
|
|
|
const GURL& opener_url,
|
2013-10-16 02:25:38 +02:00
|
|
|
const GURL& opener_top_level_frame_url,
|
2019-01-17 10:56:52 +01:00
|
|
|
const url::Origin& source_origin,
|
2017-03-03 23:37:23 +01:00
|
|
|
content::mojom::WindowContainerType container_type,
|
2013-08-15 21:38:55 +02:00
|
|
|
const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
2016-08-31 13:25:56 +02:00
|
|
|
const std::string& frame_name,
|
2013-08-15 21:38:55 +02:00
|
|
|
WindowOpenDisposition disposition,
|
2017-03-03 23:37:23 +01:00
|
|
|
const blink::mojom::WindowFeatures& features,
|
2013-08-15 21:38:55 +02:00
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
2013-02-08 01:07:41 +01:00
|
|
|
bool* no_javascript_access) {
|
2017-05-31 17:33:30 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
2013-02-08 01:07:41 +01:00
|
|
|
*no_javascript_access = false;
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
return CefBrowserInfoManager::GetInstance()->CanCreateWindow(
|
2017-05-31 17:33:30 +02:00
|
|
|
opener, target_url, referrer, frame_name, disposition, features,
|
|
|
|
user_gesture, opener_suppressed, no_javascript_access);
|
2013-02-08 01:07:41 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::OverrideWebkitPrefs(
|
2021-03-04 23:36:57 +01:00
|
|
|
content::WebContents* web_contents,
|
2020-10-08 21:54:42 +02:00
|
|
|
blink::web_pref::WebPreferences* prefs) {
|
2021-03-04 23:36:57 +01:00
|
|
|
auto rvh = web_contents->GetRenderViewHost();
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
// Using RVH instead of RFH here because rvh->GetMainFrame() may be nullptr
|
|
|
|
// when this method is called.
|
2015-10-17 02:44:00 +02:00
|
|
|
renderer_prefs::PopulateWebPreferences(rvh, *prefs);
|
2020-04-24 21:41:07 +02:00
|
|
|
|
|
|
|
if (rvh->GetWidget()->GetView()) {
|
|
|
|
rvh->GetWidget()->GetView()->SetBackgroundColor(
|
|
|
|
prefs->base_background_color);
|
|
|
|
}
|
2014-04-15 21:02:30 +02:00
|
|
|
}
|
|
|
|
|
2020-09-15 18:34:22 +02:00
|
|
|
bool AlloyContentBrowserClient::OverrideWebPreferencesAfterNavigation(
|
|
|
|
content::WebContents* web_contents,
|
2020-10-08 21:54:42 +02:00
|
|
|
blink::web_pref::WebPreferences* prefs) {
|
2020-09-15 18:34:22 +02:00
|
|
|
return renderer_prefs::PopulateWebPreferencesAfterNavigation(web_contents,
|
|
|
|
*prefs);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::BrowserURLHandlerCreated(
|
2012-10-08 19:47:37 +02:00
|
|
|
content::BrowserURLHandler* handler) {
|
2016-11-07 20:14:09 +01:00
|
|
|
scheme::BrowserURLHandlerCreated(handler);
|
2012-10-08 19:47:37 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetDefaultDownloadName() {
|
2012-04-03 03:34:16 +02:00
|
|
|
return "download";
|
|
|
|
}
|
2012-09-11 00:19:19 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::DidCreatePpapiPlugin(
|
2015-03-25 22:22:47 +01:00
|
|
|
content::BrowserPpapiHost* browser_host) {
|
|
|
|
browser_host->GetPpapiHost()->AddHostFactoryFilter(
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<ppapi::host::HostFactory>(
|
2017-12-07 22:44:24 +01:00
|
|
|
new ChromeBrowserPepperHostFactory(browser_host)));
|
2015-03-25 22:22:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-21 00:52:34 +02:00
|
|
|
std::unique_ptr<content::DevToolsManagerDelegate>
|
|
|
|
AlloyContentBrowserClient::CreateDevToolsManagerDelegate() {
|
|
|
|
return std::make_unique<CefDevToolsManagerDelegate>();
|
2014-09-27 01:48:19 +02:00
|
|
|
}
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateThrottlesForNavigation(
|
2015-10-09 17:23:12 +02:00
|
|
|
content::NavigationHandle* navigation_handle) {
|
2020-09-25 03:40:47 +02:00
|
|
|
throttle::NavigationThrottleList throttles;
|
|
|
|
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
|
2016-01-06 20:20:54 +01:00
|
|
|
return throttles;
|
2015-10-09 17:23:12 +02:00
|
|
|
}
|
|
|
|
|
2019-10-01 15:55:16 +02:00
|
|
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateURLLoaderThrottles(
|
2019-05-01 21:09:59 +02:00
|
|
|
const network::ResourceRequest& request,
|
2019-10-01 15:55:16 +02:00
|
|
|
content::BrowserContext* browser_context,
|
2019-05-01 21:09:59 +02:00
|
|
|
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
|
|
|
|
content::NavigationUIData* navigation_ui_data,
|
|
|
|
int frame_tree_node_id) {
|
2019-10-01 15:55:16 +02:00
|
|
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>> result;
|
2019-05-01 21:09:59 +02:00
|
|
|
|
2019-07-29 23:27:12 +02:00
|
|
|
// Used to substitute View ID for PDF contents when using the PDF plugin.
|
|
|
|
result.push_back(std::make_unique<PluginResponseInterceptorURLLoaderThrottle>(
|
2021-03-04 23:36:57 +01:00
|
|
|
request.destination, frame_tree_node_id));
|
2019-05-01 21:09:59 +02:00
|
|
|
|
2019-09-25 15:59:51 +02:00
|
|
|
Profile* profile = Profile::FromBrowserContext(browser_context);
|
|
|
|
|
|
|
|
chrome::mojom::DynamicParams dynamic_params = {
|
|
|
|
profile->GetPrefs()->GetBoolean(prefs::kForceGoogleSafeSearch),
|
|
|
|
profile->GetPrefs()->GetInteger(prefs::kForceYouTubeRestrict),
|
2020-03-30 22:13:42 +02:00
|
|
|
profile->GetPrefs()->GetString(prefs::kAllowedDomainsForApps)};
|
|
|
|
result.push_back(
|
|
|
|
std::make_unique<GoogleURLLoaderThrottle>(std::move(dynamic_params)));
|
2019-09-25 15:59:51 +02:00
|
|
|
|
2019-05-01 21:09:59 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
#if defined(OS_LINUX)
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
|
2014-04-04 18:50:38 +02:00
|
|
|
const base::CommandLine& command_line,
|
2013-11-21 23:43:36 +01:00
|
|
|
int child_process_id,
|
2017-09-06 23:40:58 +02:00
|
|
|
content::PosixFileDescriptorInfo* mappings) {
|
2013-11-21 23:43:36 +01:00
|
|
|
int crash_signal_fd = GetCrashSignalFD(command_line);
|
|
|
|
if (crash_signal_fd >= 0) {
|
2020-10-08 21:54:42 +02:00
|
|
|
mappings->Share(kCrashDumpSignal, crash_signal_fd);
|
2013-11-21 23:43:36 +01:00
|
|
|
}
|
|
|
|
}
|
2017-12-07 22:44:24 +01:00
|
|
|
#endif // defined(OS_LINUX)
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::ExposeInterfacesToRenderer(
|
2017-07-27 01:19:27 +02:00
|
|
|
service_manager::BinderRegistry* registry,
|
2017-12-07 22:44:24 +01:00
|
|
|
blink::AssociatedInterfaceRegistry* associated_registry,
|
|
|
|
content::RenderProcessHost* host) {
|
2019-10-01 15:55:16 +02:00
|
|
|
associated_registry->AddInterface(
|
|
|
|
base::BindRepeating(&BindPluginInfoHost, host->GetID()));
|
2017-07-27 01:19:27 +02:00
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
std::unique_ptr<net::ClientCertStore>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateClientCertStore(
|
2020-02-10 18:10:17 +01:00
|
|
|
content::BrowserContext* browser_context) {
|
|
|
|
// Match the logic in ProfileNetworkContextService::CreateClientCertStore.
|
|
|
|
#if defined(USE_NSS_CERTS)
|
|
|
|
// TODO: Add support for client implementation of crypto password dialog.
|
|
|
|
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
|
|
|
|
net::ClientCertStoreNSS::PasswordDelegateFactory()));
|
|
|
|
#elif defined(OS_WIN)
|
|
|
|
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
|
2020-08-29 00:39:23 +02:00
|
|
|
#elif defined(OS_MAC)
|
2020-02-10 18:10:17 +01:00
|
|
|
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreMac());
|
|
|
|
#else
|
|
|
|
#error Unknown platform.
|
|
|
|
#endif
|
2018-03-20 21:15:08 +01:00
|
|
|
}
|
|
|
|
|
2019-07-12 22:44:43 +02:00
|
|
|
std::unique_ptr<content::LoginDelegate>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateLoginDelegate(
|
2019-07-12 22:44:43 +02:00
|
|
|
const net::AuthChallengeInfo& auth_info,
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
const content::GlobalRequestID& request_id,
|
|
|
|
bool is_request_for_main_frame,
|
|
|
|
const GURL& url,
|
|
|
|
scoped_refptr<net::HttpResponseHeaders> response_headers,
|
|
|
|
bool first_auth_attempt,
|
|
|
|
LoginAuthRequiredCallback auth_required_callback) {
|
|
|
|
return std::make_unique<net_service::LoginDelegate>(
|
|
|
|
auth_info, web_contents, request_id, url,
|
|
|
|
std::move(auth_required_callback));
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
|
2018-05-21 14:54:08 +02:00
|
|
|
int frame_tree_node_id,
|
2020-12-02 23:31:49 +01:00
|
|
|
ukm::SourceIdObj ukm_source_id,
|
2018-04-19 17:44:42 +02:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return;
|
|
|
|
|
2018-05-21 14:54:08 +02:00
|
|
|
content::WebContents* web_contents =
|
|
|
|
content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
|
2018-04-19 17:44:42 +02:00
|
|
|
factories->emplace(
|
|
|
|
extensions::kExtensionScheme,
|
|
|
|
extensions::CreateExtensionNavigationURLLoaderFactory(
|
2020-08-29 00:39:23 +02:00
|
|
|
web_contents->GetBrowserContext(), ukm_source_id,
|
2018-05-21 14:54:08 +02:00
|
|
|
!!extensions::WebViewGuest::FromWebContents(web_contents)));
|
2018-04-19 17:44:42 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
2018-05-21 14:54:08 +02:00
|
|
|
int render_process_id,
|
|
|
|
int render_frame_id,
|
2018-04-19 17:44:42 +02:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return;
|
|
|
|
|
2018-05-21 14:54:08 +02:00
|
|
|
auto factory = extensions::CreateExtensionURLLoaderFactory(render_process_id,
|
|
|
|
render_frame_id);
|
2018-04-19 17:44:42 +02:00
|
|
|
if (factory)
|
|
|
|
factories->emplace(extensions::kExtensionScheme, std::move(factory));
|
2019-05-01 21:09:59 +02:00
|
|
|
|
|
|
|
content::RenderFrameHost* frame_host =
|
|
|
|
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
|
|
|
|
content::WebContents* web_contents =
|
|
|
|
content::WebContents::FromRenderFrameHost(frame_host);
|
|
|
|
if (!web_contents)
|
|
|
|
return;
|
|
|
|
|
|
|
|
extensions::CefExtensionWebContentsObserver* web_observer =
|
|
|
|
extensions::CefExtensionWebContentsObserver::FromWebContents(
|
|
|
|
web_contents);
|
|
|
|
|
|
|
|
// There is nothing to do if no CefExtensionWebContentsObserver is attached
|
|
|
|
// to the |web_contents|.
|
|
|
|
if (!web_observer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const extensions::Extension* extension =
|
|
|
|
web_observer->GetExtensionFromFrame(frame_host, false);
|
|
|
|
if (!extension)
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::vector<std::string> allowed_webui_hosts;
|
|
|
|
// Support for chrome:// scheme if appropriate.
|
|
|
|
if ((extension->is_extension() || extension->is_platform_app()) &&
|
|
|
|
extensions::Manifest::IsComponentLocation(extension->location())) {
|
|
|
|
// Components of chrome that are implemented as extensions or platform apps
|
|
|
|
// are allowed to use chrome://resources/ and chrome://theme/ URLs.
|
2020-08-14 21:28:23 +02:00
|
|
|
// See also HasCrossOriginWhitelistEntry.
|
2019-05-01 21:09:59 +02:00
|
|
|
allowed_webui_hosts.emplace_back(content::kChromeUIResourcesHost);
|
|
|
|
allowed_webui_hosts.emplace_back(chrome::kChromeUIThemeHost);
|
|
|
|
}
|
|
|
|
if (!allowed_webui_hosts.empty()) {
|
2020-10-08 21:54:42 +02:00
|
|
|
factories->emplace(content::kChromeUIScheme,
|
|
|
|
content::CreateWebUIURLLoaderFactory(
|
|
|
|
frame_host, content::kChromeUIScheme,
|
|
|
|
std::move(allowed_webui_hosts)));
|
2019-05-01 21:09:59 +02:00
|
|
|
}
|
2018-04-19 17:44:42 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::WillCreateURLLoaderFactory(
|
2018-06-08 18:53:10 +02:00
|
|
|
content::BrowserContext* browser_context,
|
2018-04-19 17:44:42 +02:00
|
|
|
content::RenderFrameHost* frame,
|
2018-12-26 16:12:11 +01:00
|
|
|
int render_process_id,
|
2019-10-01 15:55:16 +02:00
|
|
|
URLLoaderFactoryType type,
|
2018-10-02 14:14:11 +02:00
|
|
|
const url::Origin& request_initiator,
|
2020-02-10 18:10:17 +01:00
|
|
|
base::Optional<int64_t> navigation_id,
|
2020-12-02 23:31:49 +01:00
|
|
|
ukm::SourceIdObj ukm_source_id,
|
2019-09-04 17:13:32 +02:00
|
|
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
2019-10-01 15:55:16 +02:00
|
|
|
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
|
|
|
header_client,
|
2020-02-10 18:10:17 +01:00
|
|
|
bool* bypass_redirect_checks,
|
2020-03-04 01:29:39 +01:00
|
|
|
bool* disable_secure_dns,
|
2020-02-10 18:10:17 +01:00
|
|
|
network::mojom::URLLoaderFactoryOverridePtr* factory_override) {
|
2019-04-24 04:50:25 +02:00
|
|
|
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
2019-10-01 15:55:16 +02:00
|
|
|
browser_context, frame, render_process_id,
|
|
|
|
type == URLLoaderFactoryType::kNavigation,
|
|
|
|
type == URLLoaderFactoryType::kDownload, request_initiator);
|
2019-09-04 17:13:32 +02:00
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
net_service::ProxyURLLoaderFactory::CreateProxy(
|
2019-10-01 15:55:16 +02:00
|
|
|
browser_context, factory_receiver, header_client,
|
2019-04-24 04:50:25 +02:00
|
|
|
std::move(request_handler));
|
|
|
|
return true;
|
2018-04-19 17:44:42 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::OnNetworkServiceCreated(
|
2019-03-21 01:23:23 +01:00
|
|
|
network::mojom::NetworkService* network_service) {
|
|
|
|
DCHECK(g_browser_process);
|
|
|
|
PrefService* local_state = g_browser_process->local_state();
|
|
|
|
DCHECK(local_state);
|
|
|
|
|
|
|
|
// Need to set up global NetworkService state before anything else uses it.
|
2019-05-02 18:16:44 +02:00
|
|
|
DCHECK(SystemNetworkContextManager::GetInstance());
|
2019-03-21 01:23:23 +01:00
|
|
|
SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated(
|
|
|
|
network_service);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::ConfigureNetworkContextParams(
|
2019-03-21 01:23:23 +01:00
|
|
|
content::BrowserContext* context,
|
|
|
|
bool in_memory,
|
2020-06-09 19:48:00 +02:00
|
|
|
const base::FilePath& relative_partition_path,
|
|
|
|
network::mojom::NetworkContextParams* network_context_params,
|
2021-03-04 23:36:57 +01:00
|
|
|
cert_verifier::mojom::CertVerifierCreationParams*
|
|
|
|
cert_verifier_creation_params) {
|
2020-07-20 19:49:16 +02:00
|
|
|
// This method may be called during shutdown when using multi-threaded
|
|
|
|
// message loop mode. In that case exit early to avoid crashes.
|
|
|
|
if (!SystemNetworkContextManager::GetInstance()) {
|
|
|
|
// This must match the value expected in
|
|
|
|
// StoragePartitionImpl::InitNetworkContext.
|
|
|
|
network_context_params->context_name = "magic_shutting_down";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
|
|
|
|
|
|
|
Profile* profile = cef_context->AsProfile();
|
2021-01-28 00:13:12 +01:00
|
|
|
ProfileNetworkContextService* service =
|
|
|
|
ProfileNetworkContextServiceFactory::GetForContext(profile);
|
|
|
|
if (service) {
|
|
|
|
service->ConfigureNetworkContextParams(in_memory, relative_partition_path,
|
|
|
|
network_context_params,
|
|
|
|
cert_verifier_creation_params);
|
|
|
|
} else {
|
|
|
|
// Set default params.
|
|
|
|
network_context_params->user_agent = GetUserAgent();
|
|
|
|
network_context_params->accept_language = GetApplicationLocale();
|
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
network_context_params->cookieable_schemes =
|
|
|
|
cef_context->GetCookieableSchemes();
|
|
|
|
|
2020-06-09 19:48:00 +02:00
|
|
|
// TODO(cef): Remove this and add required NetworkIsolationKeys,
|
|
|
|
// this is currently not the case and this was not required pre M84.
|
|
|
|
network_context_params->require_network_isolation_key = false;
|
2019-03-21 01:23:23 +01:00
|
|
|
}
|
|
|
|
|
2019-03-24 19:41:42 +01:00
|
|
|
// The sandbox may block read/write access from the NetworkService to
|
|
|
|
// directories that are not returned by this method.
|
2019-03-21 01:23:23 +01:00
|
|
|
std::vector<base::FilePath>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetNetworkContextsParentDirectory() {
|
2019-03-24 19:41:42 +01:00
|
|
|
base::FilePath user_data_path;
|
|
|
|
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
|
|
|
|
DCHECK(!user_data_path.empty());
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
const auto& root_cache_path = GetRootCachePath();
|
2019-03-24 19:41:42 +01:00
|
|
|
|
|
|
|
// root_cache_path may sometimes be empty or a child of user_data_path, so
|
|
|
|
// only return the one path in that case.
|
|
|
|
if (root_cache_path.empty() || user_data_path.IsParent(root_cache_path)) {
|
|
|
|
return {user_data_path};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {user_data_path, root_cache_path};
|
2019-03-21 01:23:23 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::HandleExternalProtocol(
|
2018-04-19 17:44:42 +02:00
|
|
|
const GURL& url,
|
2020-09-25 03:40:47 +02:00
|
|
|
content::WebContents::OnceGetter web_contents_getter,
|
2018-04-19 17:44:42 +02:00
|
|
|
int child_id,
|
2021-04-21 00:52:34 +02:00
|
|
|
int frame_tree_node_id,
|
2018-04-19 17:44:42 +02:00
|
|
|
content::NavigationUIData* navigation_data,
|
|
|
|
bool is_main_frame,
|
|
|
|
ui::PageTransition page_transition,
|
2018-11-30 23:21:07 +01:00
|
|
|
bool has_user_gesture,
|
2019-11-12 17:11:44 +01:00
|
|
|
const base::Optional<url::Origin>& initiating_origin,
|
2020-02-10 18:10:17 +01:00
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
2019-07-29 23:27:12 +02:00
|
|
|
// Call the other HandleExternalProtocol variant.
|
2018-04-19 17:44:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
bool AlloyContentBrowserClient::HandleExternalProtocol(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::WebContents::Getter web_contents_getter,
|
2019-04-24 04:50:25 +02:00
|
|
|
int frame_tree_node_id,
|
|
|
|
content::NavigationUIData* navigation_data,
|
2019-09-04 17:13:32 +02:00
|
|
|
const network::ResourceRequest& resource_request,
|
2020-02-10 18:10:17 +01:00
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
|
|
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
|
|
|
|
out_factory->InitWithNewPipeAndPassReceiver();
|
2020-09-25 03:40:47 +02:00
|
|
|
|
2019-04-24 04:50:25 +02:00
|
|
|
// CefBrowserPlatformDelegate::HandleExternalProtocol may be called if
|
|
|
|
// nothing handles the request.
|
2020-09-25 03:40:47 +02:00
|
|
|
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
|
|
|
web_contents_getter, frame_tree_node_id, resource_request,
|
|
|
|
base::Bind(CefBrowserPlatformDelegate::HandleExternalProtocol,
|
|
|
|
resource_request.url));
|
|
|
|
|
|
|
|
net_service::ProxyURLLoaderFactory::CreateProxy(
|
|
|
|
web_contents_getter, std::move(receiver), std::move(request_handler));
|
2019-04-24 04:50:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-10-15 13:11:59 +02:00
|
|
|
std::unique_ptr<content::OverlayWindow>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::CreateWindowForPictureInPicture(
|
2019-10-15 13:11:59 +02:00
|
|
|
content::PictureInPictureWindowController* controller) {
|
|
|
|
// Note: content::OverlayWindow::Create() is defined by platform-specific
|
|
|
|
// implementation in chrome/browser/ui/views. This layering hack, which goes
|
|
|
|
// through //content and ContentBrowserClient, allows us to work around the
|
|
|
|
// dependency constraints that disallow directly calling
|
|
|
|
// chrome/browser/ui/views code either from here or from other code in
|
|
|
|
// chrome/browser.
|
|
|
|
return content::OverlayWindow::Create(controller);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
2020-02-10 18:10:17 +01:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2020-06-09 19:48:00 +02:00
|
|
|
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
|
2020-03-30 22:13:42 +02:00
|
|
|
PopulateChromeFrameBinders(map);
|
|
|
|
|
2020-02-10 18:10:17 +01:00
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
content::WebContents* web_contents =
|
|
|
|
content::WebContents::FromRenderFrameHost(render_frame_host);
|
|
|
|
if (!web_contents)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const GURL& site = render_frame_host->GetSiteInstance()->GetSiteURL();
|
|
|
|
if (!site.SchemeIs(extensions::kExtensionScheme))
|
|
|
|
return;
|
|
|
|
|
|
|
|
content::BrowserContext* browser_context =
|
|
|
|
render_frame_host->GetProcess()->GetBrowserContext();
|
|
|
|
auto* extension = extensions::ExtensionRegistry::Get(browser_context)
|
|
|
|
->enabled_extensions()
|
|
|
|
.GetByID(site.host());
|
|
|
|
if (!extension)
|
|
|
|
return;
|
|
|
|
extensions::ExtensionsBrowserClient::Get()
|
|
|
|
->RegisterBrowserInterfaceBindersForFrame(map, render_frame_host,
|
|
|
|
extension);
|
|
|
|
}
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
base::FilePath
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
|
2020-03-30 22:13:42 +02:00
|
|
|
return GetRootCachePath();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetProduct() {
|
2021-03-04 23:36:57 +01:00
|
|
|
return embedder_support::GetProduct();
|
2019-01-17 10:56:52 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetChromeProduct() {
|
2019-05-02 20:06:48 +02:00
|
|
|
return version_info::GetProductNameAndVersionForUserAgent();
|
2019-01-17 10:56:52 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetUserAgent() {
|
2021-03-04 23:36:57 +01:00
|
|
|
return embedder_support::GetUserAgent();
|
2019-01-17 10:56:52 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
blink::UserAgentMetadata AlloyContentBrowserClient::GetUserAgentMetadata() {
|
2019-02-21 01:42:36 +01:00
|
|
|
blink::UserAgentMetadata metadata;
|
|
|
|
|
2020-06-09 19:48:00 +02:00
|
|
|
metadata.brand_version_list = {blink::UserAgentBrandVersion{
|
|
|
|
version_info::GetProductName(), version_info::GetMajorVersionNumber()}};
|
2019-03-13 22:27:37 +01:00
|
|
|
metadata.full_version = version_info::GetVersionNumber();
|
2019-02-21 01:42:36 +01:00
|
|
|
metadata.platform = version_info::GetOSType();
|
|
|
|
|
|
|
|
// TODO(mkwst): Poke at BuildUserAgentFromProduct to split out these pieces.
|
|
|
|
metadata.architecture = "";
|
|
|
|
metadata.model = "";
|
|
|
|
|
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
|
2019-07-24 23:12:00 +02:00
|
|
|
base::flat_set<std::string>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetPluginMimeTypesWithExternalHandlers(
|
2019-10-01 15:55:16 +02:00
|
|
|
content::BrowserContext* browser_context) {
|
2019-07-24 23:12:00 +02:00
|
|
|
base::flat_set<std::string> mime_types;
|
2019-10-01 15:55:16 +02:00
|
|
|
auto map = PluginUtils::GetMimeTypeToExtensionIdMap(browser_context);
|
2019-07-24 23:12:00 +02:00
|
|
|
for (const auto& pair : map)
|
|
|
|
mime_types.insert(pair.first);
|
|
|
|
return mime_types;
|
|
|
|
}
|
|
|
|
|
2020-09-14 22:26:31 +02:00
|
|
|
bool AlloyContentBrowserClient::ArePersistentMediaDeviceIDsAllowed(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& url,
|
|
|
|
const GURL& site_for_cookies,
|
|
|
|
const base::Optional<url::Origin>& top_frame_origin) {
|
|
|
|
// Persistent MediaDevice IDs are allowed if cookies are allowed.
|
|
|
|
return CookieSettingsFactory::GetForProfile(
|
|
|
|
Profile::FromBrowserContext(browser_context))
|
|
|
|
->IsCookieAccessAllowed(url, site_for_cookies, top_frame_origin);
|
|
|
|
}
|
|
|
|
|
2020-07-23 21:46:57 +02:00
|
|
|
bool AlloyContentBrowserClient::ShouldAllowPluginCreation(
|
|
|
|
const url::Origin& embedder_origin,
|
|
|
|
const content::PepperPluginInfo& plugin_info) {
|
|
|
|
if (plugin_info.name == ChromeContentClient::kPDFInternalPluginName) {
|
|
|
|
// Allow embedding the internal PDF plugin in the built-in PDF extension.
|
|
|
|
if (embedder_origin.scheme() == extensions::kExtensionScheme &&
|
|
|
|
embedder_origin.host() == extension_misc::kPdfExtensionId) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allow embedding the internal PDF plugin in chrome://print.
|
|
|
|
if (embedder_origin ==
|
|
|
|
url::Origin::Create(GURL(chrome::kChromeUIPrintURL))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only allow the PDF plugin in the known, trustworthy origins that are
|
|
|
|
// allowlisted above. See also https://crbug.com/520422 and
|
|
|
|
// https://crbug.com/1027173.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
CefRefPtr<CefRequestContextImpl> AlloyContentBrowserClient::request_context()
|
2017-05-17 11:29:28 +02:00
|
|
|
const {
|
2017-05-04 23:53:27 +02:00
|
|
|
return browser_main_parts_->request_context();
|
2013-02-23 01:43:28 +01:00
|
|
|
}
|
2013-09-03 18:43:31 +02:00
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
CefDevToolsDelegate* AlloyContentBrowserClient::devtools_delegate() const {
|
2013-09-03 18:43:31 +02:00
|
|
|
return browser_main_parts_->devtools_delegate();
|
|
|
|
}
|
2016-07-20 20:03:38 +02:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::background_task_runner() const {
|
2018-03-20 21:15:08 +01:00
|
|
|
return browser_main_parts_->background_task_runner();
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::user_visible_task_runner() const {
|
2018-03-20 21:15:08 +01:00
|
|
|
return browser_main_parts_->user_visible_task_runner();
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::user_blocking_task_runner() const {
|
2018-03-20 21:15:08 +01:00
|
|
|
return browser_main_parts_->user_blocking_task_runner();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
const extensions::Extension* AlloyContentBrowserClient::GetExtension(
|
2016-07-20 20:03:38 +02:00
|
|
|
content::SiteInstance* site_instance) {
|
|
|
|
extensions::ExtensionRegistry* registry =
|
|
|
|
extensions::ExtensionRegistry::Get(site_instance->GetBrowserContext());
|
2017-08-04 00:55:19 +02:00
|
|
|
if (!registry)
|
|
|
|
return nullptr;
|
2016-07-20 20:03:38 +02:00
|
|
|
return registry->enabled_extensions().GetExtensionOrAppByURL(
|
|
|
|
site_instance->GetSiteURL());
|
|
|
|
}
|