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 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // Treat CDM invocations like JavaScript. | 216 // Treat CDM invocations like JavaScript. |
217 if (plugin.name == ASCIIToUTF16(kWidevineCdmPluginName)) { | 217 if (plugin.name == ASCIIToUTF16(kWidevineCdmPluginName)) { |
218 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); | 218 DCHECK(plugin.type == WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS); |
219 return true; | 219 return true; |
220 } | 220 } |
221 #endif // WIDEVINE_CDM_AVAILABLE | 221 #endif // WIDEVINE_CDM_AVAILABLE |
222 | 222 |
223 return false; | 223 return false; |
224 } | 224 } |
225 | 225 |
226 content::RenderView* GetRenderViewFromWebFrame(WebKit::WebFrame* webframe) { | |
227 if (!webframe) | |
228 return NULL; | |
229 WebKit::WebView* webview = webframe->view(); | |
230 if (!webview) | |
231 return NULL; | |
232 return content::RenderView::FromWebView(webview); | |
233 } | |
234 | |
235 } // namespace | 226 } // namespace |
236 | 227 |
237 namespace chrome { | 228 namespace chrome { |
238 | 229 |
239 ChromeContentRendererClient::ChromeContentRendererClient() { | 230 ChromeContentRendererClient::ChromeContentRendererClient() { |
240 g_current_client = this; | 231 g_current_client = this; |
241 } | 232 } |
242 | 233 |
243 ChromeContentRendererClient::~ChromeContentRendererClient() { | 234 ChromeContentRendererClient::~ChromeContentRendererClient() { |
244 g_current_client = NULL; | 235 g_current_client = NULL; |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 } | 993 } |
1003 | 994 |
1004 if (url.SchemeIs(chrome::kExtensionResourceScheme) && | 995 if (url.SchemeIs(chrome::kExtensionResourceScheme) && |
1005 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( | 996 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( |
1006 url, | 997 url, |
1007 frame)) { | 998 frame)) { |
1008 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); | 999 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); |
1009 return true; | 1000 return true; |
1010 } | 1001 } |
1011 | 1002 |
1012 const content::RenderView* render_view = GetRenderViewFromWebFrame(frame); | 1003 if (url.SchemeIs(chrome::kChromeSearchScheme) && |
1013 if (SearchBox* search_box = SearchBox::Get(render_view)) { | 1004 url.host() == chrome::kChromeSearchSuggestionHost) { |
1014 if (url.SchemeIs(chrome::kChromeSearchScheme) && | 1005 GURL top_url(frame->top()->document().url()); |
1015 url.host() == chrome::kChromeSearchSuggestionHost) { | 1006 *new_url = SetOriginForSuggestionRequest(url, top_url); |
1016 if (search_box->GenerateDataURLForSuggestionRequest(url, new_url)) | 1007 return true; |
1017 return true; | |
1018 } | |
1019 } | 1008 } |
1020 | 1009 |
1021 return false; | 1010 return false; |
1022 } | 1011 } |
1023 | 1012 |
1024 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { | 1013 bool ChromeContentRendererClient::ShouldPumpEventsDuringCookieMessage() { |
1025 // We no longer pump messages, even under Chrome Frame. We rely on cookie | 1014 // We no longer pump messages, even under Chrome Frame. We rely on cookie |
1026 // read requests handled by CF not putting up UI or causing other actions | 1015 // read requests handled by CF not putting up UI or causing other actions |
1027 // that would require us to pump messages. This fixes http://crbug.com/110090. | 1016 // that would require us to pump messages. This fixes http://crbug.com/110090. |
1028 return false; | 1017 return false; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 } | 1229 } |
1241 | 1230 |
1242 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { | 1231 for (size_t i = 0; i < request_os_file_handle_allowed_hosts_.size(); ++i) { |
1243 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) | 1232 if (MatchPattern(inner.host(), request_os_file_handle_allowed_hosts_[i])) |
1244 return true; | 1233 return true; |
1245 } | 1234 } |
1246 | 1235 |
1247 return false; | 1236 return false; |
1248 } | 1237 } |
1249 | 1238 |
| 1239 GURL ChromeContentRendererClient::SetOriginForSuggestionRequest( |
| 1240 const GURL& url, |
| 1241 const GURL& top_url) const { |
| 1242 // Note that this replaces any existing query string parameters, including |
| 1243 // any existing &origin parameter. |
| 1244 GURL::Replacements set_origin; |
| 1245 std::string query_str = "origin="; |
| 1246 query_str.append(top_url.GetOrigin().spec()); |
| 1247 // Origin should not include a trailing slash. That is part of the path. |
| 1248 TrimString(query_str, "/", &query_str); |
| 1249 set_origin.SetQueryStr(query_str); |
| 1250 return url.ReplaceComponents(set_origin); |
| 1251 } |
| 1252 |
1250 } // namespace chrome | 1253 } // namespace chrome |
OLD | NEW |