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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 15388002: Supporting high dpi favicons in Instant Extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moving reusable pieces to chrome/common Created 7 years, 7 months 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 | Annotate | Revision Log
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/strings/string_number_conversions.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/common/child_process_logging.h" 15 #include "chrome/common/child_process_logging.h"
15 #include "chrome/common/chrome_content_client.h" 16 #include "chrome/common/chrome_content_client.h"
16 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/content_settings_pattern.h" 19 #include "chrome/common/content_settings_pattern.h"
19 #include "chrome/common/extensions/chrome_manifest_handlers.h" 20 #include "chrome/common/extensions/chrome_manifest_handlers.h"
20 #include "chrome/common/extensions/extension.h" 21 #include "chrome/common/extensions/extension.h"
21 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
22 #include "chrome/common/extensions/extension_manifest_constants.h" 23 #include "chrome/common/extensions/extension_manifest_constants.h"
23 #include "chrome/common/extensions/extension_process_policy.h" 24 #include "chrome/common/extensions/extension_process_policy.h"
24 #include "chrome/common/extensions/extension_set.h" 25 #include "chrome/common/extensions/extension_set.h"
25 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" 26 #include "chrome/common/extensions/permissions/chrome_api_permissions.h"
26 #include "chrome/common/external_ipc_fuzzer.h" 27 #include "chrome/common/external_ipc_fuzzer.h"
28 #include "chrome/common/favicon_types.h"
29 #include "chrome/common/favicon_url_parser.h"
27 #include "chrome/common/localized_error.h" 30 #include "chrome/common/localized_error.h"
28 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
29 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
30 #include "chrome/renderer/benchmarking_extension.h" 33 #include "chrome/renderer/benchmarking_extension.h"
31 #include "chrome/renderer/chrome_render_process_observer.h" 34 #include "chrome/renderer/chrome_render_process_observer.h"
32 #include "chrome/renderer/chrome_render_view_observer.h" 35 #include "chrome/renderer/chrome_render_view_observer.h"
33 #include "chrome/renderer/content_settings_observer.h" 36 #include "chrome/renderer/content_settings_observer.h"
34 #include "chrome/renderer/extensions/chrome_v8_context.h" 37 #include "chrome/renderer/extensions/chrome_v8_context.h"
35 #include "chrome/renderer/extensions/chrome_v8_extension.h" 38 #include "chrome/renderer/extensions/chrome_v8_extension.h"
36 #include "chrome/renderer/extensions/dispatcher.h" 39 #include "chrome/renderer/extensions/dispatcher.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Treat CDM invocations like JavaScript. 196 // Treat CDM invocations like JavaScript.
194 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) { 197 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) {
195 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); 198 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS);
196 return true; 199 return true;
197 } 200 }
198 #endif // WIDEVINE_CDM_AVAILABLE 201 #endif // WIDEVINE_CDM_AVAILABLE
199 202
200 return false; 203 return false;
201 } 204 }
202 205
206 content::RenderView* GetRenderViewFromWebFrame(WebKit::WebFrame* webframe) {
207 if (!webframe)
208 return NULL;
209 WebKit::WebView* webview = webframe->view();
210 if (!webview)
211 return NULL;
212 return content::RenderView::FromWebView(webview);
213 }
214
203 } // namespace 215 } // namespace
204 216
205 namespace chrome { 217 namespace chrome {
206 218
207 ChromeContentRendererClient::ChromeContentRendererClient() { 219 ChromeContentRendererClient::ChromeContentRendererClient() {
208 g_current_client = this; 220 g_current_client = this;
209 } 221 }
210 222
211 ChromeContentRendererClient::~ChromeContentRendererClient() { 223 ChromeContentRendererClient::~ChromeContentRendererClient() {
212 g_current_client = NULL; 224 g_current_client = NULL;
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 } 990 }
979 991
980 if (url.SchemeIs(chrome::kExtensionResourceScheme) && 992 if (url.SchemeIs(chrome::kExtensionResourceScheme) &&
981 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( 993 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme(
982 url, 994 url,
983 frame)) { 995 frame)) {
984 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); 996 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL);
985 return true; 997 return true;
986 } 998 }
987 999
1000 const content::RenderView* render_view = GetRenderViewFromWebFrame(frame);
1001 if (SearchBox* search_box = SearchBox::Get(render_view)) {
1002
1003 if (url.SchemeIs(chrome::kChromeSearchScheme) &&
1004 (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.
1005
1006 // TODO(pedrosimonetti): DO NOT SUBMIT
1007 LOG(ERROR) << "~~~~~~~~~~~~~ ::WillSendRequest " << url.spec();
1008
1009 // Strip leading slash.
1010 std::string raw_path = url.path().substr(1);
1011 std::string params = "";
1012 bool success = true;
1013
1014 if (url.host() == "favicon") {
1015 std::string favicon_url;
1016 bool is_icon_url = false;
1017 int size_in_dip = 16;
1018 ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P;
1019
1020 success = chrome::ParseFaviconPath(raw_path, false, chrome::FAVICON,
1021 &is_icon_url, &favicon_url, &size_in_dip, &scale_factor, &params);
1022 // Now that the favicon URL has been parsed, update |raw_path| with
1023 // |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.
1024 // item in Instant Extended (which would normally be the URL whose
1025 // 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.
1026 raw_path = favicon_url;
1027 }
1028
1029 // Try to convert the |raw_path| to int, which is expected to be the id
1030 // of a Most Visited item, and then check if there is a Most Visited item
1031 // with that id.
1032 InstantRestrictedID id;
1033 InstantMostVisitedItem item;
1034 if (success &&
1035 base::StringToInt(raw_path, &id) &&
1036 search_box->GetMostVisitedItemWithID(id, &item)) {
1037 // Translate the resource URL replacing the id with the URL of the Most
1038 // Visited item associated with it. The |params| variable will ensure
1039 // that advanced favicon parameters are preserved, allowing high dpi
1040 // favicons to be served from chrome-search schema.
1041 GURL item_url = item.url;
1042 std::string translated_url = url.GetOrigin().spec() + params +
1043 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.
1044 *new_url = GURL(translated_url);
1045 // TODO(pedrosimonetti): DO NOT SUBMIT
1046 LOG(ERROR) << "OK: " << translated_url;
1047 return true;
1048 } else {
1049 *new_url = GURL(chrome::kChromeSearchInvalidRequestUrl);
1050 // TODO(pedrosimonetti): DO NOT SUBMIT
1051 LOG(ERROR) << "FAIL: " << url.spec();
1052 return true;
1053 }
1054 }
1055 }
1056
988 return false; 1057 return false;
989 } 1058 }
990 1059
991 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { 1060 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() {
992 // We no longer pump messages, even under Chrome Frame. We rely on cookie 1061 // We no longer pump messages, even under Chrome Frame. We rely on cookie
993 // read requests handled by CF not putting up UI or causing other actions 1062 // read requests handled by CF not putting up UI or causing other actions
994 // that would require us to pump messages. This fixes http://crbug.com/110090. 1063 // that would require us to pump messages. This fixes http://crbug.com/110090.
995 return false; 1064 return false;
996 } 1065 }
997 1066
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 1248
1180 if (container->element().shadowHost().isNull()) 1249 if (container->element().shadowHost().isNull())
1181 return false; 1250 return false;
1182 1251
1183 WebString tag_name = container->element().shadowHost().tagName(); 1252 WebString tag_name = container->element().shadowHost().tagName();
1184 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || 1253 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) ||
1185 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); 1254 tag_name.equals(WebString::fromUTF8(kAdViewTagName));
1186 } 1255 }
1187 1256
1188 } // namespace chrome 1257 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698