| 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/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 using blink::WebString; | 152 using blink::WebString; |
| 153 using blink::WebURL; | 153 using blink::WebURL; |
| 154 using blink::WebURLError; | 154 using blink::WebURLError; |
| 155 using blink::WebURLRequest; | 155 using blink::WebURLRequest; |
| 156 using blink::WebURLResponse; | 156 using blink::WebURLResponse; |
| 157 using blink::WebVector; | 157 using blink::WebVector; |
| 158 | 158 |
| 159 namespace { | 159 namespace { |
| 160 | 160 |
| 161 const char kWebViewTagName[] = "WEBVIEW"; | 161 const char kWebViewTagName[] = "WEBVIEW"; |
| 162 const char kAdViewTagName[] = "ADVIEW"; | |
| 163 | 162 |
| 164 ChromeContentRendererClient* g_current_client; | 163 ChromeContentRendererClient* g_current_client; |
| 165 | 164 |
| 166 static void AppendParams(const std::vector<base::string16>& additional_names, | 165 static void AppendParams(const std::vector<base::string16>& additional_names, |
| 167 const std::vector<base::string16>& additional_values, | 166 const std::vector<base::string16>& additional_values, |
| 168 WebVector<WebString>* existing_names, | 167 WebVector<WebString>* existing_names, |
| 169 WebVector<WebString>* existing_values) { | 168 WebVector<WebString>* existing_values) { |
| 170 DCHECK(additional_names.size() == additional_values.size()); | 169 DCHECK(additional_names.size() == additional_values.size()); |
| 171 DCHECK(existing_names->size() == existing_values->size()); | 170 DCHECK(existing_names->size() == existing_values->size()); |
| 172 | 171 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 const WebPluginParams& params, | 494 const WebPluginParams& params, |
| 496 WebPlugin** plugin) { | 495 WebPlugin** plugin) { |
| 497 std::string orig_mime_type = params.mimeType.utf8(); | 496 std::string orig_mime_type = params.mimeType.utf8(); |
| 498 if (orig_mime_type == content::kBrowserPluginMimeType) { | 497 if (orig_mime_type == content::kBrowserPluginMimeType) { |
| 499 WebDocument document = frame->document(); | 498 WebDocument document = frame->document(); |
| 500 const Extension* extension = | 499 const Extension* extension = |
| 501 GetExtensionByOrigin(document.securityOrigin()); | 500 GetExtensionByOrigin(document.securityOrigin()); |
| 502 if (extension) { | 501 if (extension) { |
| 503 const extensions::APIPermission::ID perms[] = { | 502 const extensions::APIPermission::ID perms[] = { |
| 504 extensions::APIPermission::kWebView, | 503 extensions::APIPermission::kWebView, |
| 505 extensions::APIPermission::kAdView | |
| 506 }; | 504 }; |
| 507 for (size_t i = 0; i < arraysize(perms); ++i) { | 505 for (size_t i = 0; i < arraysize(perms); ++i) { |
| 508 if (extension->permissions_data()->HasAPIPermission(perms[i])) | 506 if (extension->permissions_data()->HasAPIPermission(perms[i])) |
| 509 return false; | 507 return false; |
| 510 } | 508 } |
| 511 } | 509 } |
| 512 } | 510 } |
| 513 | 511 |
| 514 ChromeViewHostMsg_GetPluginInfo_Output output; | 512 ChromeViewHostMsg_GetPluginInfo_Output output; |
| 515 #if defined(ENABLE_PLUGINS) | 513 #if defined(ENABLE_PLUGINS) |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 | 1388 |
| 1391 blink::WebSpeechSynthesizer* | 1389 blink::WebSpeechSynthesizer* |
| 1392 ChromeContentRendererClient::OverrideSpeechSynthesizer( | 1390 ChromeContentRendererClient::OverrideSpeechSynthesizer( |
| 1393 blink::WebSpeechSynthesizerClient* client) { | 1391 blink::WebSpeechSynthesizerClient* client) { |
| 1394 return new TtsDispatcher(client); | 1392 return new TtsDispatcher(client); |
| 1395 } | 1393 } |
| 1396 | 1394 |
| 1397 bool ChromeContentRendererClient::AllowBrowserPlugin( | 1395 bool ChromeContentRendererClient::AllowBrowserPlugin( |
| 1398 blink::WebPluginContainer* container) { | 1396 blink::WebPluginContainer* container) { |
| 1399 // If this |BrowserPlugin| <object> in the |container| is not inside a | 1397 // If this |BrowserPlugin| <object> in the |container| is not inside a |
| 1400 // <webview>/<adview> shadowHost, we disable instantiating this plugin. This | 1398 // <webview> shadowHost, we disable instantiating this plugin. This |
| 1401 // is to discourage and prevent developers from accidentally attaching | 1399 // is to discourage and prevent developers from accidentally attaching |
| 1402 // <object> directly in apps. | 1400 // <object> directly in apps. |
| 1403 // | 1401 // |
| 1404 // Note that this check below does *not* ensure any security, it is still | 1402 // Note that this check below does *not* ensure any security, it is still |
| 1405 // possible to bypass this check. | 1403 // possible to bypass this check. |
| 1406 // TODO(lazyboy): http://crbug.com/178663, Ensure we properly disallow | 1404 // TODO(lazyboy): http://crbug.com/178663, Ensure we properly disallow |
| 1407 // instantiating BrowserPlugin outside of the <webview>/<adview> shim. | 1405 // instantiating BrowserPlugin outside of the <webview> shim. |
| 1408 if (container->element().isNull()) | 1406 if (container->element().isNull()) |
| 1409 return false; | 1407 return false; |
| 1410 | 1408 |
| 1411 if (container->element().shadowHost().isNull()) | 1409 if (container->element().shadowHost().isNull()) |
| 1412 return false; | 1410 return false; |
| 1413 | 1411 |
| 1414 WebString tag_name = container->element().shadowHost().tagName(); | 1412 WebString tag_name = container->element().shadowHost().tagName(); |
| 1415 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1413 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)); |
| 1416 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | |
| 1417 } | 1414 } |
| 1418 | 1415 |
| 1419 bool ChromeContentRendererClient::AllowPepperMediaStreamAPI( | 1416 bool ChromeContentRendererClient::AllowPepperMediaStreamAPI( |
| 1420 const GURL& url) { | 1417 const GURL& url) { |
| 1421 #if !defined(OS_ANDROID) | 1418 #if !defined(OS_ANDROID) |
| 1422 // Allow only the Hangouts app to use the MediaStream APIs. It's OK to check | 1419 // Allow only the Hangouts app to use the MediaStream APIs. It's OK to check |
| 1423 // the whitelist in the renderer, since we're only preventing access until | 1420 // the whitelist in the renderer, since we're only preventing access until |
| 1424 // these APIs are public and stable. | 1421 // these APIs are public and stable. |
| 1425 std::string url_host = url.host(); | 1422 std::string url_host = url.host(); |
| 1426 if (url.SchemeIs("https") && | 1423 if (url.SchemeIs("https") && |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1458 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1455 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1459 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); | 1456 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); |
| 1460 } | 1457 } |
| 1461 | 1458 |
| 1462 blink::WebWorkerPermissionClientProxy* | 1459 blink::WebWorkerPermissionClientProxy* |
| 1463 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( | 1460 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( |
| 1464 content::RenderFrame* render_frame, | 1461 content::RenderFrame* render_frame, |
| 1465 blink::WebFrame* frame) { | 1462 blink::WebFrame* frame) { |
| 1466 return new WorkerPermissionClientProxy(render_frame, frame); | 1463 return new WorkerPermissionClientProxy(render_frame, frame); |
| 1467 } | 1464 } |
| OLD | NEW |