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

Side by Side Diff: extensions/browser/extension_navigation_throttle.cc

Issue 2881733006: ExtensionNavigationThrottle: Enforce the same rules on redirect as we (Closed)
Patch Set: Fix compile. Created 3 years, 7 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
« no previous file with comments | « extensions/browser/extension_navigation_throttle.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/guest_view/browser/guest_view_base.h" 7 #include "components/guest_view/browser/guest_view_base.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/navigation_handle.h" 9 #include "content/public/browser/navigation_handle.h"
10 #include "content/public/browser/render_frame_host.h" 10 #include "content/public/browser/render_frame_host.h"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace extensions { 26 namespace extensions {
27 27
28 ExtensionNavigationThrottle::ExtensionNavigationThrottle( 28 ExtensionNavigationThrottle::ExtensionNavigationThrottle(
29 content::NavigationHandle* navigation_handle) 29 content::NavigationHandle* navigation_handle)
30 : content::NavigationThrottle(navigation_handle) {} 30 : content::NavigationThrottle(navigation_handle) {}
31 31
32 ExtensionNavigationThrottle::~ExtensionNavigationThrottle() {} 32 ExtensionNavigationThrottle::~ExtensionNavigationThrottle() {}
33 33
34 content::NavigationThrottle::ThrottleCheckResult 34 content::NavigationThrottle::ThrottleCheckResult
35 ExtensionNavigationThrottle::WillStartRequest() { 35 ExtensionNavigationThrottle::WillStartOrRedirectRequest() {
36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
37 content::WebContents* web_contents = navigation_handle()->GetWebContents(); 37 content::WebContents* web_contents = navigation_handle()->GetWebContents();
38 ExtensionRegistry* registry = 38 ExtensionRegistry* registry =
39 ExtensionRegistry::Get(web_contents->GetBrowserContext()); 39 ExtensionRegistry::Get(web_contents->GetBrowserContext());
40 40
41 // Is this navigation targeting an extension resource? 41 // Is this navigation targeting an extension resource?
42 const GURL& url = navigation_handle()->GetURL(); 42 const GURL& url = navigation_handle()->GetURL();
43 bool url_has_extension_scheme = url.SchemeIs(kExtensionScheme); 43 bool url_has_extension_scheme = url.SchemeIs(kExtensionScheme);
44 url::Origin target_origin(url); 44 url::Origin target_origin(url);
45 const Extension* target_extension = nullptr; 45 const Extension* target_extension = nullptr;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // |url| must be in the manifest's "web_accessible_resources" section. 147 // |url| must be in the manifest's "web_accessible_resources" section.
148 if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(target_extension, 148 if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(target_extension,
149 url.path())) 149 url.path()))
150 return content::NavigationThrottle::BLOCK_REQUEST; 150 return content::NavigationThrottle::BLOCK_REQUEST;
151 } 151 }
152 152
153 return content::NavigationThrottle::PROCEED; 153 return content::NavigationThrottle::PROCEED;
154 } 154 }
155 155
156 content::NavigationThrottle::ThrottleCheckResult
157 ExtensionNavigationThrottle::WillStartRequest() {
158 return WillStartOrRedirectRequest();
159 }
160
161 content::NavigationThrottle::ThrottleCheckResult
162 ExtensionNavigationThrottle::WillRedirectRequest() {
163 ThrottleCheckResult result = WillStartOrRedirectRequest();
164 if (result == BLOCK_REQUEST) {
165 // TODO(nick): https://crbug.com/695421 means that BLOCK_REQUEST does not
166 // work here. Once PlzNavigate is enabled 100%, just return |result|.
167 return CANCEL;
168 }
169 return result;
170 }
171
156 const char* ExtensionNavigationThrottle::GetNameForLogging() { 172 const char* ExtensionNavigationThrottle::GetNameForLogging() {
157 return "ExtensionNavigationThrottle"; 173 return "ExtensionNavigationThrottle";
158 } 174 }
159 175
160 } // namespace extensions 176 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_navigation_throttle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698