2013-01-03 18:24:24 +01:00
|
|
|
/// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Portions (c) 2011 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.
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
#include "libcef/renderer/render_thread_observer.h"
|
2017-05-17 11:29:28 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/common/cef_messages.h"
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "libcef/common/net/net_resource_provider.h"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "libcef/renderer/blink_glue.h"
|
2012-04-24 20:01:48 +02:00
|
|
|
#include "libcef/renderer/content_renderer_client.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-10-21 21:52:29 +02:00
|
|
|
#include "components/visitedlink/renderer/visitedlink_slave.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "content/public/child/child_thread.h"
|
|
|
|
#include "content/public/common/service_manager_connection.h"
|
|
|
|
#include "content/public/common/simple_connection_filter.h"
|
2016-10-21 21:52:29 +02:00
|
|
|
#include "content/public/renderer/render_thread.h"
|
2013-06-24 20:57:05 +02:00
|
|
|
#include "net/base/net_module.h"
|
2017-05-31 17:33:30 +02:00
|
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
2018-04-19 17:44:42 +02:00
|
|
|
#include "third_party/blink/public/platform/web_string.h"
|
|
|
|
#include "third_party/blink/public/platform/web_url.h"
|
|
|
|
#include "third_party/blink/public/web/web_security_policy.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
bool CefRenderThreadObserver::is_incognito_process_ = false;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2016-10-21 21:52:29 +02:00
|
|
|
CefRenderThreadObserver::CefRenderThreadObserver()
|
2017-05-17 11:29:28 +02:00
|
|
|
: visited_link_slave_(new visitedlink::VisitedLinkSlave) {
|
2013-06-24 20:57:05 +02:00
|
|
|
net::NetModule::SetResourceProvider(NetResourceProvider);
|
2016-10-21 21:52:29 +02:00
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
auto registry = std::make_unique<service_manager::BinderRegistry>();
|
2017-05-31 17:33:30 +02:00
|
|
|
registry->AddInterface(visited_link_slave_->GetBindCallback(),
|
|
|
|
base::ThreadTaskRunnerHandle::Get());
|
|
|
|
if (content::ChildThread::Get()) {
|
|
|
|
content::ChildThread::Get()
|
|
|
|
->GetServiceManagerConnection()
|
2018-03-20 21:15:08 +01:00
|
|
|
->AddConnectionFilter(std::make_unique<content::SimpleConnectionFilter>(
|
2017-05-31 17:33:30 +02:00
|
|
|
std::move(registry)));
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefRenderThreadObserver::~CefRenderThreadObserver() {}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
bool CefRenderThreadObserver::OnControlMessageReceived(
|
2012-04-03 03:34:16 +02:00
|
|
|
const IPC::Message& message) {
|
|
|
|
bool handled = true;
|
2016-05-25 01:35:43 +02:00
|
|
|
IPC_BEGIN_MESSAGE_MAP(CefRenderThreadObserver, message)
|
2015-07-16 23:40:01 +02:00
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_SetIsIncognitoProcess,
|
|
|
|
OnSetIsIncognitoProcess)
|
2012-04-03 03:34:16 +02:00
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_ModifyCrossOriginWhitelistEntry,
|
|
|
|
OnModifyCrossOriginWhitelistEntry)
|
|
|
|
IPC_MESSAGE_HANDLER(CefProcessMsg_ClearCrossOriginWhitelist,
|
|
|
|
OnClearCrossOriginWhitelist)
|
|
|
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
|
|
|
IPC_END_MESSAGE_MAP()
|
|
|
|
return handled;
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnSetIsIncognitoProcess(
|
2015-07-16 23:40:01 +02:00
|
|
|
bool is_incognito_process) {
|
|
|
|
is_incognito_process_ = is_incognito_process;
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnModifyCrossOriginWhitelistEntry(
|
2012-04-03 03:34:16 +02:00
|
|
|
bool add,
|
2012-11-20 21:08:36 +01:00
|
|
|
const Cef_CrossOriginWhiteListEntry_Params& params) {
|
|
|
|
GURL gurl = GURL(params.source_origin);
|
2012-04-03 03:34:16 +02:00
|
|
|
if (add) {
|
2018-09-04 11:43:21 +02:00
|
|
|
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
|
2017-05-17 11:29:28 +02:00
|
|
|
gurl, blink::WebString::FromUTF8(params.target_protocol),
|
2017-04-20 21:28:17 +02:00
|
|
|
blink::WebString::FromUTF8(params.target_domain),
|
2018-11-03 02:15:09 +01:00
|
|
|
params.allow_target_subdomains,
|
2018-11-30 23:21:07 +01:00
|
|
|
network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
|
2012-04-03 03:34:16 +02:00
|
|
|
} else {
|
2018-11-30 23:21:07 +01:00
|
|
|
blink::WebSecurityPolicy::ClearOriginAccessListForOrigin(gurl);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
void CefRenderThreadObserver::OnClearCrossOriginWhitelist() {
|
2018-11-30 23:21:07 +01:00
|
|
|
blink::WebSecurityPolicy::ClearOriginAccessList();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|