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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/renderer/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 if (should_fork) 1114 if (should_fork)
1115 return true; 1115 return true;
1116 #endif // defined(ENABLE_EXTENSIONS) 1116 #endif // defined(ENABLE_EXTENSIONS)
1117 1117
1118 return false; 1118 return false;
1119 } 1119 }
1120 1120
1121 bool ChromeContentRendererClient::WillSendRequest( 1121 bool ChromeContentRendererClient::WillSendRequest(
1122 WebFrame* frame, 1122 WebFrame* frame,
1123 ui::PageTransition transition_type, 1123 ui::PageTransition transition_type,
1124 const GURL& url, 1124 const blink::WebURL& url,
1125 const GURL& first_party_for_cookies,
1126 GURL* new_url) { 1125 GURL* new_url) {
1127 // Check whether the request should be allowed. If not allowed, we reset the 1126 // Check whether the request should be allowed. If not allowed, we reset the
1128 // URL to something invalid to prevent the request and cause an error. 1127 // URL to something invalid to prevent the request and cause an error.
1129 #if defined(ENABLE_EXTENSIONS) 1128 #if defined(ENABLE_EXTENSIONS)
1130 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( 1129 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest(
1131 frame, transition_type, url, new_url)) { 1130 frame, transition_type, url, new_url)) {
1132 return true; 1131 return true;
1133 } 1132 }
1134 #endif 1133 #endif
1135 1134
1135 if (!url.protocolIs(chrome::kChromeSearchScheme))
1136 return false;
1137
1136 const content::RenderView* render_view = 1138 const content::RenderView* render_view =
1137 content::RenderView::FromWebView(frame->view()); 1139 content::RenderView::FromWebView(frame->view());
1138 SearchBox* search_box = SearchBox::Get(render_view); 1140 SearchBox* search_box = SearchBox::Get(render_view);
1139 if (search_box && url.SchemeIs(chrome::kChromeSearchScheme)) { 1141 if (search_box) {
1142 // Note: this GURL copy could be avoided if host() were added to WebURL.
1143 GURL gurl(url);
1140 SearchBox::ImageSourceType type = SearchBox::NONE; 1144 SearchBox::ImageSourceType type = SearchBox::NONE;
1141 if (url.host() == chrome::kChromeUIFaviconHost) 1145 if (gurl.host_piece() == chrome::kChromeUIFaviconHost)
1142 type = SearchBox::FAVICON; 1146 type = SearchBox::FAVICON;
1143 else if (url.host() == chrome::kChromeUILargeIconHost) 1147 else if (gurl.host_piece() == chrome::kChromeUILargeIconHost)
1144 type = SearchBox::LARGE_ICON; 1148 type = SearchBox::LARGE_ICON;
1145 else if (url.host() == chrome::kChromeUIFallbackIconHost) 1149 else if (gurl.host_piece() == chrome::kChromeUIFallbackIconHost)
1146 type = SearchBox::FALLBACK_ICON; 1150 type = SearchBox::FALLBACK_ICON;
1147 else if (url.host() == chrome::kChromeUIThumbnailHost) 1151 else if (gurl.host_piece() == chrome::kChromeUIThumbnailHost)
1148 type = SearchBox::THUMB; 1152 type = SearchBox::THUMB;
1149 1153
1150 if (type != SearchBox::NONE) 1154 if (type != SearchBox::NONE)
1151 return search_box->GenerateImageURLFromTransientURL(url, type, new_url); 1155 return search_box->GenerateImageURLFromTransientURL(url, type, new_url);
1152 } 1156 }
1153 1157
1154 return false; 1158 return false;
1155 } 1159 }
1156 1160
1157 bool ChromeContentRendererClient::IsPrefetchOnly( 1161 bool ChromeContentRendererClient::IsPrefetchOnly(
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 1482
1479 url::Replacements<char> r; 1483 url::Replacements<char> r;
1480 r.SetPath(path.c_str(), url::Component(0, path.length())); 1484 r.SetPath(path.c_str(), url::Component(0, path.length()));
1481 1485
1482 if (result == internal::NUM_PLUGIN_ERROR) 1486 if (result == internal::NUM_PLUGIN_ERROR)
1483 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; 1487 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS;
1484 1488
1485 RecordYouTubeRewriteUMA(result); 1489 RecordYouTubeRewriteUMA(result);
1486 return corrected_url.ReplaceComponents(r); 1490 return corrected_url.ReplaceComponents(r);
1487 } 1491 }
OLDNEW
« 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