OLD | NEW |
---|---|
(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_->render_manager()->current_frame_host(); | |
nasko
2017/02/11 00:01:23
nit: No need to indirect through render_manager()
arthursonzogni
2017/02/13 16:33:20
Done.
| |
21 | |
22 if (!current_frame_host) | |
alexmos
2017/02/10 22:59:53
Is this null check needed?
arthursonzogni
2017/02/13 16:33:20
It is probably not needed indeed for this case(i.e
alexmos
2017/02/14 06:57:19
I haven't ever seen any code null-checking current
arthursonzogni
2017/02/15 09:26:09
You are probably right. I will remove the "if (!cu
| |
23 return; | |
24 | |
25 current_frame_host->AddMessageToConsole(CONSOLE_MESSAGE_LEVEL_ERROR, message); | |
nasko
2017/02/11 00:01:23
Is the log level always ERROR?
arthursonzogni
2017/02/13 16:33:20
Yes, see all calls to ContentSecurityPolicy::logTo
| |
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::SchemeShouldBypass(const base::StringPiece& scheme) { | |
alexmos
2017/02/10 22:59:53
Perhaps name this SchemeShouldBypassCSP, so it's c
arthursonzogni
2017/02/13 16:33:20
Done.
| |
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_scheme = url::GetCSPBypassingSchemes(); | |
alexmos
2017/02/10 22:59:53
nit: s/bypassing_scheme/bypassing_schemes/
arthursonzogni
2017/02/13 16:33:20
Done.
| |
43 return std::find(bypassing_scheme.begin(), bypassing_scheme.end(), scheme) != | |
44 bypassing_scheme.end(); | |
45 } | |
46 | |
47 } // namespace content | |
OLD | NEW |