OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/extension_navigation_throttle.h" | 5 #include "extensions/browser/extension_navigation_throttle.h" |
6 | 6 |
7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
8 #include "content/public/browser/navigation_handle.h" | 8 #include "content/public/browser/navigation_handle.h" |
9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 return content::NavigationThrottle::PROCEED; | 37 return content::NavigationThrottle::PROCEED; |
38 | 38 |
39 // The subframe which is navigated needs to have all of its ancestors be | 39 // The subframe which is navigated needs to have all of its ancestors be |
40 // at the same origin, otherwise the resource needs to be explicitly listed | 40 // at the same origin, otherwise the resource needs to be explicitly listed |
41 // in web_accessible_resources. | 41 // in web_accessible_resources. |
42 // Since the RenderFrameHost is not known until navigation has committed, | 42 // Since the RenderFrameHost is not known until navigation has committed, |
43 // we can't get it from NavigationHandle. However, this code only cares about | 43 // we can't get it from NavigationHandle. However, this code only cares about |
44 // the ancestor chain, so find the current RenderFrameHost and use it to | 44 // the ancestor chain, so find the current RenderFrameHost and use it to |
45 // traverse up to the main frame. | 45 // traverse up to the main frame. |
46 content::RenderFrameHost* navigating_frame = nullptr; | 46 content::RenderFrameHost* navigating_frame = nullptr; |
47 for (auto frame : navigation_handle()->GetWebContents()->GetAllFrames()) { | 47 for (auto* frame : navigation_handle()->GetWebContents()->GetAllFrames()) { |
48 if (frame->GetFrameTreeNodeId() == | 48 if (frame->GetFrameTreeNodeId() == |
49 navigation_handle()->GetFrameTreeNodeId()) { | 49 navigation_handle()->GetFrameTreeNodeId()) { |
50 navigating_frame = frame; | 50 navigating_frame = frame; |
51 break; | 51 break; |
52 } | 52 } |
53 } | 53 } |
54 DCHECK(navigating_frame); | 54 DCHECK(navigating_frame); |
55 | 55 |
56 // Traverse the chain of parent frames, checking if they are the same origin | 56 // Traverse the chain of parent frames, checking if they are the same origin |
57 // as the URL of this navigation. | 57 // as the URL of this navigation. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 if (WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, | 90 if (WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, |
91 resource_path)) { | 91 resource_path)) { |
92 return content::NavigationThrottle::PROCEED; | 92 return content::NavigationThrottle::PROCEED; |
93 } | 93 } |
94 | 94 |
95 return content::NavigationThrottle::BLOCK_REQUEST; | 95 return content::NavigationThrottle::BLOCK_REQUEST; |
96 } | 96 } |
97 | 97 |
98 } // namespace extensions | 98 } // namespace extensions |
OLD | NEW |