Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: content/browser/frame_host/csp_context_impl.cc

Issue 2655463006: PlzNavigate: Enforce 'frame-src' CSP on the browser. (Closed)
Patch Set: Addressed comments(alexmos@ and nasko@) Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <algorithm>
6
7 #include "content/browser/frame_host/csp_context_impl.h"
8 #include "content/browser/frame_host/frame_tree_node.h"
9 #include "url/url_util.h"
10
11 namespace content {
12
13 CSPContextImpl::CSPContextImpl(FrameTreeNode* frame_tree_node)
14 : frame_tree_node_(frame_tree_node) {
15 DCHECK(frame_tree_node_);
16 }
17
18 void CSPContextImpl::LogToConsole(const std::string& message) {
19 RenderFrameHostImpl* current_frame_host =
20 frame_tree_node_->current_frame_host();
21
22 if (!current_frame_host)
23 return;
24
25 current_frame_host->AddMessageToConsole(CONSOLE_MESSAGE_LEVEL_ERROR, message);
26 }
27
28 void CSPContextImpl::ReportViolation(
29 const CSPViolationParams& violation_params) {
30 frame_tree_node_->current_frame_host()->ContentSecurityPolicyViolation(
31 violation_params);
32 }
33
34 bool CSPContextImpl::SchemeShouldBypassCSP(const base::StringPiece& scheme) {
35 // Blink uses its SchemeRegistry to check if a scheme should be bypassed.
36 // It can't be used on the browser process. It is used for two things:
37 // 1) Bypassing the "chrome-extension" scheme when chrome is built with the
38 // extensions support.
39 // 2) Bypassing arbitrary scheme for testing purpose only in blink and in V8.
40 // TODO(arthursonzogni): url::GetBypassingCSPScheme() is used instead of the
41 // blink::SchemeRegistry. It contains 1) but not 2).
42 const auto& bypassing_schemes = url::GetCSPBypassingSchemes();
43 return std::find(bypassing_schemes.begin(), bypassing_schemes.end(),
44 scheme) != bypassing_schemes.end();
45 }
46
47 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698