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

Unified Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 2459143002: Avoid GURL allocations/copies/frees in RenderFrameImpl::willSendRequest (Closed)
Patch Set: s/host/host_piece 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/chrome_content_renderer_client.cc
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 0a1c0741bb5e38e48247310aa1e13420113e08d8..0a89b4d677a78b9a6691e90a11d319e1d3c56beb 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -1121,11 +1121,10 @@ bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
bool ChromeContentRendererClient::WillSendRequest(
WebFrame* frame,
ui::PageTransition transition_type,
- const GURL& url,
- const GURL& first_party_for_cookies,
+ const blink::WebURL& url,
GURL* new_url) {
- // Check whether the request should be allowed. If not allowed, we reset the
- // URL to something invalid to prevent the request and cause an error.
+// Check whether the request should be allowed. If not allowed, we reset the
+// URL to something invalid to prevent the request and cause an error.
#if defined(ENABLE_EXTENSIONS)
if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest(
frame, transition_type, url, new_url)) {
@@ -1133,18 +1132,23 @@ bool ChromeContentRendererClient::WillSendRequest(
}
#endif
+ if (!url.protocolIs(chrome::kChromeSearchScheme))
+ return false;
+
const content::RenderView* render_view =
content::RenderView::FromWebView(frame->view());
SearchBox* search_box = SearchBox::Get(render_view);
- if (search_box && url.SchemeIs(chrome::kChromeSearchScheme)) {
+ if (search_box) {
+ // Note: this GURL copy could be avoided if host() were added to WebURL.
+ GURL gurl(url);
SearchBox::ImageSourceType type = SearchBox::NONE;
- if (url.host() == chrome::kChromeUIFaviconHost)
+ if (gurl.host_piece() == chrome::kChromeUIFaviconHost)
type = SearchBox::FAVICON;
- else if (url.host() == chrome::kChromeUILargeIconHost)
+ else if (gurl.host_piece() == chrome::kChromeUILargeIconHost)
type = SearchBox::LARGE_ICON;
- else if (url.host() == chrome::kChromeUIFallbackIconHost)
+ else if (gurl.host_piece() == chrome::kChromeUIFallbackIconHost)
type = SearchBox::FALLBACK_ICON;
- else if (url.host() == chrome::kChromeUIThumbnailHost)
+ else if (gurl.host_piece() == chrome::kChromeUIThumbnailHost)
type = SearchBox::THUMB;
if (type != SearchBox::NONE)
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | chrome/renderer/extensions/chrome_extensions_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698