Chromium Code Reviews| 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 2ace978b9fc6631e39009a547d62dee2465ebe6a..b01ded0433311b468e5709833319a0ae6bf8cba3 100644 |
| --- a/chrome/renderer/chrome_content_renderer_client.cc |
| +++ b/chrome/renderer/chrome_content_renderer_client.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/metrics/histogram.h" |
| #include "base/path_service.h" |
| #include "base/string_util.h" |
| +#include "base/strings/string_number_conversions.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| #include "chrome/common/child_process_logging.h" |
| @@ -24,6 +25,8 @@ |
| #include "chrome/common/extensions/extension_set.h" |
| #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
| #include "chrome/common/external_ipc_fuzzer.h" |
| +#include "chrome/common/favicon_types.h" |
| +#include "chrome/common/favicon_url_parser.h" |
| #include "chrome/common/localized_error.h" |
| #include "chrome/common/render_messages.h" |
| #include "chrome/common/url_constants.h" |
| @@ -200,6 +203,15 @@ bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) { |
| return false; |
| } |
| +content::RenderView* GetRenderViewFromWebFrame(WebKit::WebFrame* webframe) { |
| + if (!webframe) |
| + return NULL; |
| + WebKit::WebView* webview = webframe->view(); |
| + if (!webview) |
| + return NULL; |
| + return content::RenderView::FromWebView(webview); |
| +} |
| + |
| } // namespace |
| namespace chrome { |
| @@ -985,6 +997,63 @@ bool ChromeContentRendererClient::WillSendRequest( |
| return true; |
| } |
| + const content::RenderView* render_view = GetRenderViewFromWebFrame(frame); |
| + if (SearchBox* search_box = SearchBox::Get(render_view)) { |
| + |
| + if (url.SchemeIs(chrome::kChromeSearchScheme) && |
| + (url.host() == "thumb" || url.host() == "favicon")) { |
|
sreeram
2013/06/04 22:01:56
Use kChromeUIThumbnailHost, kChromeUIFaviconHost a
pedro (no code reviews)
2013/06/07 23:34:21
Done.
|
| + |
| + // TODO(pedrosimonetti): DO NOT SUBMIT |
| + LOG(ERROR) << "~~~~~~~~~~~~~ ::WillSendRequest " << url.spec(); |
| + |
| + // Strip leading slash. |
| + std::string raw_path = url.path().substr(1); |
| + std::string params = ""; |
| + bool success = true; |
| + |
| + if (url.host() == "favicon") { |
| + std::string favicon_url; |
| + bool is_icon_url = false; |
| + int size_in_dip = 16; |
| + ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P; |
| + |
| + success = chrome::ParseFaviconPath(raw_path, false, chrome::FAVICON, |
| + &is_icon_url, &favicon_url, &size_in_dip, &scale_factor, ¶ms); |
| + // Now that the favicon URL has been parsed, update |raw_path| with |
| + // |favicon_url| which it is expected to be the id of a Most Visited |
|
sreeram
2013/06/04 22:01:56
which it is -> which is
pedro (no code reviews)
2013/06/07 23:34:21
Done.
|
| + // item in Instant Extended (which would normally be the URL whose |
| + // favicon is being requested). |
|
sreeram
2013/06/04 22:01:56
This comment is kinda superfluous. Just delete it.
pedro (no code reviews)
2013/06/07 23:34:21
Done.
|
| + raw_path = favicon_url; |
| + } |
| + |
| + // Try to convert the |raw_path| to int, which is expected to be the id |
| + // of a Most Visited item, and then check if there is a Most Visited item |
| + // with that id. |
| + InstantRestrictedID id; |
| + InstantMostVisitedItem item; |
| + if (success && |
| + base::StringToInt(raw_path, &id) && |
| + search_box->GetMostVisitedItemWithID(id, &item)) { |
| + // Translate the resource URL replacing the id with the URL of the Most |
| + // Visited item associated with it. The |params| variable will ensure |
| + // that advanced favicon parameters are preserved, allowing high dpi |
| + // favicons to be served from chrome-search schema. |
| + GURL item_url = item.url; |
| + std::string translated_url = url.GetOrigin().spec() + params + |
| + item_url.spec(); |
|
sreeram
2013/06/04 22:01:56
Do you need to URL-escape the item_url?
pedro (no code reviews)
2013/06/07 23:34:21
Good question. I'm not sure if we need to do that.
|
| + *new_url = GURL(translated_url); |
| + // TODO(pedrosimonetti): DO NOT SUBMIT |
| + LOG(ERROR) << "OK: " << translated_url; |
| + return true; |
| + } else { |
| + *new_url = GURL(chrome::kChromeSearchInvalidRequestUrl); |
| + // TODO(pedrosimonetti): DO NOT SUBMIT |
| + LOG(ERROR) << "FAIL: " << url.spec(); |
| + return true; |
| + } |
| + } |
| + } |
| + |
| return false; |
| } |