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
|
|
|
|
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_host_impl.h"
|
|
|
|
#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"
|
2014-09-27 01:48:19 +02:00
|
|
|
#include "libcef/browser/devtools_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-03-25 22:22:47 +01:00
|
|
|
#include "libcef/browser/pepper/browser_pepper_host_factory.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "libcef/browser/plugins/plugin_info_message_filter.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"
|
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"
|
2012-09-11 00:19:19 +02:00
|
|
|
#include "base/path_service.h"
|
2014-10-07 22:44:33 +02:00
|
|
|
#include "chrome/browser/spellchecker/spellcheck_message_filter.h"
|
2013-02-06 21:41:54 +01:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/navigation_interception/intercept_navigation_throttle.h"
|
|
|
|
#include "components/navigation_interception/navigation_params.h"
|
|
|
|
#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"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/access_token_store.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "content/public/browser/browser_ppapi_host.h"
|
2012-10-08 19:47:37 +02:00
|
|
|
#include "content/public/browser/browser_url_handler.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"
|
2016-07-06 21:34:09 +02:00
|
|
|
#include "content/public/browser/geolocation_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"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/common/content_switches.h"
|
2014-04-30 19:14:40 +02:00
|
|
|
#include "content/public/common/storage_quota_params.h"
|
2014-09-04 19:53:40 +02:00
|
|
|
#include "content/public/common/web_preferences.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "extensions/browser/extension_message_filter.h"
|
|
|
|
#include "extensions/browser/extension_registry.h"
|
|
|
|
#include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
|
|
|
|
#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"
|
2013-08-15 21:38:55 +02:00
|
|
|
#include "third_party/WebKit/public/web/WebWindowFeatures.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
|
|
|
|
2014-10-07 22:44:33 +02:00
|
|
|
#if defined(OS_MACOSX)
|
2015-08-14 16:41:08 +02:00
|
|
|
#include "chrome/browser/spellchecker/spellcheck_message_filter_platform.h"
|
2014-10-07 22:44:33 +02:00
|
|
|
#endif
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
#include "base/debug/leak_annotations.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 {
|
|
|
|
|
|
|
|
// In-memory store for access tokens used by geolocation.
|
|
|
|
class CefAccessTokenStore : public content::AccessTokenStore {
|
|
|
|
public:
|
2015-03-02 21:25:14 +01:00
|
|
|
// |system_context| is used by NetworkLocationProvider to communicate with a
|
|
|
|
// remote geolocation service.
|
|
|
|
explicit CefAccessTokenStore(net::URLRequestContextGetter* system_context)
|
|
|
|
: system_context_(system_context) {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-03-16 03:55:59 +01:00
|
|
|
void LoadAccessTokens(const LoadAccessTokensCallback& callback) override {
|
|
|
|
callback.Run(access_token_map_, system_context_);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void SaveAccessToken(
|
|
|
|
const GURL& server_url, const base::string16& access_token) override {
|
2016-03-16 03:55:59 +01:00
|
|
|
access_token_map_[server_url] = access_token;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-03-02 21:25:14 +01:00
|
|
|
net::URLRequestContextGetter* system_context_;
|
2016-03-16 03:55:59 +01:00
|
|
|
AccessTokenMap access_token_map_;
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefAccessTokenStore);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
2016-07-06 21:34:09 +02:00
|
|
|
// A provider of services for geolocation.
|
|
|
|
class CefGeolocationDelegate : public content::GeolocationDelegate {
|
|
|
|
public:
|
|
|
|
explicit CefGeolocationDelegate(net::URLRequestContextGetter* system_context)
|
|
|
|
: system_context_(system_context) {}
|
|
|
|
|
|
|
|
content::AccessTokenStore* CreateAccessTokenStore() override {
|
|
|
|
return new CefAccessTokenStore(system_context_);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
net::URLRequestContextGetter* system_context_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefGeolocationDelegate);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
: 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 {
|
|
|
|
CEF_POST_TASK(CEF_IOT,
|
2015-04-02 17:21:46 +02:00
|
|
|
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,
|
|
|
|
base::Bind(&CefQuotaCallbackImpl::Continue, this, allow));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void Cancel() override {
|
2015-04-02 17:21:46 +02:00
|
|
|
Continue(false);
|
2012-09-28 00:52:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Disconnect() {
|
|
|
|
callback_.Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2015-04-02 17:21:46 +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:
|
2014-07-02 20:25:22 +02:00
|
|
|
typedef base::Callback<void(bool)> // NOLINT(readability/function)
|
|
|
|
CallbackType;
|
|
|
|
|
|
|
|
explicit CefAllowCertificateErrorCallbackImpl(const CallbackType& callback)
|
|
|
|
: 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,
|
|
|
|
base::Bind(&CefAllowCertificateErrorCallbackImpl::RunNow,
|
|
|
|
callback_, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
base::Bind(&CefAllowCertificateErrorCallbackImpl::Continue,
|
2015-04-02 17:21:46 +02:00
|
|
|
this, allow));
|
2013-04-04 19:50:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 17:21:46 +02:00
|
|
|
void Cancel() override {
|
|
|
|
Continue(false);
|
|
|
|
}
|
|
|
|
|
2013-04-04 19:50:35 +02:00
|
|
|
void Disconnect() {
|
|
|
|
callback_.Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2015-04-02 17:21:46 +02:00
|
|
|
callback.Run(allow);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2012-09-28 00:52:15 +02:00
|
|
|
class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
|
|
|
public:
|
|
|
|
CefQuotaPermissionContext() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// The callback will be dispatched on the IO thread.
|
2014-11-12 20:25:15 +01:00
|
|
|
void RequestQuotaPermission(
|
2014-04-30 19:14:40 +02:00
|
|
|
const content::StorageQuotaParams& params,
|
2012-09-28 00:52:15 +02:00
|
|
|
int render_process_id,
|
2014-11-12 20:25:15 +01:00
|
|
|
const PermissionCallback& callback) override {
|
2014-09-04 19:53:40 +02:00
|
|
|
if (params.storage_type != storage::kStorageTypePersistent) {
|
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 =
|
2014-01-02 23:41:11 +01:00
|
|
|
CefBrowserHostImpl::GetBrowserForView(render_process_id,
|
2014-04-30 19:14:40 +02:00
|
|
|
params.render_view_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));
|
2014-04-30 19:14:40 +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) {
|
|
|
|
base::FilePath dumps_path =
|
2014-10-07 22:44:33 +02:00
|
|
|
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
|
2013-11-21 23:43:36 +01:00
|
|
|
switches::kCrashDumpsDir);
|
|
|
|
{
|
|
|
|
ANNOTATE_SCOPED_MEMORY_LEAK;
|
|
|
|
breakpad::CrashHandlerHostLinux* crash_handler =
|
|
|
|
new breakpad::CrashHandlerHostLinux(
|
|
|
|
process_type, dumps_path, false);
|
|
|
|
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.
|
|
|
|
frame = new CefFrameHostImpl(browser.get(),
|
|
|
|
CefFrameHostImpl::kInvalidFrameId,
|
|
|
|
false,
|
|
|
|
CefString(),
|
|
|
|
CefString(),
|
|
|
|
parent_frame_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
|
|
|
|
request->Set(params, is_main_frame);
|
|
|
|
request->SetReadOnly(true);
|
|
|
|
|
|
|
|
ignore_navigation = handler->OnBeforeBrowse(
|
|
|
|
browser.get(), frame, request.get(), params.is_redirect());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ignore_navigation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FindFrameHostForNavigationHandle(
|
|
|
|
content::NavigationHandle* navigation_handle,
|
|
|
|
content::RenderFrameHost** matching_frame_host,
|
|
|
|
content::RenderFrameHost* current_frame_host) {
|
|
|
|
content::RenderFrameHostImpl* current_impl =
|
|
|
|
static_cast<content::RenderFrameHostImpl*>(current_frame_host);
|
|
|
|
if (current_impl->navigation_handle() == navigation_handle)
|
|
|
|
*matching_frame_host = current_frame_host;
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
CefContentBrowserClient::CefContentBrowserClient()
|
2015-11-17 19:20:13 +01:00
|
|
|
: 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
|
|
|
}
|
|
|
|
|
|
|
|
CefContentBrowserClient::~CefContentBrowserClient() {
|
|
|
|
}
|
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
// static
|
|
|
|
CefContentBrowserClient* CefContentBrowserClient::Get() {
|
|
|
|
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);
|
|
|
|
return browser_main_parts_;
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-01-02 23:41:11 +01:00
|
|
|
void CefContentBrowserClient::RenderProcessWillLaunch(
|
2012-04-03 03:34:16 +02:00
|
|
|
content::RenderProcessHost* host) {
|
2014-10-07 22:44:33 +02:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
const int id = host->GetID();
|
|
|
|
|
2016-05-11 18:18:43 +02:00
|
|
|
host->GetChannel()->AddFilter(new CefBrowserMessageFilter(id));
|
2014-10-07 22:44:33 +02:00
|
|
|
host->AddFilter(new printing::PrintingMessageFilter(id));
|
|
|
|
|
|
|
|
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
|
|
|
|
host->AddFilter(new SpellCheckMessageFilter(id));
|
|
|
|
#if defined(OS_MACOSX)
|
2015-08-14 16:41:08 +02:00
|
|
|
host->AddFilter(new SpellCheckMessageFilterPlatform(id));
|
2014-10-07 22:44:33 +02:00
|
|
|
#endif
|
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
content::BrowserContext* browser_context = host->GetBrowserContext();
|
|
|
|
|
2015-09-09 16:05:39 +02:00
|
|
|
host->AddFilter(new CefPluginInfoMessageFilter(id,
|
|
|
|
static_cast<CefBrowserContext*>(browser_context)));
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
host->AddFilter(
|
|
|
|
new extensions::ExtensionMessageFilter(id, browser_context));
|
|
|
|
host->AddFilter(
|
|
|
|
new extensions::IOThreadExtensionMessageFilter(id, browser_context));
|
|
|
|
host->AddFilter(
|
|
|
|
new extensions::ExtensionsGuestViewMessageFilter(id, browser_context));
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
host->Send(new CefProcessMsg_SetIsIncognitoProcess(
|
|
|
|
browser_context->IsOffTheRecord()));
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
2014-10-07 22:44:33 +02:00
|
|
|
base::CommandLine* command_line, int child_process_id) {
|
2015-01-09 18:22:10 +01:00
|
|
|
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
|
|
|
#if !defined(OS_WIN)
|
|
|
|
switches::kCrashDumpsDir,
|
|
|
|
#endif
|
|
|
|
switches::kDisablePackLoading,
|
|
|
|
switches::kEnableCrashReporter,
|
2012-10-25 23:19:20 +02:00
|
|
|
switches::kLang,
|
|
|
|
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[] = {
|
2012-10-29 22:46:02 +01:00
|
|
|
switches::kContextSafetyImplementation,
|
2015-07-16 23:40:01 +02:00
|
|
|
switches::kDisableExtensions,
|
|
|
|
switches::kDisablePdfExtension,
|
2015-04-08 15:16:17 +02:00
|
|
|
switches::kDisableScrollBounce,
|
2014-10-07 22:44:33 +02:00
|
|
|
switches::kDisableSpellChecking,
|
2013-03-08 01:41:26 +01:00
|
|
|
switches::kEnableSpeechInput,
|
2015-03-25 22:22:47 +01:00
|
|
|
switches::kEnableSystemFlash,
|
|
|
|
switches::kPpapiFlashArgs,
|
|
|
|
switches::kPpapiFlashPath,
|
|
|
|
switches::kPpapiFlashVersion,
|
2012-11-02 19:16:28 +01:00
|
|
|
switches::kUncaughtExceptionStackSize,
|
2015-08-31 13:28:07 +02:00
|
|
|
switches::kWidevineCdmPath,
|
|
|
|
switches::kWidevineCdmVersion,
|
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;
|
|
|
|
if (browser_context &&
|
|
|
|
extensions::ProcessMap::Get(browser_context)->Contains(
|
|
|
|
process->GetID())) {
|
|
|
|
command_line->AppendSwitch(extensions::switches::kExtensionProcess);
|
|
|
|
}
|
|
|
|
}
|
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)
|
2015-03-25 22:22:47 +01:00
|
|
|
if (process_type == switches::kZygoteProcess) {
|
|
|
|
// Propagate the following switches to the zygone command line (along with
|
|
|
|
// any associated values) if present in the browser command line.
|
|
|
|
static const char* const kSwitchNames[] = {
|
|
|
|
switches::kPpapiFlashPath,
|
|
|
|
switches::kPpapiFlashVersion,
|
2015-08-31 13:28:07 +02:00
|
|
|
switches::kWidevineCdmPath,
|
|
|
|
switches::kWidevineCdmVersion,
|
2015-03-25 22:22:47 +01:00
|
|
|
};
|
|
|
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
|
|
|
arraysize(kSwitchNames));
|
|
|
|
|
|
|
|
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*
|
|
|
|
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
|
|
|
return new CefQuotaPermissionContext();
|
|
|
|
}
|
|
|
|
|
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*
|
2014-12-13 21:18:31 +01: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 overridable,
|
|
|
|
bool strict_enforcement,
|
2014-09-04 19:53:40 +02:00
|
|
|
bool expired_previous_decision,
|
2013-04-04 19:50:35 +02:00
|
|
|
const base::Callback<void(bool)>& callback,
|
2013-06-04 19:41:37 +02:00
|
|
|
content::CertificateRequestResultType* result) {
|
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.
|
2013-06-04 19:41:37 +02:00
|
|
|
*result = 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());
|
2016-01-27 18:57:48 +01:00
|
|
|
if (!proceed)
|
2013-04-04 19:50:35 +02:00
|
|
|
callbackImpl->Disconnect();
|
2013-06-04 19:41:37 +02:00
|
|
|
|
|
|
|
*result = proceed ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
|
|
|
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,
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
2015-05-19 19:55:58 +02:00
|
|
|
if (!cert_request_info->client_certs.empty()) {
|
|
|
|
// Use the first certificate.
|
|
|
|
delegate->ContinueWithCertificate(cert_request_info->client_certs[0].get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-06 21:34:09 +02:00
|
|
|
content::GeolocationDelegate*
|
|
|
|
CefContentBrowserClient::CreateGeolocationDelegate() {
|
|
|
|
return new CefGeolocationDelegate(
|
2015-03-02 21:25:14 +01:00
|
|
|
browser_main_parts_->browser_context()->request_context().get());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-02-08 01:07:41 +01:00
|
|
|
bool CefContentBrowserClient::CanCreateWindow(
|
|
|
|
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,
|
2013-02-08 01:07:41 +01:00
|
|
|
WindowContainerType container_type,
|
2013-08-15 21:38:55 +02:00
|
|
|
const GURL& target_url,
|
|
|
|
const content::Referrer& referrer,
|
|
|
|
WindowOpenDisposition disposition,
|
2013-11-08 22:28:56 +01:00
|
|
|
const blink::WebWindowFeatures& features,
|
2013-08-15 21:38:55 +02:00
|
|
|
bool user_gesture,
|
|
|
|
bool opener_suppressed,
|
2013-02-08 01:07:41 +01:00
|
|
|
content::ResourceContext* context,
|
|
|
|
int render_process_id,
|
2015-07-24 02:06:56 +02:00
|
|
|
int opener_render_view_id,
|
|
|
|
int opener_render_frame_id,
|
2013-02-08 01:07:41 +01:00
|
|
|
bool* no_javascript_access) {
|
|
|
|
CEF_REQUIRE_IOT();
|
|
|
|
*no_javascript_access = false;
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
return CefBrowserInfoManager::GetInstance()->CanCreateWindow(
|
|
|
|
target_url, referrer, disposition, features, user_gesture,
|
|
|
|
opener_suppressed, render_process_id, opener_render_view_id,
|
|
|
|
opener_render_frame_id, 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) {
|
2015-10-17 02:44:00 +02:00
|
|
|
renderer_prefs::PopulateWebPreferences(rvh, *prefs);
|
2014-04-15 21:02:30 +02:00
|
|
|
|
2015-11-10 21:18:16 +01:00
|
|
|
if (rvh->GetWidget()->GetView()) {
|
|
|
|
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) {
|
|
|
|
// Used to redirect about: URLs to chrome: URLs.
|
|
|
|
handler->AddHandlerPair(&scheme::WillHandleBrowserAboutURL,
|
|
|
|
content::BrowserURLHandler::null_handler());
|
|
|
|
}
|
|
|
|
|
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>(
|
2015-03-25 22:22:47 +01:00
|
|
|
new CefBrowserPepperHostFactory(browser_host)));
|
|
|
|
}
|
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
content::DevToolsManagerDelegate*
|
|
|
|
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
|
|
|
|
2015-10-09 17:23:12 +02:00
|
|
|
ScopedVector<content::NavigationThrottle>
|
|
|
|
CefContentBrowserClient::CreateThrottlesForNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
|
|
|
|
ScopedVector<content::NavigationThrottle> throttles;
|
|
|
|
|
|
|
|
const bool is_main_frame = navigation_handle->IsInMainFrame();
|
|
|
|
|
|
|
|
int64 parent_frame_id = CefFrameHostImpl::kUnspecifiedFrameId;
|
|
|
|
if (!is_main_frame) {
|
|
|
|
// Identify the RenderFrameHostImpl that originated the navigation.
|
|
|
|
// TODO(cef): It would be better if NavigationHandle could directly report
|
|
|
|
// the owner RenderFrameHostImpl.
|
|
|
|
// There is additional complexity here if PlzNavigate is enabled. See
|
|
|
|
// comments in content/browser/frame_host/navigation_handle_impl.h.
|
|
|
|
content::WebContents* web_contents = navigation_handle->GetWebContents();
|
|
|
|
content::RenderFrameHost* parent_frame_host = NULL;
|
|
|
|
web_contents->ForEachFrame(
|
|
|
|
base::Bind(FindFrameHostForNavigationHandle,
|
|
|
|
navigation_handle, &parent_frame_host));
|
|
|
|
DCHECK(parent_frame_host);
|
|
|
|
|
|
|
|
parent_frame_id = parent_frame_host->GetRoutingID();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
content::NavigationThrottle* throttle =
|
|
|
|
new navigation_interception::InterceptNavigationThrottle(
|
|
|
|
navigation_handle,
|
|
|
|
base::Bind(&NavigationOnUIThread, is_main_frame, frame_id,
|
2015-12-09 17:10:16 +01:00
|
|
|
parent_frame_id),
|
|
|
|
true);
|
2015-10-09 17:23:12 +02:00
|
|
|
throttles.push_back(throttle);
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
return throttles;
|
2015-10-09 17:23:12 +02:00
|
|
|
}
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
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,
|
2014-11-12 20:25:15 +01:00
|
|
|
content::FileDescriptorInfo* mappings) {
|
2013-11-21 23:43:36 +01:00
|
|
|
int crash_signal_fd = GetCrashSignalFD(command_line);
|
|
|
|
if (crash_signal_fd >= 0) {
|
2014-11-12 20:25:15 +01:00
|
|
|
mappings->Share(kCrashDumpSignal, crash_signal_fd);
|
2013-11-21 23:43:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
|
|
|
|
|
2012-09-11 00:19:19 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const wchar_t* CefContentBrowserClient::GetResourceDllName() {
|
|
|
|
static wchar_t file_path[MAX_PATH+1] = {0};
|
|
|
|
|
|
|
|
if (file_path[0] == 0) {
|
|
|
|
// Retrieve the module path (usually libcef.dll).
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath module;
|
2012-09-11 00:19:19 +02:00
|
|
|
PathService::Get(base::FILE_MODULE, &module);
|
|
|
|
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
|
|
|
|
2015-12-09 17:10:16 +01: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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:17:08 +01:00
|
|
|
scoped_refptr<CefBrowserContextImpl>
|
|
|
|
CefContentBrowserClient::browser_context() const {
|
2013-02-23 01:43:28 +01:00
|
|
|
return browser_main_parts_->browser_context();
|
|
|
|
}
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
CefDevToolsDelegate* CefContentBrowserClient::devtools_delegate() const {
|
|
|
|
return browser_main_parts_->devtools_delegate();
|
|
|
|
}
|