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

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

Issue 2481923002: [WIP] make GURL::path() return a StringPiece (Closed)
Patch Set: thanks asan Created 4 years, 1 month 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 registry->enabled_extensions().GetExtensionOrAppByURL(url); 73 registry->enabled_extensions().GetExtensionOrAppByURL(url);
74 guest_view::GuestViewBase* guest = 74 guest_view::GuestViewBase* guest =
75 guest_view::GuestViewBase::FromWebContents(web_contents); 75 guest_view::GuestViewBase::FromWebContents(web_contents);
76 if (guest) { 76 if (guest) {
77 std::string owner_extension_id = guest->owner_host(); 77 std::string owner_extension_id = guest->owner_host();
78 const Extension* owner_extension = 78 const Extension* owner_extension =
79 registry->enabled_extensions().GetByID(owner_extension_id); 79 registry->enabled_extensions().GetByID(owner_extension_id);
80 80
81 std::string partition_domain, partition_id; 81 std::string partition_domain, partition_id;
82 bool in_memory; 82 bool in_memory;
83 std::string resource_path = url.path(); 83 std::string resource_path = url.path().as_string();
84 bool is_guest = WebViewGuest::GetGuestPartitionConfigForSite( 84 bool is_guest = WebViewGuest::GetGuestPartitionConfigForSite(
85 navigation_handle()->GetStartingSiteInstance()->GetSiteURL(), 85 navigation_handle()->GetStartingSiteInstance()->GetSiteURL(),
86 &partition_domain, &partition_id, &in_memory); 86 &partition_domain, &partition_id, &in_memory);
87 87
88 bool allowed = true; 88 bool allowed = true;
89 url_request_util::AllowCrossRendererResourceLoadHelper( 89 url_request_util::AllowCrossRendererResourceLoadHelper(
90 is_guest, extension, owner_extension, partition_id, resource_path, 90 is_guest, extension, owner_extension, partition_id, resource_path,
91 navigation_handle()->GetPageTransition(), &allowed); 91 navigation_handle()->GetPageTransition(), &allowed);
92 if (!allowed) 92 if (!allowed)
93 return content::NavigationThrottle::CANCEL; 93 return content::NavigationThrottle::CANCEL;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 } 137 }
138 ancestor = ancestor->GetParent(); 138 ancestor = ancestor->GetParent();
139 } 139 }
140 140
141 if (!external_ancestor) 141 if (!external_ancestor)
142 return content::NavigationThrottle::PROCEED; 142 return content::NavigationThrottle::PROCEED;
143 143
144 // Since there was at least one origin different than the navigation URL, 144 // Since there was at least one origin different than the navigation URL,
145 // explicitly check for the resource in web_accessible_resources. 145 // explicitly check for the resource in web_accessible_resources.
146 std::string resource_path = url.path(); 146 base::StringPiece resource_path = url.path();
147 if (!registry) 147 if (!registry)
148 return content::NavigationThrottle::BLOCK_REQUEST; 148 return content::NavigationThrottle::BLOCK_REQUEST;
149 149
150 const extensions::Extension* extension = 150 const extensions::Extension* extension =
151 registry->enabled_extensions().GetByID(url.host()); 151 registry->enabled_extensions().GetByID(url.host());
152 if (!extension) 152 if (!extension)
153 return content::NavigationThrottle::BLOCK_REQUEST; 153 return content::NavigationThrottle::BLOCK_REQUEST;
154 154
155 if (WebAccessibleResourcesInfo::IsResourceWebAccessible(extension, 155 if (WebAccessibleResourcesInfo::IsResourceWebAccessible(
156 resource_path)) { 156 extension, resource_path.as_string())) {
157 return content::NavigationThrottle::PROCEED; 157 return content::NavigationThrottle::PROCEED;
158 } 158 }
159 159
160 return content::NavigationThrottle::BLOCK_REQUEST; 160 return content::NavigationThrottle::BLOCK_REQUEST;
161 } 161 }
162 162
163 } // namespace extensions 163 } // namespace extensions
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/layout_test_browser_context.cc ('k') | extensions/browser/extension_protocols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698