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 "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/instant_types.h" | |
| 27 #include "chrome/common/localized_error.h" | 29 #include "chrome/common/localized_error.h" |
| 28 #include "chrome/common/render_messages.h" | 30 #include "chrome/common/render_messages.h" |
| 29 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 30 #include "chrome/renderer/benchmarking_extension.h" | 32 #include "chrome/renderer/benchmarking_extension.h" |
| 31 #include "chrome/renderer/chrome_render_process_observer.h" | 33 #include "chrome/renderer/chrome_render_process_observer.h" |
| 32 #include "chrome/renderer/chrome_render_view_observer.h" | 34 #include "chrome/renderer/chrome_render_view_observer.h" |
| 33 #include "chrome/renderer/content_settings_observer.h" | 35 #include "chrome/renderer/content_settings_observer.h" |
| 34 #include "chrome/renderer/extensions/chrome_v8_context.h" | 36 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 35 #include "chrome/renderer/extensions/chrome_v8_extension.h" | 37 #include "chrome/renderer/extensions/chrome_v8_extension.h" |
| 36 #include "chrome/renderer/extensions/dispatcher.h" | 38 #include "chrome/renderer/extensions/dispatcher.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 // Treat CDM invocations like JavaScript. | 196 // Treat CDM invocations like JavaScript. |
| 195 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) { | 197 if (plugin.name == ASCIIToUTF16(kWidevineCdmDisplayName)) { |
| 196 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); | 198 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); |
| 197 return true; | 199 return true; |
| 198 } | 200 } |
| 199 #endif // WIDEVINE_CDM_AVAILABLE | 201 #endif // WIDEVINE_CDM_AVAILABLE |
| 200 | 202 |
| 201 return false; | 203 return false; |
| 202 } | 204 } |
| 203 | 205 |
| 206 // Parses |url| and fills in |id| with the InstantRestrictedID obtained from the | |
| 207 // |url|. |render_view_id| is the ID of the associated RenderView. | |
| 208 // | |
| 209 // Valid |url| forms: | |
| 210 // chrome-search://favicon/<view_id>/<restriced_id> or | |
| 211 // chrome-search://thumb/<view_id>/<restricted_id> | |
| 212 // | |
| 213 // If the |url| is valid, returns true and fills in |id| with restricted_id | |
| 214 // value. If the |url| is invalid, returns false and |id| is not set. | |
| 215 bool GetInstantRestrictedIDFromURL(int render_view_id, | |
|
Jered
2013/06/04 23:27:23
I realized this function might make more sense in
kmadhusu
2013/06/05 00:48:30
Moved to SearchBox.
| |
| 216 const GURL& url, | |
| 217 InstantRestrictedID* id) { | |
| 218 // Strip leading slash. | |
| 219 std::string path = url.path().substr(1); | |
| 220 | |
| 221 // Check that the path is of Most visited item ID form. | |
| 222 std::vector<std::string> tokens; | |
| 223 if (Tokenize(path, "/", &tokens) != 2) | |
| 224 return false; | |
| 225 | |
| 226 int view_id = 0; | |
| 227 if (!base::StringToInt(tokens[0], &view_id) || view_id != render_view_id) | |
| 228 return false; | |
| 229 return base::StringToInt(tokens[1], id); | |
| 230 } | |
| 231 | |
| 232 content::RenderView* GetRenderViewFromWebFrame(WebKit::WebFrame* frame) { | |
| 233 if (!frame) | |
| 234 return NULL; | |
| 235 | |
| 236 WebKit::WebView* view = frame->view(); | |
| 237 if (!view) | |
| 238 return NULL; | |
| 239 return content::RenderView::FromWebView(view); | |
| 240 } | |
| 241 | |
| 204 } // namespace | 242 } // namespace |
| 205 | 243 |
| 206 namespace chrome { | 244 namespace chrome { |
| 207 | 245 |
| 208 ChromeContentRendererClient::ChromeContentRendererClient() { | 246 ChromeContentRendererClient::ChromeContentRendererClient() { |
| 209 g_current_client = this; | 247 g_current_client = this; |
| 210 } | 248 } |
| 211 | 249 |
| 212 ChromeContentRendererClient::~ChromeContentRendererClient() { | 250 ChromeContentRendererClient::~ChromeContentRendererClient() { |
| 213 g_current_client = NULL; | 251 g_current_client = NULL; |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 } | 1023 } |
| 986 | 1024 |
| 987 if (url.SchemeIs(chrome::kExtensionResourceScheme) && | 1025 if (url.SchemeIs(chrome::kExtensionResourceScheme) && |
| 988 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( | 1026 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( |
| 989 url, | 1027 url, |
| 990 frame)) { | 1028 frame)) { |
| 991 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); | 1029 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); |
| 992 return true; | 1030 return true; |
| 993 } | 1031 } |
| 994 | 1032 |
| 1033 const content::RenderView* render_view = GetRenderViewFromWebFrame(frame); | |
| 1034 if (SearchBox* search_box = SearchBox::Get(render_view)) { | |
| 1035 if (url.SchemeIs(chrome::kChromeSearchScheme)) { | |
| 1036 if (url.host() == chrome::kChromeUIThumbnailHost) { | |
| 1037 InstantRestrictedID rid = 0; | |
| 1038 return GetInstantRestrictedIDFromURL(render_view->GetRoutingID(), url, | |
|
Jered
2013/06/04 23:19:20
If the rewrite fails, we'll send a bad URL to chro
kmadhusu
2013/06/05 00:48:30
If rewrite fails, we will send a bad URL to Favico
| |
| 1039 &rid) && | |
| 1040 search_box->GenerateThumbnailURLFromRID(rid, new_url); | |
| 1041 } else if (url.host() == chrome::kChromeUIFaviconHost) { | |
| 1042 InstantRestrictedID rid = 0; | |
| 1043 return GetInstantRestrictedIDFromURL(render_view->GetRoutingID(), url, | |
| 1044 &rid) && | |
| 1045 search_box->GenerateFaviconURLFromRID(rid, new_url); | |
| 1046 } | |
| 1047 } | |
| 1048 } | |
| 1049 | |
| 995 return false; | 1050 return false; |
| 996 } | 1051 } |
| 997 | 1052 |
| 998 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { | 1053 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { |
| 999 // We no longer pump messages, even under Chrome Frame. We rely on cookie | 1054 // We no longer pump messages, even under Chrome Frame. We rely on cookie |
| 1000 // read requests handled by CF not putting up UI or causing other actions | 1055 // read requests handled by CF not putting up UI or causing other actions |
| 1001 // that would require us to pump messages. This fixes http://crbug.com/110090. | 1056 // that would require us to pump messages. This fixes http://crbug.com/110090. |
| 1002 return false; | 1057 return false; |
| 1003 } | 1058 } |
| 1004 | 1059 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 | 1249 |
| 1195 if (container->element().shadowHost().isNull()) | 1250 if (container->element().shadowHost().isNull()) |
| 1196 return false; | 1251 return false; |
| 1197 | 1252 |
| 1198 WebString tag_name = container->element().shadowHost().tagName(); | 1253 WebString tag_name = container->element().shadowHost().tagName(); |
| 1199 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1254 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
| 1200 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1255 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
| 1201 } | 1256 } |
| 1202 | 1257 |
| 1203 } // namespace chrome | 1258 } // namespace chrome |
| OLD | NEW |