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"
|
2018-09-04 11:43:21 +02:00
|
|
|
#include "libcef/renderer/blink_glue.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
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
|
|
|
|
2020-09-25 03:40:47 +02:00
|
|
|
CefRenderThreadObserver::CefRenderThreadObserver() = default;
|
|
|
|
CefRenderThreadObserver::~CefRenderThreadObserver() = default;
|
2019-09-25 15:59:51 +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)
|
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::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),
|
2019-07-16 19:59:21 +02:00
|
|
|
/*destination_port=*/0,
|
|
|
|
params.allow_target_subdomains
|
|
|
|
? network::mojom::CorsDomainMatchMode::kAllowSubdomains
|
|
|
|
: network::mojom::CorsDomainMatchMode::kDisallowSubdomains,
|
|
|
|
network::mojom::CorsPortMatchMode::kAllowAnyPort,
|
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
|
|
|
}
|