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>
|
2022-01-25 20:40:24 +01:00
|
|
|
#include <tuple>
|
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"
|
2022-05-27 11:03:31 +02:00
|
|
|
#include "libcef/browser/alloy/alloy_web_contents_view_delegate.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "libcef/browser/browser_context.h"
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "libcef/browser/browser_frame.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"
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "libcef/browser/browser_manager.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "libcef/browser/browser_platform_delegate.h"
|
2022-08-09 21:43:00 +02:00
|
|
|
#include "libcef/browser/certificate_query.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-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"
|
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"
|
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"
|
2021-08-19 23:07:44 +02:00
|
|
|
#include "libcef/common/frame_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-11-23 21:28:12 +01:00
|
|
|
#include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h"
|
2023-07-21 00:11:34 +02:00
|
|
|
#include "chrome/browser/media/webrtc/media_device_salt_service_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"
|
2021-11-23 21:28:12 +01:00
|
|
|
#include "chrome/browser/pdf/chrome_pdf_stream_delegate.h"
|
|
|
|
#include "chrome/browser/plugins/pdf_iframe_navigation_throttle.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"
|
2022-08-23 03:37:40 +02:00
|
|
|
#include "chrome/browser/predictors/network_hints_handler_impl.h"
|
2022-10-12 23:53:06 +02:00
|
|
|
#include "chrome/browser/printing/print_view_manager.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"
|
2022-04-15 21:55:23 +02:00
|
|
|
#include "chrome/browser/ui/chrome_select_file_policy.h"
|
2023-09-15 21:51:43 +02:00
|
|
|
#include "chrome/browser/ui/pdf/chrome_pdf_document_helper_client.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"
|
2021-11-23 21:28:12 +01:00
|
|
|
#include "chrome/common/pdf_util.h"
|
2019-09-25 15:59:51 +02:00
|
|
|
#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"
|
2023-02-27 19:52:38 +01:00
|
|
|
#include "chrome/services/speech/buildflags/buildflags.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"
|
2023-07-21 00:11:34 +02:00
|
|
|
#include "components/media_device_salt/media_device_salt_service.h"
|
2023-09-15 21:51:43 +02:00
|
|
|
#include "components/pdf/browser/pdf_document_helper.h"
|
2021-11-23 21:28:12 +01:00
|
|
|
#include "components/pdf/browser/pdf_navigation_throttle.h"
|
|
|
|
#include "components/pdf/browser/pdf_url_loader_request_interceptor.h"
|
|
|
|
#include "components/pdf/common/internal_plugin_helpers.h"
|
2023-04-04 20:00:13 +02:00
|
|
|
#include "components/policy/core/common/policy_pref_names.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"
|
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"
|
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"
|
2022-01-25 21:26:51 +01:00
|
|
|
#include "crypto/crypto_buildflags.h"
|
2021-06-04 03:34:56 +02:00
|
|
|
#include "extensions/browser/event_router.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"
|
2021-08-20 01:40:49 +02:00
|
|
|
#include "extensions/browser/extension_web_contents_observer.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "extensions/browser/extensions_browser_client.h"
|
2022-02-21 23:23:40 +01:00
|
|
|
#include "extensions/browser/guest_view/extensions_guest_view.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/process_map.h"
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "extensions/browser/renderer_startup_helper.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"
|
2021-09-20 11:06:23 +02:00
|
|
|
#include "net/ssl/ssl_private_key.h"
|
2021-11-23 21:28:12 +01:00
|
|
|
#include "pdf/pdf_features.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"
|
2021-09-20 11:06:23 +02:00
|
|
|
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
2022-10-20 18:49:29 +02:00
|
|
|
#include "third_party/blink/public/mojom/badging/badging.mojom.h"
|
2020-03-30 22:13:42 +02:00
|
|
|
#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"
|
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
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_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"
|
2022-03-15 20:42:15 +01:00
|
|
|
#elif BUILDFLAG(IS_POSIX)
|
|
|
|
#include "components/crash/core/app/crash_switches.h"
|
|
|
|
#include "components/crash/core/app/crashpad.h"
|
|
|
|
#include "content/public/common/content_descriptors.h"
|
|
|
|
#include "libcef/common/crash_reporting.h"
|
2019-01-18 17:47:03 +01:00
|
|
|
#endif
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2023-02-27 19:52:38 +01:00
|
|
|
#if BUILDFLAG(ENABLE_SPEECH_SERVICE)
|
|
|
|
#include "media/mojo/mojom/renderer_extensions.mojom.h"
|
|
|
|
#endif
|
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"
|
2023-02-27 19:52:38 +01:00
|
|
|
#endif // BUILDFLAG(IS_WIN)
|
2015-06-12 01:00:09 +02:00
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
#if BUILDFLAG(USE_NSS_CERTS)
|
2020-02-10 18:10:17 +01:00
|
|
|
#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 {
|
|
|
|
|
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
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
CefSelectClientCertificateCallbackImpl(
|
|
|
|
const CefSelectClientCertificateCallbackImpl&) = delete;
|
|
|
|
CefSelectClientCertificateCallbackImpl& operator=(
|
|
|
|
const CefSelectClientCertificateCallbackImpl&) = delete;
|
|
|
|
|
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.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2020-01-15 14:36:24 +01:00
|
|
|
DoSelect(nullptr);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Select(CefRefPtr<CefX509Certificate> cert) override {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (delegate_) {
|
2016-10-27 19:57:12 +02:00
|
|
|
DoSelect(cert);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
2022-03-15 20:42:15 +01:00
|
|
|
int GetCrashSignalFD() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!crash_reporting::Enabled()) {
|
2013-11-21 23:43:36 +01:00
|
|
|
return -1;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2013-11-21 23:43:36 +01:00
|
|
|
|
2022-03-15 20:42:15 +01:00
|
|
|
int fd;
|
|
|
|
pid_t pid;
|
|
|
|
return crash_reporter::GetHandlerSocket(&fd, &pid) ? fd : -1;
|
2013-11-21 23:43:36 +01:00
|
|
|
}
|
2022-01-24 18:58:02 +01:00
|
|
|
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_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);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!host) {
|
2019-10-01 15:55:16 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2022-10-20 18:49:29 +02:00
|
|
|
void BindBadgeService(
|
|
|
|
content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {}
|
|
|
|
|
|
|
|
void BindBadgeServiceForServiceWorker(
|
|
|
|
const content::ServiceWorkerVersionBaseInfo& info,
|
|
|
|
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {}
|
|
|
|
|
2023-02-27 19:52:38 +01:00
|
|
|
#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_SPEECH_SERVICE)
|
2022-04-21 20:58:48 +02:00
|
|
|
void BindMediaFoundationRendererNotifierHandler(
|
|
|
|
content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<media::mojom::MediaFoundationRendererNotifier>
|
|
|
|
receiver) {}
|
2023-02-27 19:52:38 +01:00
|
|
|
#endif
|
2022-04-21 20:58:48 +02:00
|
|
|
|
2022-08-23 03:37:40 +02:00
|
|
|
void BindNetworkHintsHandler(
|
|
|
|
content::RenderFrameHost* frame_host,
|
|
|
|
mojo::PendingReceiver<network_hints::mojom::NetworkHintsHandler> receiver) {
|
|
|
|
predictors::NetworkHintsHandlerImpl::Create(frame_host, std::move(receiver));
|
|
|
|
}
|
|
|
|
|
2023-06-06 16:41:53 +02:00
|
|
|
base::FilePath GetUserDataPath() {
|
|
|
|
base::FilePath user_data_path;
|
|
|
|
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_path);
|
|
|
|
DCHECK(!user_data_path.empty());
|
|
|
|
return user_data_path;
|
2020-03-30 22:13:42 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
const extensions::Extension* GetEnabledExtensionFromSiteURL(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
const GURL& site_url) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!site_url.SchemeIs(extensions::kExtensionScheme)) {
|
2021-11-23 21:28:12 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
|
|
|
|
auto registry = extensions::ExtensionRegistry::Get(context);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!registry) {
|
2021-11-23 21:28:12 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
|
|
|
|
return registry->enabled_extensions().GetByID(site_url.host());
|
|
|
|
}
|
|
|
|
|
2023-06-26 12:13:38 +02:00
|
|
|
std::unique_ptr<blink::URLLoaderThrottle> CreateGoogleURLLoaderThrottle(
|
|
|
|
Profile* profile) {
|
|
|
|
chrome::mojom::DynamicParamsPtr dynamic_params =
|
|
|
|
chrome::mojom::DynamicParams::New(
|
|
|
|
#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
|
|
|
|
/*bound_session_params=*/nullptr,
|
|
|
|
#endif
|
|
|
|
profile->GetPrefs()->GetBoolean(
|
|
|
|
policy::policy_prefs::kForceGoogleSafeSearch),
|
|
|
|
profile->GetPrefs()->GetInteger(
|
|
|
|
policy::policy_prefs::kForceYouTubeRestrict),
|
|
|
|
profile->GetPrefs()->GetString(prefs::kAllowedDomainsForApps));
|
|
|
|
return std::make_unique<GoogleURLLoaderThrottle>(
|
|
|
|
#if BUILDFLAG(ENABLE_BOUND_SESSION_CREDENTIALS)
|
|
|
|
/*bound_session_request_throttled_listener=*/nullptr,
|
|
|
|
#endif
|
|
|
|
std::move(dynamic_params));
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
} // namespace
|
|
|
|
|
2021-11-10 22:57:31 +01:00
|
|
|
AlloyContentBrowserClient::AlloyContentBrowserClient() = default;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2021-11-10 22:57:31 +01:00
|
|
|
AlloyContentBrowserClient::~AlloyContentBrowserClient() = default;
|
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(
|
2022-05-19 12:28:44 +02:00
|
|
|
bool /* is_integration_test */) {
|
|
|
|
auto browser_main_parts = std::make_unique<AlloyBrowserMainParts>();
|
|
|
|
browser_main_parts_ = browser_main_parts.get();
|
|
|
|
return 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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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,
|
2021-11-23 21:28:12 +01:00
|
|
|
const GURL& site_url) {
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
if (auto profile = Profile::FromBrowserContext(browser_context)) {
|
|
|
|
return extensions::ChromeContentBrowserClientExtensionsPart::
|
|
|
|
ShouldUseProcessPerSite(profile, site_url);
|
|
|
|
}
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
return content::ContentBrowserClient::ShouldUseProcessPerSite(browser_context,
|
|
|
|
site_url);
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
bool AlloyContentBrowserClient::ShouldUseSpareRenderProcessHost(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& site_url) {
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
if (auto profile = Profile::FromBrowserContext(browser_context)) {
|
|
|
|
return extensions::ChromeContentBrowserClientExtensionsPart::
|
|
|
|
ShouldUseSpareRenderProcessHost(profile, site_url);
|
|
|
|
}
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
return content::ContentBrowserClient::ShouldUseSpareRenderProcessHost(
|
|
|
|
browser_context, site_url);
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
bool AlloyContentBrowserClient::DoesSiteRequireDedicatedProcess(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& effective_site_url) {
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
return extensions::ChromeContentBrowserClientExtensionsPart::
|
|
|
|
DoesSiteRequireDedicatedProcess(browser_context, effective_site_url);
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
return content::ContentBrowserClient::DoesSiteRequireDedicatedProcess(
|
|
|
|
browser_context, effective_site_url);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
bool AlloyContentBrowserClient::ShouldTreatURLSchemeAsFirstPartyWhenTopLevel(
|
|
|
|
base::StringPiece scheme,
|
|
|
|
bool is_embedded_origin_secure) {
|
|
|
|
// This is needed to bypass the normal SameSite rules for any chrome:// page
|
|
|
|
// embedding a secure origin, regardless of the registrable domains of any
|
|
|
|
// intervening frames. For example, this is needed for browser UI to interact
|
|
|
|
// with SameSite cookies on accounts.google.com, which are used for logging
|
|
|
|
// into Cloud Print from chrome://print, for displaying a list of available
|
|
|
|
// accounts on the NTP (chrome://new-tab-page), etc.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (is_embedded_origin_secure && scheme == content::kChromeUIScheme) {
|
2021-11-23 21:28:12 +01:00
|
|
|
return true;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
2021-11-23 21:28:12 +01:00
|
|
|
return scheme == extensions::kExtensionScheme;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AlloyContentBrowserClient::
|
|
|
|
ShouldIgnoreSameSiteCookieRestrictionsWhenTopLevel(
|
|
|
|
base::StringPiece scheme,
|
|
|
|
bool is_embedded_origin_secure) {
|
|
|
|
return is_embedded_origin_secure && scheme == content::kChromeUIScheme;
|
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);
|
|
|
|
}
|
|
|
|
|
2022-04-15 21:55:23 +02:00
|
|
|
std::unique_ptr<ui::SelectFilePolicy>
|
|
|
|
AlloyContentBrowserClient::CreateSelectFilePolicy(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
return std::make_unique<ChromeSelectFilePolicy>(web_contents);
|
|
|
|
}
|
|
|
|
|
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);
|
2022-02-16 22:24:41 +01:00
|
|
|
additional_allowed_schemes->push_back(content::kChromeUIUntrustedScheme);
|
2019-04-30 22:45:13 +02:00
|
|
|
}
|
|
|
|
|
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) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!url.is_valid()) {
|
2013-06-04 19:41:37 +02:00
|
|
|
return false;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2013-06-04 19:41:37 +02:00
|
|
|
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
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (scheme::IsInternalHandledScheme(scheme)) {
|
2013-06-04 19:41:37 +02:00
|
|
|
return true;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2013-06-04 19:41:37 +02:00
|
|
|
|
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) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extensions::ExtensionsEnabled()) {
|
2016-07-20 20:03:38 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-07-20 20:03:38 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
CHECK(site_instance->HasProcess());
|
|
|
|
|
|
|
|
auto context = site_instance->GetBrowserContext();
|
|
|
|
|
|
|
|
// Only add the process to the map if the SiteInstance's site URL is already
|
|
|
|
// a chrome-extension:// URL. This includes hosted apps, except in rare cases
|
|
|
|
// that a URL in the hosted app's extent is not treated as a hosted app (e.g.,
|
|
|
|
// for isolated origins or cross-site iframes). For that case, don't look up
|
|
|
|
// the hosted app's Extension from the site URL using GetExtensionOrAppByURL,
|
|
|
|
// since it isn't treated as a hosted app.
|
|
|
|
const auto extension =
|
|
|
|
GetEnabledExtensionFromSiteURL(context, site_instance->GetSiteURL());
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extension) {
|
2016-07-20 20:03:38 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-07-20 20:03:38 +02:00
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
extensions::ProcessMap::Get(context)->Insert(
|
2023-05-30 10:55:32 +02:00
|
|
|
extension->id(), site_instance->GetProcess()->GetID());
|
2016-07-20 20:03:38 +02:00
|
|
|
}
|
|
|
|
|
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,
|
2022-01-24 18:58:02 +01:00
|
|
|
#if BUILDFLAG(IS_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,
|
2023-08-07 18:58:24 +02:00
|
|
|
switches::kLogItems,
|
2012-09-10 18:13:51 +02:00
|
|
|
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
|
|
|
};
|
2023-07-21 00:11:34 +02:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, 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,
|
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
|
|
|
};
|
2023-07-21 00:11:34 +02:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, 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,
|
|
|
|
};
|
2023-07-21 00:11:34 +02:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2012-09-27 19:07:31 +02:00
|
|
|
|
2021-08-09 23:18:43 +02:00
|
|
|
// Necessary to populate DIR_USER_DATA in sub-processes.
|
|
|
|
// See resource_util.cc GetUserDataPath.
|
|
|
|
base::FilePath user_data_dir;
|
|
|
|
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
|
|
|
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
|
|
|
}
|
|
|
|
|
2022-03-15 20:42:15 +01:00
|
|
|
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
2020-10-08 21:54:42 +02:00
|
|
|
if (process_type == switches::kZygoteProcess) {
|
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);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!subprocess_path.empty()) {
|
2015-03-25 22:22:47 +01:00
|
|
|
command_line->SetProgram(subprocess_path);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2015-03-25 22:22:47 +01:00
|
|
|
}
|
2021-08-24 18:17:15 +02:00
|
|
|
|
|
|
|
// Propagate the following switches to the zygote command line (along with
|
|
|
|
// any associated values) if present in the browser command line.
|
|
|
|
static const char* const kSwitchNames[] = {
|
|
|
|
switches::kLogFile,
|
|
|
|
};
|
2023-07-21 00:11:34 +02:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames);
|
2013-06-10 20:48:09 +02:00
|
|
|
}
|
2022-03-15 20:42:15 +01:00
|
|
|
|
|
|
|
if (crash_reporting::Enabled()) {
|
|
|
|
int fd;
|
|
|
|
pid_t pid;
|
|
|
|
if (crash_reporter::GetHandlerSocket(&fd, &pid)) {
|
|
|
|
command_line->AppendSwitchASCII(
|
|
|
|
crash_reporter::switches::kCrashpadHandlerPid,
|
|
|
|
base::NumberToString(pid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
2013-06-10 20:48:09 +02:00
|
|
|
|
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());
|
2022-01-25 20:40:24 +01:00
|
|
|
std::ignore = 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));
|
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!SystemNetworkContextManager::GetInstance()) {
|
2019-03-21 01:23:23 +01:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2019-03-21 01:23:23 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
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();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (command_line->HasSwitch(switches::kEnableSpeechInput)) {
|
2013-03-08 01:41:26 +01:00
|
|
|
return new CefSpeechRecognitionManagerDelegate();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2013-03-08 01:41:26 +01:00
|
|
|
|
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) {
|
2022-08-09 21:43:00 +02:00
|
|
|
auto returned_callback = certificate_query::AllowCertificateError(
|
|
|
|
web_contents, cert_error, ssl_info, request_url, is_main_frame_request,
|
|
|
|
strict_enforcement, std::move(callback), /*default_disallow=*/true);
|
|
|
|
// Callback should not be returned.
|
|
|
|
DCHECK(returned_callback.is_null());
|
2013-04-04 19:50:35 +02:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
base::OnceClosure AlloyContentBrowserClient::SelectClientCertificate(
|
2023-08-09 23:17:17 +02:00
|
|
|
content::BrowserContext* browser_context,
|
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();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (client.get()) {
|
2016-10-27 19:57:12 +02:00
|
|
|
handler = client->GetRequestHandler();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-10-27 19:57:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2021-07-23 18:40:13 +02:00
|
|
|
SkColor base_background_color;
|
|
|
|
renderer_prefs::PopulateWebPreferences(rvh, *prefs, base_background_color);
|
|
|
|
|
|
|
|
web_contents->SetPageBaseBackgroundColor(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
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
void AlloyContentBrowserClient::
|
|
|
|
RegisterAssociatedInterfaceBindersForRenderFrameHost(
|
|
|
|
content::RenderFrameHost& render_frame_host,
|
|
|
|
blink::AssociatedInterfaceRegistry& associated_registry) {
|
2022-08-23 03:37:40 +02:00
|
|
|
associated_registry.AddInterface<extensions::mojom::LocalFrameHost>(
|
|
|
|
base::BindRepeating(
|
|
|
|
[](content::RenderFrameHost* render_frame_host,
|
|
|
|
mojo::PendingAssociatedReceiver<extensions::mojom::LocalFrameHost>
|
|
|
|
receiver) {
|
|
|
|
extensions::ExtensionWebContentsObserver::BindLocalFrameHost(
|
|
|
|
std::move(receiver), render_frame_host);
|
|
|
|
},
|
|
|
|
&render_frame_host));
|
|
|
|
|
|
|
|
associated_registry.AddInterface<printing::mojom::PrintManagerHost>(
|
|
|
|
base::BindRepeating(
|
|
|
|
[](content::RenderFrameHost* render_frame_host,
|
|
|
|
mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost>
|
|
|
|
receiver) {
|
2022-10-12 23:53:06 +02:00
|
|
|
printing::PrintViewManager::BindPrintManagerHost(
|
2022-08-23 03:37:40 +02:00
|
|
|
std::move(receiver), render_frame_host);
|
|
|
|
},
|
|
|
|
&render_frame_host));
|
|
|
|
|
|
|
|
associated_registry.AddInterface<pdf::mojom::PdfService>(base::BindRepeating(
|
2022-01-25 21:26:51 +01:00
|
|
|
[](content::RenderFrameHost* render_frame_host,
|
|
|
|
mojo::PendingAssociatedReceiver<pdf::mojom::PdfService> receiver) {
|
2023-09-15 21:51:43 +02:00
|
|
|
pdf::PDFDocumentHelper::BindPdfService(
|
|
|
|
std::move(receiver), render_frame_host,
|
|
|
|
std::make_unique<ChromePDFDocumentHelperClient>());
|
2022-01-25 21:26:51 +01:00
|
|
|
},
|
|
|
|
&render_frame_host));
|
2021-08-20 01:40:49 +02: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;
|
2021-11-23 21:28:12 +01:00
|
|
|
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
auto pdf_iframe_throttle =
|
|
|
|
PDFIFrameNavigationThrottle::MaybeCreateThrottleFor(navigation_handle);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (pdf_iframe_throttle) {
|
2021-11-23 21:28:12 +01:00
|
|
|
throttles.push_back(std::move(pdf_iframe_throttle));
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
|
|
|
|
auto pdf_throttle = pdf::PdfNavigationThrottle::MaybeCreateThrottleFor(
|
|
|
|
navigation_handle, std::make_unique<ChromePdfStreamDelegate>());
|
2023-01-02 23:59:03 +01:00
|
|
|
if (pdf_throttle) {
|
2021-11-23 21:28:12 +01:00
|
|
|
throttles.push_back(std::move(pdf_throttle));
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
}
|
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
|
2021-11-23 21:28:12 +01:00
|
|
|
|
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);
|
|
|
|
|
2023-06-26 12:13:38 +02:00
|
|
|
if (auto google_throttle = CreateGoogleURLLoaderThrottle(profile)) {
|
|
|
|
result.push_back(std::move(google_throttle));
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
|
|
|
AlloyContentBrowserClient::CreateURLLoaderThrottlesForKeepAlive(
|
|
|
|
const network::ResourceRequest& request,
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
|
|
|
|
int frame_tree_node_id) {
|
|
|
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>> result;
|
|
|
|
|
|
|
|
Profile* profile = Profile::FromBrowserContext(browser_context);
|
|
|
|
|
|
|
|
if (auto google_throttle = CreateGoogleURLLoaderThrottle(profile)) {
|
|
|
|
result.push_back(std::move(google_throttle));
|
|
|
|
}
|
2019-09-25 15:59:51 +02:00
|
|
|
|
2019-05-01 21:09:59 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
|
|
|
AlloyContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
|
|
|
|
content::NavigationUIData* navigation_ui_data,
|
2023-06-26 12:13:38 +02:00
|
|
|
int frame_tree_node_id,
|
|
|
|
int64_t navigation_id,
|
|
|
|
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner) {
|
2021-11-23 21:28:12 +01:00
|
|
|
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
|
|
|
|
interceptors;
|
|
|
|
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
auto pdf_interceptor =
|
|
|
|
pdf::PdfURLLoaderRequestInterceptor::MaybeCreateInterceptor(
|
|
|
|
frame_tree_node_id, std::make_unique<ChromePdfStreamDelegate>());
|
2023-01-02 23:59:03 +01:00
|
|
|
if (pdf_interceptor) {
|
2021-11-23 21:28:12 +01:00
|
|
|
interceptors.push_back(std::move(pdf_interceptor));
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-11-23 21:28:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return interceptors;
|
|
|
|
}
|
|
|
|
|
2022-03-15 20:42:15 +01:00
|
|
|
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
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) {
|
2022-03-15 20:42:15 +01:00
|
|
|
int crash_signal_fd = GetCrashSignalFD();
|
2013-11-21 23:43:36 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2022-03-15 20:42:15 +01:00
|
|
|
#endif // BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_MAC)
|
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) {
|
2022-08-23 03:37:40 +02:00
|
|
|
associated_registry->AddInterface<chrome::mojom::PluginInfoHost>(
|
2019-10-01 15:55:16 +02:00
|
|
|
base::BindRepeating(&BindPluginInfoHost, host->GetID()));
|
2021-05-14 18:58:55 +02:00
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
2022-08-23 03:37:40 +02:00
|
|
|
associated_registry->AddInterface<extensions::mojom::EventRouter>(
|
|
|
|
base::BindRepeating(&extensions::EventRouter::BindForRenderer,
|
|
|
|
host->GetID()));
|
|
|
|
associated_registry->AddInterface<guest_view::mojom::GuestViewHost>(
|
|
|
|
base::BindRepeating(
|
|
|
|
&extensions::ExtensionsGuestView::CreateForComponents,
|
|
|
|
host->GetID()));
|
|
|
|
associated_registry->AddInterface<extensions::mojom::GuestView>(
|
|
|
|
base::BindRepeating(
|
|
|
|
&extensions::ExtensionsGuestView::CreateForExtensions,
|
|
|
|
host->GetID()));
|
2023-01-30 18:43:54 +01:00
|
|
|
associated_registry->AddInterface<extensions::mojom::RendererHost>(
|
|
|
|
base::BindRepeating(&extensions::RendererStartupHelper::BindForRenderer,
|
|
|
|
host->GetID()));
|
2021-06-04 03:34:56 +02:00
|
|
|
}
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
CefBrowserManager::ExposeInterfacesToRenderer(registry, associated_registry,
|
|
|
|
host);
|
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.
|
2022-01-25 21:26:51 +01:00
|
|
|
#if BUILDFLAG(USE_NSS_CERTS)
|
2020-02-10 18:10:17 +01:00
|
|
|
// TODO: Add support for client implementation of crypto password dialog.
|
|
|
|
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreNSS(
|
|
|
|
net::ClientCertStoreNSS::PasswordDelegateFactory()));
|
2022-01-24 18:58:02 +01:00
|
|
|
#elif BUILDFLAG(IS_WIN)
|
2020-02-10 18:10:17 +01:00
|
|
|
return std::unique_ptr<net::ClientCertStore>(new net::ClientCertStoreWin());
|
2022-01-24 18:58:02 +01:00
|
|
|
#elif BUILDFLAG(IS_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) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extensions::ExtensionsEnabled()) {
|
2018-04-19 17:44:42 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2018-04-19 17:44:42 +02:00
|
|
|
|
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,
|
2022-01-25 21:26:51 +01:00
|
|
|
const absl::optional<url::Origin>& request_initiator_origin,
|
2018-04-19 17:44:42 +02:00
|
|
|
NonNetworkURLLoaderFactoryMap* factories) {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extensions::ExtensionsEnabled()) {
|
2018-04-19 17:44:42 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2018-04-19 17:44:42 +02:00
|
|
|
|
2018-05-21 14:54:08 +02:00
|
|
|
auto factory = extensions::CreateExtensionURLLoaderFactory(render_process_id,
|
|
|
|
render_frame_id);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (factory) {
|
2018-04-19 17:44:42 +02:00
|
|
|
factories->emplace(extensions::kExtensionScheme, std::move(factory));
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
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);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!web_contents) {
|
2019-05-01 21:09:59 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2019-05-01 21:09:59 +02:00
|
|
|
|
|
|
|
extensions::CefExtensionWebContentsObserver* web_observer =
|
|
|
|
extensions::CefExtensionWebContentsObserver::FromWebContents(
|
|
|
|
web_contents);
|
|
|
|
|
|
|
|
// There is nothing to do if no CefExtensionWebContentsObserver is attached
|
|
|
|
// to the |web_contents|.
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!web_observer) {
|
2019-05-01 21:09:59 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2019-05-01 21:09:59 +02:00
|
|
|
|
|
|
|
const extensions::Extension* extension =
|
|
|
|
web_observer->GetExtensionFromFrame(frame_host, false);
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extension) {
|
2019-05-01 21:09:59 +02:00
|
|
|
return;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2019-05-01 21:09:59 +02:00
|
|
|
|
|
|
|
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,
|
2021-06-04 03:34:56 +02:00
|
|
|
absl::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,
|
2023-06-26 12:13:38 +02:00
|
|
|
network::mojom::URLLoaderFactoryOverridePtr* factory_override,
|
|
|
|
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner) {
|
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);
|
|
|
|
}
|
|
|
|
|
2021-10-19 00:17:16 +02:00
|
|
|
bool 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()) {
|
2021-10-19 00:17:16 +02:00
|
|
|
// Cancel NetworkContext creation in
|
2020-07-20 19:49:16 +02:00
|
|
|
// StoragePartitionImpl::InitNetworkContext.
|
2021-10-19 00:17:16 +02:00
|
|
|
return false;
|
2020-07-20 19:49:16 +02:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
// TODO(cef): Remove this and add required NetworkAnonymizationKey,
|
2020-06-09 19:48:00 +02:00
|
|
|
// this is currently not the case and this was not required pre M84.
|
2023-05-30 10:55:32 +02:00
|
|
|
network_context_params->require_network_anonymization_key = false;
|
2021-10-19 00:17:16 +02:00
|
|
|
|
|
|
|
return true;
|
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() {
|
2023-06-06 16:41:53 +02:00
|
|
|
return {GetUserDataPath()};
|
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,
|
2021-07-23 18:40:13 +02:00
|
|
|
content::WebContents::Getter web_contents_getter,
|
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,
|
2022-03-26 02:12:30 +01:00
|
|
|
bool is_primary_main_frame,
|
|
|
|
bool is_in_fenced_frame_tree,
|
2021-10-19 00:17:16 +02:00
|
|
|
network::mojom::WebSandboxFlags sandbox_flags,
|
2018-04-19 17:44:42 +02:00
|
|
|
ui::PageTransition page_transition,
|
2018-11-30 23:21:07 +01:00
|
|
|
bool has_user_gesture,
|
2021-06-04 03:34:56 +02:00
|
|
|
const absl::optional<url::Origin>& initiating_origin,
|
2022-01-25 21:26:51 +01:00
|
|
|
content::RenderFrameHost* initiator_document,
|
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,
|
2022-03-26 02:12:30 +01:00
|
|
|
bool is_primary_main_frame,
|
|
|
|
bool is_in_fenced_frame_tree,
|
2021-10-19 00:17:16 +02:00
|
|
|
network::mojom::WebSandboxFlags sandbox_flags,
|
2019-09-04 17:13:32 +02:00
|
|
|
const network::ResourceRequest& resource_request,
|
2022-01-25 21:26:51 +01:00
|
|
|
const absl::optional<url::Origin>& initiating_origin,
|
|
|
|
content::RenderFrameHost* initiator_document,
|
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,
|
2021-06-04 03:34:56 +02:00
|
|
|
base::BindRepeating(CefBrowserPlatformDelegate::HandleExternalProtocol,
|
|
|
|
resource_request.url));
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
net_service::ProxyURLLoaderFactory::CreateProxy(
|
|
|
|
web_contents_getter, std::move(receiver), std::move(request_handler));
|
2019-04-24 04:50:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
2022-11-15 18:50:53 +01:00
|
|
|
|
2022-02-21 23:23:40 +01:00
|
|
|
std::unique_ptr<content::VideoOverlayWindow>
|
|
|
|
AlloyContentBrowserClient::CreateWindowForVideoPictureInPicture(
|
|
|
|
content::VideoPictureInPictureWindowController* controller) {
|
|
|
|
// Note: content::VideoOverlayWindow::Create() is defined by platform-specific
|
2019-10-15 13:11:59 +02:00
|
|
|
// 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.
|
2022-02-21 23:23:40 +01:00
|
|
|
return content::VideoOverlayWindow::Create(controller);
|
2019-10-15 13:11:59 +02:00
|
|
|
}
|
|
|
|
|
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) {
|
2021-05-14 18:58:55 +02:00
|
|
|
CefBrowserFrame::RegisterBrowserInterfaceBindersForFrame(render_frame_host,
|
|
|
|
map);
|
2020-03-30 22:13:42 +02:00
|
|
|
|
2022-10-20 18:49:29 +02:00
|
|
|
map->Add<blink::mojom::BadgeService>(base::BindRepeating(&BindBadgeService));
|
2023-02-27 19:52:38 +01:00
|
|
|
#if BUILDFLAG(IS_WIN) && BUILDFLAG(ENABLE_SPEECH_SERVICE)
|
2022-04-21 20:58:48 +02:00
|
|
|
map->Add<media::mojom::MediaFoundationRendererNotifier>(
|
|
|
|
base::BindRepeating(&BindMediaFoundationRendererNotifierHandler));
|
2023-02-27 19:52:38 +01:00
|
|
|
#endif
|
2022-08-23 03:37:40 +02:00
|
|
|
map->Add<network_hints::mojom::NetworkHintsHandler>(
|
|
|
|
base::BindRepeating(&BindNetworkHintsHandler));
|
2022-04-21 20:58:48 +02:00
|
|
|
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extensions::ExtensionsEnabled()) {
|
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
|
|
|
|
|
|
|
content::WebContents* web_contents =
|
|
|
|
content::WebContents::FromRenderFrameHost(render_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
|
|
|
|
|
|
|
const GURL& site = render_frame_host->GetSiteInstance()->GetSiteURL();
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!site.SchemeIs(extensions::kExtensionScheme)) {
|
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
|
|
|
|
|
|
|
content::BrowserContext* browser_context =
|
|
|
|
render_frame_host->GetProcess()->GetBrowserContext();
|
|
|
|
auto* extension = extensions::ExtensionRegistry::Get(browser_context)
|
|
|
|
->enabled_extensions()
|
|
|
|
.GetByID(site.host());
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!extension) {
|
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::ExtensionsBrowserClient::Get()
|
|
|
|
->RegisterBrowserInterfaceBindersForFrame(map, render_frame_host,
|
|
|
|
extension);
|
|
|
|
}
|
|
|
|
|
2022-10-20 18:49:29 +02:00
|
|
|
void AlloyContentBrowserClient::RegisterBrowserInterfaceBindersForServiceWorker(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const content::ServiceWorkerVersionBaseInfo& service_worker_version_info,
|
|
|
|
mojo::BinderMapWithContext<const content::ServiceWorkerVersionBaseInfo&>*
|
|
|
|
map) {
|
|
|
|
map->Add<blink::mojom::BadgeService>(
|
|
|
|
base::BindRepeating(&BindBadgeServiceForServiceWorker));
|
|
|
|
}
|
|
|
|
|
2020-03-30 22:13:42 +02:00
|
|
|
base::FilePath
|
2020-06-28 20:29:44 +02:00
|
|
|
AlloyContentBrowserClient::GetSandboxedStorageServiceDataDirectory() {
|
2023-06-06 16:41:53 +02:00
|
|
|
return GetUserDataPath();
|
2020-03-30 22:13:42 +02:00
|
|
|
}
|
|
|
|
|
2023-10-19 20:08:48 +02:00
|
|
|
base::FilePath AlloyContentBrowserClient::GetShaderDiskCacheDirectory() {
|
|
|
|
return GetUserDataPath().Append(FILE_PATH_LITERAL("ShaderCache"));
|
|
|
|
}
|
|
|
|
|
|
|
|
base::FilePath AlloyContentBrowserClient::GetGrShaderDiskCacheDirectory() {
|
|
|
|
return GetUserDataPath().Append(FILE_PATH_LITERAL("GrShaderCache"));
|
|
|
|
}
|
|
|
|
|
|
|
|
base::FilePath AlloyContentBrowserClient::GetGraphiteDawnDiskCacheDirectory() {
|
|
|
|
return GetUserDataPath().Append(FILE_PATH_LITERAL("GraphiteDawnCache"));
|
|
|
|
}
|
|
|
|
|
|
|
|
base::FilePath AlloyContentBrowserClient::GetNetLogDefaultDirectory() {
|
|
|
|
return GetUserDataPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
base::FilePath AlloyContentBrowserClient::GetFirstPartySetsDirectory() {
|
|
|
|
return GetUserDataPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
absl::optional<base::FilePath>
|
|
|
|
AlloyContentBrowserClient::GetLocalTracesDirectory() {
|
|
|
|
return GetUserDataPath();
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetProduct() {
|
2022-03-26 02:12:30 +01:00
|
|
|
return GetChromeProduct();
|
2019-01-17 10:56:52 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
std::string AlloyContentBrowserClient::GetChromeProduct() {
|
2023-05-30 10:55:32 +02:00
|
|
|
return std::string(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
|
|
|
}
|
|
|
|
|
2022-05-27 11:03:31 +02:00
|
|
|
std::unique_ptr<content::WebContentsViewDelegate>
|
|
|
|
AlloyContentBrowserClient::GetWebContentsViewDelegate(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
return std::make_unique<AlloyWebContentsViewDelegate>(web_contents);
|
|
|
|
}
|
|
|
|
|
2020-06-28 20:29:44 +02:00
|
|
|
blink::UserAgentMetadata AlloyContentBrowserClient::GetUserAgentMetadata() {
|
2023-05-30 10:55:32 +02:00
|
|
|
return embedder_support::GetUserAgentMetadata(
|
|
|
|
g_browser_process->local_state());
|
2019-02-21 01:42:36 +01:00
|
|
|
}
|
|
|
|
|
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);
|
2023-01-02 23:59:03 +01:00
|
|
|
for (const auto& pair : map) {
|
2019-07-24 23:12:00 +02:00
|
|
|
mime_types.insert(pair.first);
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2022-03-26 02:12:30 +01:00
|
|
|
mime_types.insert(pdf::kInternalPluginMimeType);
|
2019-07-24 23:12:00 +02:00
|
|
|
return mime_types;
|
|
|
|
}
|
|
|
|
|
2023-07-21 00:11:34 +02:00
|
|
|
void AlloyContentBrowserClient::GetMediaDeviceIDSalt(
|
|
|
|
content::RenderFrameHost* rfh,
|
2021-09-20 11:06:23 +02:00
|
|
|
const net::SiteForCookies& site_for_cookies,
|
2023-07-21 00:11:34 +02:00
|
|
|
const blink::StorageKey& storage_key,
|
|
|
|
base::OnceCallback<void(bool, const std::string&)> callback) {
|
|
|
|
GURL url = rfh->GetLastCommittedURL();
|
|
|
|
url::Origin top_frame_origin = rfh->GetMainFrame()->GetLastCommittedOrigin();
|
|
|
|
content::BrowserContext* browser_context = rfh->GetBrowserContext();
|
|
|
|
|
2020-09-14 22:26:31 +02:00
|
|
|
// Persistent MediaDevice IDs are allowed if cookies are allowed.
|
2023-07-21 00:11:34 +02:00
|
|
|
scoped_refptr<content_settings::CookieSettings> cookie_settings =
|
|
|
|
CookieSettingsFactory::GetForProfile(
|
|
|
|
Profile::FromBrowserContext(browser_context));
|
|
|
|
bool allowed = cookie_settings->IsFullCookieAccessAllowed(
|
|
|
|
url, site_for_cookies, top_frame_origin,
|
|
|
|
cookie_settings->SettingOverridesForStorage());
|
2023-08-09 23:17:17 +02:00
|
|
|
media_device_salt::MediaDeviceSaltService* salt_service =
|
2023-07-21 00:11:34 +02:00
|
|
|
MediaDeviceSaltServiceFactory::GetInstance()->GetForBrowserContext(
|
|
|
|
browser_context);
|
|
|
|
if (!salt_service) {
|
|
|
|
std::move(callback).Run(allowed, browser_context->UniqueId());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-09 23:17:17 +02:00
|
|
|
salt_service->GetSalt(rfh->GetStorageKey(),
|
|
|
|
base::BindOnce(std::move(callback), allowed));
|
2020-09-14 22:26:31 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 20:45:53 +01:00
|
|
|
void AlloyContentBrowserClient::OnWebContentsCreated(
|
|
|
|
content::WebContents* web_contents) {
|
|
|
|
// Attach universal WebContentsObservers. These are quite rare, and in most
|
|
|
|
// cases CefBrowserPlatformDelegateAlloy::BrowserCreated and/or
|
|
|
|
// CefExtensionsAPIClient::AttachWebContentsHelpers should be used instead.
|
|
|
|
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
extensions::CefExtensionWebContentsObserver::CreateForWebContents(
|
|
|
|
web_contents);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 21:28:12 +01:00
|
|
|
bool AlloyContentBrowserClient::IsFindInPageDisabledForOrigin(
|
|
|
|
const url::Origin& origin) {
|
|
|
|
// For PDF viewing with the PPAPI-free PDF Viewer, find-in-page should only
|
|
|
|
// display results from the PDF content, and not from the UI.
|
2022-03-26 02:12:30 +01:00
|
|
|
return IsPdfExtensionOrigin(origin);
|
2021-11-23 21:28:12 +01:00
|
|
|
}
|
|
|
|
|
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());
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!registry) {
|
2017-08-04 00:55:19 +02:00
|
|
|
return nullptr;
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2016-07-20 20:03:38 +02:00
|
|
|
return registry->enabled_extensions().GetExtensionOrAppByURL(
|
|
|
|
site_instance->GetSiteURL());
|
|
|
|
}
|