Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 if (should_fork) | 1115 if (should_fork) |
| 1116 return true; | 1116 return true; |
| 1117 #endif // defined(ENABLE_EXTENSIONS) | 1117 #endif // defined(ENABLE_EXTENSIONS) |
| 1118 | 1118 |
| 1119 return false; | 1119 return false; |
| 1120 } | 1120 } |
| 1121 | 1121 |
| 1122 bool ChromeContentRendererClient::WillSendRequest( | 1122 bool ChromeContentRendererClient::WillSendRequest( |
| 1123 WebFrame* frame, | 1123 WebFrame* frame, |
| 1124 ui::PageTransition transition_type, | 1124 ui::PageTransition transition_type, |
| 1125 const GURL& url, | 1125 const blink::WebURL& url, |
| 1126 const GURL& first_party_for_cookies, | |
| 1127 GURL* new_url) { | 1126 GURL* new_url) { |
| 1128 // Check whether the request should be allowed. If not allowed, we reset the | 1127 // Check whether the request should be allowed. If not allowed, we reset the |
| 1129 // URL to something invalid to prevent the request and cause an error. | 1128 // URL to something invalid to prevent the request and cause an error. |
| 1130 #if defined(ENABLE_EXTENSIONS) | 1129 #if defined(ENABLE_EXTENSIONS) |
| 1131 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( | 1130 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( |
| 1132 frame, transition_type, url, new_url)) { | 1131 frame, transition_type, url, new_url)) { |
| 1133 return true; | 1132 return true; |
| 1134 } | 1133 } |
| 1135 #endif | 1134 #endif |
| 1136 | 1135 |
| 1136 // Early exit before fetching the RenderView or SearchBox. | |
|
Devlin
2016/10/31 15:17:39
optional nit: This comment doesn't seem to add muc
Charlie Harrison
2016/10/31 15:46:13
Done.
| |
| 1137 if (!url.protocolIs(chrome::kChromeSearchScheme)) | |
| 1138 return false; | |
| 1139 | |
| 1137 const content::RenderView* render_view = | 1140 const content::RenderView* render_view = |
| 1138 content::RenderView::FromWebView(frame->view()); | 1141 content::RenderView::FromWebView(frame->view()); |
| 1139 SearchBox* search_box = SearchBox::Get(render_view); | 1142 SearchBox* search_box = SearchBox::Get(render_view); |
| 1140 if (search_box && url.SchemeIs(chrome::kChromeSearchScheme)) { | 1143 if (search_box) { |
| 1144 // Note: this GURL copy could be avoided if host() were added to WebURL. | |
| 1145 GURL gurl(url); | |
| 1141 SearchBox::ImageSourceType type = SearchBox::NONE; | 1146 SearchBox::ImageSourceType type = SearchBox::NONE; |
| 1142 if (url.host() == chrome::kChromeUIFaviconHost) | 1147 if (gurl.host() == chrome::kChromeUIFaviconHost) |
| 1143 type = SearchBox::FAVICON; | 1148 type = SearchBox::FAVICON; |
| 1144 else if (url.host() == chrome::kChromeUILargeIconHost) | 1149 else if (gurl.host() == chrome::kChromeUILargeIconHost) |
| 1145 type = SearchBox::LARGE_ICON; | 1150 type = SearchBox::LARGE_ICON; |
| 1146 else if (url.host() == chrome::kChromeUIFallbackIconHost) | 1151 else if (gurl.host() == chrome::kChromeUIFallbackIconHost) |
| 1147 type = SearchBox::FALLBACK_ICON; | 1152 type = SearchBox::FALLBACK_ICON; |
| 1148 else if (url.host() == chrome::kChromeUIThumbnailHost) | 1153 else if (gurl.host() == chrome::kChromeUIThumbnailHost) |
| 1149 type = SearchBox::THUMB; | 1154 type = SearchBox::THUMB; |
| 1150 | 1155 |
| 1151 if (type != SearchBox::NONE) | 1156 if (type != SearchBox::NONE) |
| 1152 return search_box->GenerateImageURLFromTransientURL(url, type, new_url); | 1157 return search_box->GenerateImageURLFromTransientURL(url, type, new_url); |
| 1153 } | 1158 } |
| 1154 | 1159 |
| 1155 return false; | 1160 return false; |
| 1156 } | 1161 } |
| 1157 | 1162 |
| 1158 bool ChromeContentRendererClient::IsPrefetchOnly( | 1163 bool ChromeContentRendererClient::IsPrefetchOnly( |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1486 | 1491 |
| 1487 url::Replacements<char> r; | 1492 url::Replacements<char> r; |
| 1488 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1493 r.SetPath(path.c_str(), url::Component(0, path.length())); |
| 1489 | 1494 |
| 1490 if (result == internal::NUM_PLUGIN_ERROR) | 1495 if (result == internal::NUM_PLUGIN_ERROR) |
| 1491 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; | 1496 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; |
| 1492 | 1497 |
| 1493 RecordYouTubeRewriteUMA(result); | 1498 RecordYouTubeRewriteUMA(result); |
| 1494 return corrected_url.ReplaceComponents(r); | 1499 return corrected_url.ReplaceComponents(r); |
| 1495 } | 1500 } |
| OLD | NEW |