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.
|
|
|
|
|
|
|
|
#include "libcef/browser/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
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
#include "libcef/browser/browser_context_impl.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
#include "libcef/browser/browser_host_impl.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_main.h"
|
|
|
|
#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"
|
2016-10-17 20:14:44 +02:00
|
|
|
#include "libcef/browser/devtools_manager_delegate.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/browser/extensions/extension_system.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"
|
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-10-23 21:30:47 +02:00
|
|
|
#include "libcef/browser/printing/printing_message_filter.h"
|
2012-06-25 23:21:27 +02:00
|
|
|
#include "libcef/browser/resource_dispatcher_host_delegate.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"
|
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"
|
2013-04-16 00:16:01 +02:00
|
|
|
#include "libcef/common/content_client.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"
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "cef/grit/cef_resources.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/browser/chrome_service.h"
|
|
|
|
#include "chrome/browser/plugins/plugin_info_host_impl.h"
|
2017-02-14 23:27:19 +01:00
|
|
|
#include "chrome/browser/profiles/profile.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
2013-02-06 21:41:54 +01:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "chrome/common/constants.mojom.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"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "chrome/services/printing/public/mojom/constants.mojom.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/navigation_interception/intercept_navigation_throttle.h"
|
|
|
|
#include "components/navigation_interception/navigation_params.h"
|
2018-06-01 21:16:26 +02:00
|
|
|
#include "components/services/pdf_compositor/public/interfaces/pdf_compositor.mojom.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "content/browser/frame_host/navigation_handle_impl.h"
|
|
|
|
#include "content/browser/frame_host/render_frame_host_impl.h"
|
2015-09-25 13:59:30 +02:00
|
|
|
#include "content/browser/plugin_service_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"
|
2013-06-04 19:41:37 +02:00
|
|
|
#include "content/public/browser/child_process_security_policy.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"
|
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"
|
2012-06-25 23:21:27 +02:00
|
|
|
#include "content/public/browser/resource_dispatcher_host.h"
|
2017-04-27 20:59:31 +02:00
|
|
|
#include "content/public/browser/storage_partition.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/common/content_switches.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
#include "content/public/common/service_names.mojom.h"
|
2014-04-30 19:14:40 +02:00
|
|
|
#include "content/public/common/storage_quota_params.h"
|
2014-09-04 19:53:40 +02:00
|
|
|
#include "content/public/common/web_preferences.h"
|
2018-04-19 17:44:42 +02:00
|
|
|
#include "extensions/browser/api/web_request/web_request_api.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"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/io_thread_extension_message_filter.h"
|
|
|
|
#include "extensions/common/constants.h"
|
2015-10-14 20:23:08 +02:00
|
|
|
#include "extensions/common/switches.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"
|
2018-05-21 14:54:08 +02:00
|
|
|
#include "services/service_manager/embedder/switches.h"
|
2018-03-20 21:15:08 +01:00
|
|
|
#include "services/service_manager/public/mojom/connector.mojom.h"
|
2018-05-14 13:24:05 +02:00
|
|
|
#include "services/service_manager/sandbox/switches.h"
|
2017-04-27 20:59:31 +02:00
|
|
|
#include "storage/browser/quota/quota_settings.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
|
|
|
|
2016-10-14 17:56:41 +02:00
|
|
|
#if defined(OS_LINUX)
|
|
|
|
#include "libcef/common/widevine_loader.h"
|
|
|
|
#endif
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
#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/app/breakpad_linux.h"
|
|
|
|
#include "components/crash/content/browser/crash_handler_host_linux.h"
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "content/public/common/content_descriptors.h"
|
|
|
|
#endif
|
|
|
|
|
2015-06-12 01:00:09 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "sandbox/win/src/sandbox_policy.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:
|
|
|
|
explicit CefQuotaCallbackImpl(
|
|
|
|
const content::QuotaPermissionContext::PermissionCallback& callback)
|
2017-05-17 11:29:28 +02:00
|
|
|
: callback_(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()) {
|
2015-04-02 17:21:46 +02:00
|
|
|
RunNow(callback_, false);
|
2012-09-28 00:52:15 +02:00
|
|
|
} else {
|
2017-05-17 11:29:28 +02:00
|
|
|
CEF_POST_TASK(CEF_IOT, base::Bind(&CefQuotaCallbackImpl::RunNow,
|
|
|
|
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()) {
|
2015-04-02 17:21:46 +02:00
|
|
|
RunNow(callback_, allow);
|
2012-09-28 00:52:15 +02:00
|
|
|
callback_.Reset();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
CEF_POST_TASK(CEF_IOT,
|
2017-05-17 11:29:28 +02:00
|
|
|
base::Bind(&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
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void Disconnect() { callback_.Reset(); }
|
2012-09-28 00:52:15 +02:00
|
|
|
|
|
|
|
private:
|
2015-04-02 17:21:46 +02:00
|
|
|
static void RunNow(
|
|
|
|
const content::QuotaPermissionContext::PermissionCallback& callback,
|
|
|
|
bool allow) {
|
2012-09-28 00:52:15 +02:00
|
|
|
CEF_REQUIRE_IOT();
|
2017-05-17 11:29:28 +02:00
|
|
|
callback.Run(
|
|
|
|
allow ? content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW
|
|
|
|
: content::QuotaPermissionContext::
|
|
|
|
QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
content::QuotaPermissionContext::PermissionCallback callback_;
|
|
|
|
|
|
|
|
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:
|
2016-08-31 13:25:56 +02:00
|
|
|
typedef base::Callback<void(content::CertificateRequestResultType)>
|
2014-07-02 20:25:22 +02:00
|
|
|
CallbackType;
|
|
|
|
|
|
|
|
explicit CefAllowCertificateErrorCallbackImpl(const CallbackType& callback)
|
2017-05-17 11:29:28 +02:00
|
|
|
: callback_(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()) {
|
|
|
|
RunNow(callback_, false);
|
|
|
|
} else {
|
|
|
|
CEF_POST_TASK(CEF_UIT,
|
2017-05-17 11:29:28 +02:00
|
|
|
base::Bind(&CefAllowCertificateErrorCallbackImpl::RunNow,
|
|
|
|
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()) {
|
2015-04-02 17:21:46 +02:00
|
|
|
RunNow(callback_, allow);
|
2013-04-04 19:50:35 +02:00
|
|
|
callback_.Reset();
|
|
|
|
}
|
|
|
|
} 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
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
void Disconnect() { callback_.Reset(); }
|
2013-04-04 19:50:35 +02:00
|
|
|
|
|
|
|
private:
|
2015-04-02 17:21:46 +02:00
|
|
|
static void RunNow(const CallbackType& callback, bool allow) {
|
2015-05-07 16:37:50 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
2017-05-17 11:29:28 +02:00
|
|
|
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_)
|
|
|
|
DoSelect(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
CEF_POST_TASK(CEF_UIT,
|
2017-05-17 11:29:28 +02:00
|
|
|
base::Bind(&CefSelectClientCertificateCallbackImpl::RunNow,
|
|
|
|
base::Passed(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());
|
2017-07-27 01:19:27 +02:00
|
|
|
certImpl->AcquirePrivateKey(
|
|
|
|
base::Bind(&CefSelectClientCertificateCallbackImpl::RunWithPrivateKey,
|
|
|
|
base::Passed(std::move(delegate)), cert));
|
|
|
|
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,
|
|
|
|
const 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.
|
|
|
|
callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool handled = false;
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser =
|
2017-01-23 18:36:54 +01:00
|
|
|
CefBrowserHostImpl::GetBrowserForFrame(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(
|
|
|
|
new CefQuotaCallbackImpl(callback));
|
2017-05-17 11:29:28 +02:00
|
|
|
handled = handler->OnQuotaRequest(
|
|
|
|
browser.get(), params.origin_url.spec(), params.requested_size,
|
|
|
|
callbackImpl.get());
|
2012-09-28 00:52:15 +02:00
|
|
|
if (!handled)
|
|
|
|
callbackImpl->Disconnect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!handled) {
|
|
|
|
// Disallow the request by default.
|
|
|
|
callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
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
|
|
|
|
// CefMainDelegate::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)) {
|
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
|
|
|
|
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) {
|
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
|
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost(process_type);
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process_type == switches::kPpapiPluginProcess) {
|
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
|
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost(process_type);
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process_type == switches::kGpuProcess) {
|
|
|
|
static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
|
|
|
|
if (!crash_handler)
|
|
|
|
crash_handler = CreateCrashHandlerHost(process_type);
|
|
|
|
return crash_handler->GetDeathSignalSocket();
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
|
2015-10-09 17:23:12 +02:00
|
|
|
// TODO(cef): We can't currently trust NavigationParams::is_main_frame() because
|
|
|
|
// it's always set to true in
|
|
|
|
// InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation. Remove the
|
|
|
|
// |is_main_frame| argument once this problem is fixed.
|
|
|
|
bool NavigationOnUIThread(
|
|
|
|
bool is_main_frame,
|
|
|
|
int64 frame_id,
|
|
|
|
int64 parent_frame_id,
|
|
|
|
content::WebContents* source,
|
|
|
|
const navigation_interception::NavigationParams& params) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
|
|
|
bool ignore_navigation = false;
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser =
|
|
|
|
CefBrowserHostImpl::GetBrowserForContents(source);
|
|
|
|
if (browser.get()) {
|
|
|
|
CefRefPtr<CefClient> client = browser->GetClient();
|
|
|
|
if (client.get()) {
|
|
|
|
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
|
|
|
if (handler.get()) {
|
|
|
|
CefRefPtr<CefFrame> frame;
|
|
|
|
if (is_main_frame) {
|
|
|
|
frame = browser->GetMainFrame();
|
|
|
|
} else if (frame_id >= 0) {
|
|
|
|
frame = browser->GetFrame(frame_id);
|
|
|
|
DCHECK(frame);
|
|
|
|
} else {
|
|
|
|
// Create a temporary frame object for navigation of sub-frames that
|
|
|
|
// don't yet exist.
|
2017-05-17 11:29:28 +02:00
|
|
|
frame = new CefFrameHostImpl(
|
|
|
|
browser.get(), CefFrameHostImpl::kInvalidFrameId, false,
|
|
|
|
CefString(), CefString(), parent_frame_id);
|
2015-10-09 17:23:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
|
|
|
|
request->Set(params, is_main_frame);
|
|
|
|
request->SetReadOnly(true);
|
|
|
|
|
2018-06-19 00:08:20 +02:00
|
|
|
// Initiating a new navigation in OnBeforeBrowse will delete the
|
|
|
|
// InterceptNavigationThrottle that currently owns this callback,
|
|
|
|
// resulting in a crash. Use the lock to prevent that.
|
|
|
|
std::unique_ptr<CefBrowserHostImpl::NavigationLock> navigation_lock =
|
|
|
|
browser->CreateNavigationLock();
|
2015-10-09 17:23:12 +02:00
|
|
|
ignore_navigation = handler->OnBeforeBrowse(
|
2018-04-27 17:11:53 +02:00
|
|
|
browser.get(), frame, request.get(), params.has_user_gesture(),
|
|
|
|
params.is_redirect());
|
2015-10-09 17:23:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ignore_navigation;
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
} // namespace
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentBrowserClient::CefContentBrowserClient() : browser_main_parts_(NULL) {
|
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
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentBrowserClient::~CefContentBrowserClient() {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
// static
|
|
|
|
CefContentBrowserClient* CefContentBrowserClient::Get() {
|
2018-03-20 21:15:08 +01:00
|
|
|
if (!CefContentClient::Get())
|
|
|
|
return nullptr;
|
2012-11-20 21:08:36 +01:00
|
|
|
return static_cast<CefContentBrowserClient*>(
|
2013-04-16 00:16:01 +02:00
|
|
|
CefContentClient::Get()->browser());
|
2012-11-20 21:08:36 +01:00
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
content::BrowserMainParts* CefContentBrowserClient::CreateBrowserMainParts(
|
|
|
|
const content::MainFunctionParams& parameters) {
|
2012-04-11 20:00:55 +02:00
|
|
|
browser_main_parts_ = new CefBrowserMainParts(parameters);
|
2018-03-20 21:15:08 +01:00
|
|
|
browser_main_parts_->AddParts(
|
|
|
|
ChromeService::GetInstance()->CreateExtraParts());
|
2012-04-11 20:00:55 +02:00
|
|
|
return browser_main_parts_;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
void CefContentBrowserClient::RenderProcessWillLaunch(
|
2018-03-20 21:15:08 +01:00
|
|
|
content::RenderProcessHost* host,
|
|
|
|
service_manager::mojom::ServiceRequest* service_request) {
|
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));
|
2016-11-23 21:54:29 +01:00
|
|
|
host->AddFilter(new printing::CefPrintingMessageFilter(id, profile));
|
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::IOThreadExtensionMessageFilter(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());
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
host->Send(
|
|
|
|
new CefProcessMsg_SetIsIncognitoProcess(profile->IsOffTheRecord()));
|
2018-03-20 21:15:08 +01:00
|
|
|
|
|
|
|
service_manager::mojom::ServicePtr service;
|
|
|
|
*service_request = mojo::MakeRequest(&service);
|
|
|
|
service_manager::mojom::PIDReceiverPtr pid_receiver;
|
|
|
|
service_manager::Identity renderer_identity = host->GetChildIdentity();
|
|
|
|
ChromeService::GetInstance()->connector()->StartService(
|
|
|
|
service_manager::Identity(chrome::mojom::kRendererServiceName,
|
|
|
|
renderer_identity.user_id(),
|
|
|
|
renderer_identity.instance()),
|
|
|
|
std::move(service), mojo::MakeRequest(&pid_receiver));
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CefContentBrowserClient::ShouldUseProcessPerSite(
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-06-04 19:41:37 +02:00
|
|
|
bool CefContentBrowserClient::IsHandledURL(const GURL& url) {
|
|
|
|
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;
|
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
return CefContentClient::Get()->HasCustomScheme(scheme);
|
2013-06-04 19:41:37 +02:00
|
|
|
}
|
|
|
|
|
2016-07-20 20:03:38 +02:00
|
|
|
void CefContentBrowserClient::SiteInstanceGotProcess(
|
|
|
|
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;
|
|
|
|
|
|
|
|
CefBrowserContext* browser_context =
|
|
|
|
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_IOT, base::Bind(&extensions::InfoMap::RegisterExtensionProcess,
|
|
|
|
browser_context->extension_system()->info_map(),
|
|
|
|
extension->id(), site_instance->GetProcess()->GetID(),
|
|
|
|
site_instance->GetId()));
|
2016-07-20 20:03:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentBrowserClient::SiteInstanceDeleting(
|
|
|
|
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;
|
|
|
|
|
|
|
|
CefBrowserContext* browser_context =
|
|
|
|
static_cast<CefBrowserContext*>(site_instance->GetBrowserContext());
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_IOT, base::Bind(&extensions::InfoMap::UnregisterExtensionProcess,
|
|
|
|
browser_context->extension_system()->info_map(),
|
|
|
|
extension->id(), site_instance->GetProcess()->GetID(),
|
|
|
|
site_instance->GetId()));
|
2016-07-20 20:03:38 +02:00
|
|
|
}
|
|
|
|
|
2017-12-27 22:38:34 +01:00
|
|
|
void CefContentBrowserClient::RegisterInProcessServices(
|
2018-06-01 21:16:26 +02:00
|
|
|
StaticServiceMap* services,
|
|
|
|
content::ServiceManagerConnection* connection) {
|
2017-12-07 22:44:24 +01:00
|
|
|
{
|
|
|
|
// For spell checking.
|
|
|
|
service_manager::EmbeddedServiceInfo info;
|
2018-03-20 21:15:08 +01:00
|
|
|
info.factory = ChromeService::GetInstance()->CreateChromeServiceFactory();
|
2017-12-07 22:44:24 +01:00
|
|
|
services->insert(std::make_pair(chrome::mojom::kServiceName, info));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
void CefContentBrowserClient::RegisterOutOfProcessServices(
|
|
|
|
OutOfProcessServiceMap* services) {
|
2017-10-20 19:45:20 +02:00
|
|
|
(*services)[printing::mojom::kServiceName] =
|
|
|
|
base::ASCIIToUTF16("PDF Compositor Service");
|
2018-02-15 01:12:09 +01:00
|
|
|
(*services)[printing::mojom::kChromePrintingServiceName] =
|
|
|
|
base::ASCIIToUTF16("Printing Service");
|
2017-12-27 22:38:34 +01:00
|
|
|
(*services)[proxy_resolver::mojom::kProxyResolverServiceName] =
|
|
|
|
l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_PROXY_RESOLVER_NAME);
|
2017-05-31 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
std::unique_ptr<base::Value> CefContentBrowserClient::GetServiceManifestOverlay(
|
|
|
|
base::StringPiece name) {
|
2016-11-23 21:54:29 +01:00
|
|
|
int id = -1;
|
|
|
|
if (name == content::mojom::kBrowserServiceName)
|
|
|
|
id = IDR_CEF_BROWSER_MANIFEST_OVERLAY;
|
2017-12-07 22:44:24 +01:00
|
|
|
else if (name == content::mojom::kPackagedServicesServiceName)
|
|
|
|
id = IDR_CEF_PACKAGED_SERVICES_MANIFEST_OVERLAY;
|
2016-11-23 21:54:29 +01:00
|
|
|
else if (name == content::mojom::kRendererServiceName)
|
|
|
|
id = IDR_CEF_RENDERER_MANIFEST_OVERLAY;
|
|
|
|
else if (name == content::mojom::kUtilityServiceName)
|
|
|
|
id = IDR_CEF_UTILITY_MANIFEST_OVERLAY;
|
|
|
|
if (id == -1)
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
base::StringPiece manifest_contents =
|
|
|
|
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
|
|
|
id, ui::ScaleFactor::SCALE_FACTOR_NONE);
|
|
|
|
return base::JSONReader::Read(manifest_contents);
|
|
|
|
}
|
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
std::vector<content::ContentBrowserClient::ServiceManifestInfo>
|
|
|
|
CefContentBrowserClient::GetExtraServiceManifests() {
|
|
|
|
return std::vector<ServiceManifestInfo>({
|
|
|
|
{printing::mojom::kServiceName, IDR_PDF_COMPOSITOR_MANIFEST},
|
2018-03-20 21:15:08 +01:00
|
|
|
{chrome::mojom::kRendererServiceName,
|
|
|
|
IDR_CHROME_RENDERER_SERVICE_MANIFEST},
|
2017-05-31 17:33:30 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
bool CefContentBrowserClient::IsSameBrowserContext(
|
|
|
|
content::BrowserContext* context1,
|
|
|
|
content::BrowserContext* context2) {
|
|
|
|
return CefBrowserContextImpl::GetForContext(context1) ==
|
|
|
|
CefBrowserContextImpl::GetForContext(context2);
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefContentBrowserClient::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,
|
2017-01-27 01:14:56 +01:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
switches::kFrameworkDirPath,
|
|
|
|
#endif
|
2012-10-25 23:19:20 +02:00
|
|
|
switches::kLocalesDirPath,
|
2012-09-10 18:13:51 +02:00
|
|
|
switches::kLogFile,
|
|
|
|
switches::kLogSeverity,
|
2014-01-10 20:49:43 +01:00
|
|
|
switches::kProductVersion,
|
2014-10-28 00:12:21 +01:00
|
|
|
switches::kResourcesDirPath,
|
|
|
|
switches::kUserAgent,
|
2012-09-10 18:13:51 +02:00
|
|
|
};
|
2015-01-09 18:22:10 +01:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
2012-09-10 18:13:51 +02:00
|
|
|
arraysize(kSwitchNames));
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
switches::kDisableScrollBounce,
|
|
|
|
switches::kDisableSpellChecking,
|
|
|
|
switches::kEnableSpeechInput,
|
|
|
|
switches::kEnableSystemFlash,
|
|
|
|
switches::kPpapiFlashArgs,
|
|
|
|
switches::kPpapiFlashPath,
|
|
|
|
switches::kPpapiFlashVersion,
|
|
|
|
switches::kUncaughtExceptionStackSize,
|
2012-09-10 18:13:51 +02:00
|
|
|
};
|
2015-01-09 18:22:10 +01:00
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
2012-09-10 18:13:51 +02:00
|
|
|
arraysize(kSwitchNames));
|
2015-10-14 20:23:08 +02:00
|
|
|
|
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
// Based on ChromeContentBrowserClientExtensionsPart::
|
|
|
|
// AppendExtraRendererCommandLineSwitches
|
|
|
|
content::RenderProcessHost* process =
|
|
|
|
content::RenderProcessHost::FromID(child_process_id);
|
|
|
|
content::BrowserContext* browser_context =
|
|
|
|
process ? process->GetBrowserContext() : NULL;
|
2017-05-17 11:29:28 +02:00
|
|
|
if (browser_context && extensions::ProcessMap::Get(browser_context)
|
|
|
|
->Contains(process->GetID())) {
|
2015-10-14 20:23:08 +02:00
|
|
|
command_line->AppendSwitch(extensions::switches::kExtensionProcess);
|
|
|
|
}
|
|
|
|
}
|
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,
|
|
|
|
arraysize(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)
|
2018-05-21 14:54:08 +02:00
|
|
|
if (process_type == service_manager::switches::kZygoteProcess) {
|
2016-10-14 17:56:41 +02:00
|
|
|
// Propagate the following switches to the zygote command line (along with
|
2015-03-25 22:22:47 +01:00
|
|
|
// any associated values) if present in the browser command line.
|
|
|
|
static const char* const kSwitchNames[] = {
|
2017-05-17 11:29:28 +02:00
|
|
|
switches::kPpapiFlashPath, switches::kPpapiFlashVersion,
|
2015-03-25 22:22:47 +01:00
|
|
|
};
|
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
|
|
|
arraysize(kSwitchNames));
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
#if defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
2018-05-14 13:24:05 +02:00
|
|
|
if (!browser_cmd->HasSwitch(service_manager::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)
|
|
|
|
|
2013-09-03 18:43:31 +02:00
|
|
|
CefRefPtr<CefApp> app = CefContentClient::Get()->application();
|
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());
|
|
|
|
commandLinePtr->Detach(NULL);
|
|
|
|
}
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2012-09-28 00:52:15 +02:00
|
|
|
content::QuotaPermissionContext*
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
2012-09-28 00:52:15 +02:00
|
|
|
return new CefQuotaPermissionContext();
|
|
|
|
}
|
|
|
|
|
2017-04-27 20:59:31 +02:00
|
|
|
void CefContentBrowserClient::GetQuotaSettings(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
content::StoragePartition* partition,
|
2017-07-27 01:19:27 +02:00
|
|
|
storage::OptionalQuotaSettingsCallback callback) {
|
2017-08-04 00:55:19 +02:00
|
|
|
const base::FilePath& cache_path = partition->GetPath();
|
|
|
|
storage::GetNominalDynamicSettings(cache_path, !cache_path.empty(),
|
|
|
|
std::move(callback));
|
2017-04-27 20:59:31 +02:00
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
content::MediaObserver* CefContentBrowserClient::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*
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentBrowserClient::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();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-04-04 19:50:35 +02:00
|
|
|
void CefContentBrowserClient::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,
|
2014-09-04 19:53:40 +02:00
|
|
|
content::ResourceType resource_type,
|
2013-04-04 19:50:35 +02:00
|
|
|
bool strict_enforcement,
|
2014-09-04 19:53:40 +02:00
|
|
|
bool expired_previous_decision,
|
2017-05-17 11:29:28 +02:00
|
|
|
const base::Callback<void(content::CertificateRequestResultType)>&
|
|
|
|
callback) {
|
2013-04-04 19:50:35 +02:00
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
2014-09-04 19:53:40 +02:00
|
|
|
if (resource_type != content::ResourceType::RESOURCE_TYPE_MAIN_FRAME) {
|
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.
|
2016-08-31 13:25:56 +02:00
|
|
|
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
2013-04-04 19:50:35 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser =
|
2015-12-09 17:10:16 +01:00
|
|
|
CefBrowserHostImpl::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(
|
|
|
|
new CefAllowCertificateErrorCallbackImpl(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) {
|
2013-04-04 19:50:35 +02:00
|
|
|
callbackImpl->Disconnect();
|
2017-01-17 18:49:23 +01:00
|
|
|
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL);
|
|
|
|
}
|
2013-04-04 19:50:35 +02:00
|
|
|
}
|
|
|
|
|
2015-05-19 19:55:58 +02:00
|
|
|
void CefContentBrowserClient::SelectClientCertificate(
|
|
|
|
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;
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser =
|
|
|
|
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
|
|
|
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);
|
2016-10-27 19:57:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-08 01:07:41 +01:00
|
|
|
bool CefContentBrowserClient::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,
|
2013-08-15 21:38:55 +02:00
|
|
|
const GURL& 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
|
|
|
}
|
|
|
|
|
2012-06-25 23:21:27 +02:00
|
|
|
void CefContentBrowserClient::ResourceDispatcherHostCreated() {
|
|
|
|
resource_dispatcher_host_delegate_.reset(
|
|
|
|
new CefResourceDispatcherHostDelegate());
|
|
|
|
content::ResourceDispatcherHost::Get()->SetDelegate(
|
|
|
|
resource_dispatcher_host_delegate_.get());
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefContentBrowserClient::OverrideWebkitPrefs(
|
|
|
|
content::RenderViewHost* rvh,
|
2014-09-04 19:53:40 +02:00
|
|
|
content::WebPreferences* prefs) {
|
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);
|
2014-04-15 21:02:30 +02:00
|
|
|
|
2017-01-13 22:35:26 +01:00
|
|
|
if (rvh->GetWidget()->GetView()) {
|
2015-11-10 21:18:16 +01:00
|
|
|
rvh->GetWidget()->GetView()->SetBackgroundColor(
|
|
|
|
prefs->base_background_color);
|
|
|
|
}
|
2014-04-15 21:02:30 +02:00
|
|
|
}
|
|
|
|
|
2012-10-08 19:47:37 +02:00
|
|
|
void CefContentBrowserClient::BrowserURLHandlerCreated(
|
|
|
|
content::BrowserURLHandler* handler) {
|
2016-11-07 20:14:09 +01:00
|
|
|
scheme::BrowserURLHandlerCreated(handler);
|
2012-10-08 19:47:37 +02:00
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
std::string CefContentBrowserClient::GetDefaultDownloadName() {
|
|
|
|
return "download";
|
|
|
|
}
|
2012-09-11 00:19:19 +02:00
|
|
|
|
2015-03-25 22:22:47 +01:00
|
|
|
void CefContentBrowserClient::DidCreatePpapiPlugin(
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
content::DevToolsManagerDelegate*
|
2017-05-17 11:29:28 +02:00
|
|
|
CefContentBrowserClient::GetDevToolsManagerDelegate() {
|
2015-03-02 21:25:14 +01:00
|
|
|
return new 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>>
|
2015-10-09 17:23:12 +02:00
|
|
|
CefContentBrowserClient::CreateThrottlesForNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
2015-10-09 17:23:12 +02:00
|
|
|
|
|
|
|
const bool is_main_frame = navigation_handle->IsInMainFrame();
|
|
|
|
|
|
|
|
int64 parent_frame_id = CefFrameHostImpl::kUnspecifiedFrameId;
|
|
|
|
if (!is_main_frame) {
|
2017-11-29 00:00:50 +01:00
|
|
|
// Identify the RenderFrameHost that originated the navigation.
|
|
|
|
content::RenderFrameHost* parent_frame_host =
|
|
|
|
navigation_handle->GetParentFrame();
|
2015-10-09 17:23:12 +02:00
|
|
|
DCHECK(parent_frame_host);
|
2017-11-29 00:00:50 +01:00
|
|
|
if (parent_frame_host)
|
|
|
|
parent_frame_id = parent_frame_host->GetRoutingID();
|
2015-10-09 17:23:12 +02:00
|
|
|
if (parent_frame_id < 0)
|
|
|
|
parent_frame_id = CefFrameHostImpl::kUnspecifiedFrameId;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64 frame_id = CefFrameHostImpl::kInvalidFrameId;
|
|
|
|
if (!is_main_frame && navigation_handle->HasCommitted()) {
|
|
|
|
frame_id = navigation_handle->GetRenderFrameHost()->GetRoutingID();
|
|
|
|
if (frame_id < 0)
|
|
|
|
frame_id = CefFrameHostImpl::kInvalidFrameId;
|
|
|
|
}
|
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
std::unique_ptr<content::NavigationThrottle> throttle =
|
2018-03-20 21:15:08 +01:00
|
|
|
std::make_unique<navigation_interception::InterceptNavigationThrottle>(
|
2017-07-27 01:19:27 +02:00
|
|
|
navigation_handle, base::Bind(&NavigationOnUIThread, is_main_frame,
|
|
|
|
frame_id, parent_frame_id));
|
2017-01-23 18:36:54 +01:00
|
|
|
throttles.push_back(std::move(throttle));
|
2015-10-09 17:23:12 +02:00
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
return throttles;
|
2015-10-09 17:23:12 +02:00
|
|
|
}
|
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
#if defined(OS_LINUX)
|
2013-11-21 23:43:36 +01:00
|
|
|
void CefContentBrowserClient::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) {
|
2018-05-21 14:54:08 +02:00
|
|
|
mappings->Share(service_manager::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
|
|
|
|
2012-09-11 00:19:19 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const wchar_t* CefContentBrowserClient::GetResourceDllName() {
|
2017-05-17 11:29:28 +02:00
|
|
|
static wchar_t file_path[MAX_PATH + 1] = {0};
|
2012-09-11 00:19:19 +02:00
|
|
|
|
|
|
|
if (file_path[0] == 0) {
|
|
|
|
// Retrieve the module path (usually libcef.dll).
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath module;
|
2018-05-14 13:24:05 +02:00
|
|
|
base::PathService::Get(base::FILE_MODULE, &module);
|
2012-09-11 00:19:19 +02:00
|
|
|
const std::wstring wstr = module.value();
|
|
|
|
size_t count = std::min(static_cast<size_t>(MAX_PATH), wstr.size());
|
|
|
|
wcsncpy(file_path, wstr.c_str(), count);
|
|
|
|
file_path[count] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return file_path;
|
|
|
|
}
|
2015-06-12 01:00:09 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy) {
|
2016-05-25 01:35:43 +02:00
|
|
|
return true;
|
2015-06-12 01:00:09 +02:00
|
|
|
}
|
2012-09-11 00:19:19 +02:00
|
|
|
#endif // defined(OS_WIN)
|
2013-02-08 01:07:41 +01:00
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
void CefContentBrowserClient::ExposeInterfacesToRenderer(
|
|
|
|
service_manager::BinderRegistry* registry,
|
2017-12-07 22:44:24 +01:00
|
|
|
blink::AssociatedInterfaceRegistry* associated_registry,
|
|
|
|
content::RenderProcessHost* host) {
|
|
|
|
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
|
|
|
|
host->GetChannel()->AddAssociatedInterfaceForIOThread(base::Bind(
|
|
|
|
&PluginInfoHostImpl::OnPluginInfoHostRequest,
|
|
|
|
base::MakeRefCounted<PluginInfoHostImpl>(host->GetID(), profile)));
|
2017-07-27 01:19:27 +02:00
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
std::unique_ptr<net::ClientCertStore>
|
|
|
|
CefContentBrowserClient::CreateClientCertStore(
|
|
|
|
content::ResourceContext* resource_context) {
|
|
|
|
if (!resource_context)
|
|
|
|
return nullptr;
|
|
|
|
return static_cast<CefResourceContext*>(resource_context)
|
|
|
|
->CreateClientCertStore();
|
|
|
|
}
|
|
|
|
|
2018-04-19 17:44:42 +02:00
|
|
|
void CefContentBrowserClient::RegisterNonNetworkNavigationURLLoaderFactories(
|
2018-05-21 14:54:08 +02:00
|
|
|
int frame_tree_node_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(
|
2018-05-21 14:54:08 +02:00
|
|
|
web_contents->GetBrowserContext(),
|
|
|
|
!!extensions::WebViewGuest::FromWebContents(web_contents)));
|
2018-04-19 17:44:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefContentBrowserClient::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));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefContentBrowserClient::WillCreateURLLoaderFactory(
|
2018-06-08 18:53:10 +02:00
|
|
|
content::BrowserContext* browser_context,
|
2018-04-19 17:44:42 +02:00
|
|
|
content::RenderFrameHost* frame,
|
|
|
|
bool is_navigation,
|
|
|
|
network::mojom::URLLoaderFactoryRequest* factory_request) {
|
|
|
|
if (!extensions::ExtensionsEnabled())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
auto* web_request_api =
|
|
|
|
extensions::BrowserContextKeyedAPIFactory<extensions::WebRequestAPI>::Get(
|
2018-06-08 18:53:10 +02:00
|
|
|
browser_context);
|
2018-04-19 17:44:42 +02:00
|
|
|
return web_request_api->MaybeProxyURLLoaderFactory(frame, is_navigation,
|
|
|
|
factory_request);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefContentBrowserClient::HandleExternalProtocol(
|
|
|
|
const GURL& url,
|
|
|
|
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
|
|
|
|
int child_id,
|
|
|
|
content::NavigationUIData* navigation_data,
|
|
|
|
bool is_main_frame,
|
|
|
|
ui::PageTransition page_transition,
|
|
|
|
bool has_user_gesture) {
|
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_UIT,
|
|
|
|
base::Bind(
|
|
|
|
base::IgnoreResult(
|
|
|
|
&CefContentBrowserClient::HandleExternalProtocolOnUIThread),
|
|
|
|
url, web_contents_getter));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-05 01:37:26 +02:00
|
|
|
void CefContentBrowserClient::RegisterCustomScheme(const std::string& scheme) {
|
2013-06-04 19:41:37 +02:00
|
|
|
// Register as a Web-safe scheme so that requests for the scheme from a
|
|
|
|
// render process will be allowed in resource_dispatcher_host_impl.cc
|
|
|
|
// ShouldServiceRequest.
|
|
|
|
content::ChildProcessSecurityPolicy* policy =
|
|
|
|
content::ChildProcessSecurityPolicy::GetInstance();
|
|
|
|
if (!policy->IsWebSafeScheme(scheme))
|
|
|
|
policy->RegisterWebSafeScheme(scheme);
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefRefPtr<CefRequestContextImpl> CefContentBrowserClient::request_context()
|
|
|
|
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
|
|
|
|
|
|
|
CefDevToolsDelegate* CefContentBrowserClient::devtools_delegate() const {
|
|
|
|
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>
|
|
|
|
CefContentBrowserClient::background_task_runner() const {
|
|
|
|
return browser_main_parts_->background_task_runner();
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
|
|
|
CefContentBrowserClient::user_visible_task_runner() const {
|
|
|
|
return browser_main_parts_->user_visible_task_runner();
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
|
|
|
CefContentBrowserClient::user_blocking_task_runner() const {
|
|
|
|
return browser_main_parts_->user_blocking_task_runner();
|
|
|
|
}
|
|
|
|
|
2016-07-20 20:03:38 +02:00
|
|
|
const extensions::Extension* CefContentBrowserClient::GetExtension(
|
|
|
|
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());
|
|
|
|
}
|
2018-04-19 17:44:42 +02:00
|
|
|
|
|
|
|
// static
|
|
|
|
void CefContentBrowserClient::HandleExternalProtocolOnUIThread(
|
|
|
|
const GURL& url,
|
|
|
|
const content::ResourceRequestInfo::WebContentsGetter&
|
|
|
|
web_contents_getter) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
content::WebContents* web_contents = web_contents_getter.Run();
|
|
|
|
if (web_contents) {
|
|
|
|
CefRefPtr<CefBrowserHostImpl> browser =
|
|
|
|
CefBrowserHostImpl::GetBrowserForContents(web_contents);
|
|
|
|
if (browser.get())
|
|
|
|
browser->HandleExternalProtocol(url);
|
|
|
|
}
|
|
|
|
}
|