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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/string_util.h" | |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "chrome/common/child_process_logging.h" | 17 #include "chrome/common/child_process_logging.h" |
17 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/content_settings_pattern.h" | 21 #include "chrome/common/content_settings_pattern.h" |
21 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" | 22 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" |
22 #include "chrome/common/extensions/background_info.h" | 23 #include "chrome/common/extensions/background_info.h" |
23 #include "chrome/common/extensions/csp_handler.h" | 24 #include "chrome/common/extensions/csp_handler.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 // Treat CDM invocations like JavaScript. | 211 // Treat CDM invocations like JavaScript. |
211 if (plugin.name == ASCIIToUTF16(kWidevineCdmPluginName)) { | 212 if (plugin.name == ASCIIToUTF16(kWidevineCdmPluginName)) { |
212 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); | 213 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); |
213 return true; | 214 return true; |
214 } | 215 } |
215 #endif // WIDEVINE_CDM_AVAILABLE | 216 #endif // WIDEVINE_CDM_AVAILABLE |
216 | 217 |
217 return false; | 218 return false; |
218 } | 219 } |
219 | 220 |
220 content::RenderView* GetRenderViewFromWebFrame(WebKit::WebFrame* webframe) { | |
221 if (!webframe) | |
222 return NULL; | |
223 WebKit::WebView* webview = webframe->view(); | |
224 if (!webview) | |
225 return NULL; | |
226 return content::RenderView::FromWebView(webview); | |
227 } | |
228 | |
229 } // namespace | 221 } // namespace |
230 | 222 |
231 namespace chrome { | 223 namespace chrome { |
232 | 224 |
233 ChromeContentRendererClient::ChromeContentRendererClient() { | 225 ChromeContentRendererClient::ChromeContentRendererClient() { |
234 } | 226 } |
235 | 227 |
236 ChromeContentRendererClient::~ChromeContentRendererClient() { | 228 ChromeContentRendererClient::~ChromeContentRendererClient() { |
237 } | 229 } |
238 | 230 |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
987 } | 979 } |
988 | 980 |
989 if (url.SchemeIs(chrome::kExtensionResourceScheme) && | 981 if (url.SchemeIs(chrome::kExtensionResourceScheme) && |
990 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( | 982 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( |
991 url, | 983 url, |
992 frame)) { | 984 frame)) { |
993 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); | 985 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); |
994 return true; | 986 return true; |
995 } | 987 } |
996 | 988 |
997 const content::RenderView* render_view = GetRenderViewFromWebFrame(frame); | 989 if (url.SchemeIs(chrome::kChromeSearchScheme) && |
998 if (SearchBox* search_box = SearchBox::Get(render_view)) { | 990 url.host() == chrome::kChromeSearchSuggestionHost) { |
999 if (url.SchemeIs(chrome::kChromeSearchScheme) && | 991 GURL top_url(frame->top()->document().url()); |
1000 url.host() == chrome::kChromeSearchSuggestionHost) { | 992 // Note that this replaces any existing &origin param. |
samarth
2013/04/02 23:26:58
This also replaces any other query params, but I s
Jered
2013/04/04 17:30:10
Done.
| |
1001 if (search_box->GenerateDataURLForSuggestionRequest(url, new_url)) | 993 GURL::Replacements set_origin; |
1002 return true; | 994 std::string query_str = "origin="; |
1003 } | 995 query_str.append(top_url.GetOrigin().spec()); |
996 // Origin should not include a trailing slash. That is part of the path. | |
997 TrimString(query_str, "/", &query_str); | |
998 set_origin.SetQueryStr(query_str); | |
999 *new_url = url.ReplaceComponents(set_origin); | |
1000 return true; | |
1004 } | 1001 } |
1005 | 1002 |
1006 return false; | 1003 return false; |
1007 } | 1004 } |
1008 | 1005 |
1009 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { | 1006 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { |
1010 // We no longer pump messages, even under Chrome Frame. We rely on cookie | 1007 // We no longer pump messages, even under Chrome Frame. We rely on cookie |
1011 // read requests handled by CF not putting up UI or causing other actions | 1008 // read requests handled by CF not putting up UI or causing other actions |
1012 // that would require us to pump messages. This fixes http://crbug.com/110090. | 1009 // that would require us to pump messages. This fixes http://crbug.com/110090. |
1013 return false; | 1010 return false; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 | 1185 |
1189 if (container->element().shadowHost().isNull()) | 1186 if (container->element().shadowHost().isNull()) |
1190 return false; | 1187 return false; |
1191 | 1188 |
1192 WebString tag_name = container->element().shadowHost().tagName(); | 1189 WebString tag_name = container->element().shadowHost().tagName(); |
1193 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1190 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
1194 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1191 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
1195 } | 1192 } |
1196 | 1193 |
1197 } // namespace chrome | 1194 } // namespace chrome |
OLD | NEW |