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/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/common/chrome_content_client.h" | 18 #include "chrome/common/chrome_content_client.h" |
19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/chrome_version_info.h" |
21 #include "chrome/common/content_settings_pattern.h" | 22 #include "chrome/common/content_settings_pattern.h" |
22 #include "chrome/common/crash_keys.h" | 23 #include "chrome/common/crash_keys.h" |
23 #include "chrome/common/extensions/chrome_extensions_client.h" | 24 #include "chrome/common/extensions/chrome_extensions_client.h" |
24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
25 #include "chrome/common/extensions/extension_process_policy.h" | 26 #include "chrome/common/extensions/extension_process_policy.h" |
26 #include "chrome/common/localized_error.h" | 27 #include "chrome/common/localized_error.h" |
27 #include "chrome/common/pepper_permission_util.h" | 28 #include "chrome/common/pepper_permission_util.h" |
28 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
30 #include "chrome/renderer/benchmarking_extension.h" | 31 #include "chrome/renderer/benchmarking_extension.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 using blink::WebURL; | 156 using blink::WebURL; |
156 using blink::WebURLError; | 157 using blink::WebURLError; |
157 using blink::WebURLRequest; | 158 using blink::WebURLRequest; |
158 using blink::WebURLResponse; | 159 using blink::WebURLResponse; |
159 using blink::WebVector; | 160 using blink::WebVector; |
160 | 161 |
161 namespace { | 162 namespace { |
162 | 163 |
163 ChromeContentRendererClient* g_current_client; | 164 ChromeContentRendererClient* g_current_client; |
164 | 165 |
| 166 #if defined(ENABLE_PLUGINS) |
| 167 const char* const kPredefinedAllowedCompositorOrigins[] = { |
| 168 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/383937 |
| 169 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/383937 |
| 170 }; |
| 171 |
| 172 const char* const kPredefinedAllowedVideoDecodeOrigins[] = { |
| 173 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/383937 |
| 174 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/383937 |
| 175 }; |
| 176 #endif |
| 177 |
165 static void AppendParams(const std::vector<base::string16>& additional_names, | 178 static void AppendParams(const std::vector<base::string16>& additional_names, |
166 const std::vector<base::string16>& additional_values, | 179 const std::vector<base::string16>& additional_values, |
167 WebVector<WebString>* existing_names, | 180 WebVector<WebString>* existing_names, |
168 WebVector<WebString>* existing_values) { | 181 WebVector<WebString>* existing_values) { |
169 DCHECK(additional_names.size() == additional_values.size()); | 182 DCHECK(additional_names.size() == additional_values.size()); |
170 DCHECK(existing_names->size() == existing_values->size()); | 183 DCHECK(existing_names->size() == existing_values->size()); |
171 | 184 |
172 size_t existing_size = existing_names->size(); | 185 size_t existing_size = existing_names->size(); |
173 size_t total_size = existing_size + additional_names.size(); | 186 size_t total_size = existing_size + additional_names.size(); |
174 | 187 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 246 |
234 } // namespace | 247 } // namespace |
235 | 248 |
236 ChromeContentRendererClient::ChromeContentRendererClient() { | 249 ChromeContentRendererClient::ChromeContentRendererClient() { |
237 g_current_client = this; | 250 g_current_client = this; |
238 | 251 |
239 extensions::ExtensionsClient::Set( | 252 extensions::ExtensionsClient::Set( |
240 extensions::ChromeExtensionsClient::GetInstance()); | 253 extensions::ChromeExtensionsClient::GetInstance()); |
241 extensions::ExtensionsRendererClient::Set( | 254 extensions::ExtensionsRendererClient::Set( |
242 ChromeExtensionsRendererClient::GetInstance()); | 255 ChromeExtensionsRendererClient::GetInstance()); |
| 256 #if defined(ENABLE_PLUGINS) |
| 257 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i) |
| 258 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]); |
| 259 for (size_t i = 0; i < arraysize(kPredefinedAllowedVideoDecodeOrigins); ++i) |
| 260 allowed_video_decode_origins_.insert( |
| 261 kPredefinedAllowedVideoDecodeOrigins[i]); |
| 262 #endif |
243 } | 263 } |
244 | 264 |
245 ChromeContentRendererClient::~ChromeContentRendererClient() { | 265 ChromeContentRendererClient::~ChromeContentRendererClient() { |
246 g_current_client = NULL; | 266 g_current_client = NULL; |
247 } | 267 } |
248 | 268 |
249 void ChromeContentRendererClient::RenderThreadStarted() { | 269 void ChromeContentRendererClient::RenderThreadStarted() { |
250 RenderThread* thread = RenderThread::Get(); | 270 RenderThread* thread = RenderThread::Get(); |
251 | 271 |
252 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); | 272 chrome_observer_.reset(new ChromeRenderProcessObserver(this)); |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1446 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1427 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); | 1447 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); |
1428 } | 1448 } |
1429 | 1449 |
1430 blink::WebWorkerPermissionClientProxy* | 1450 blink::WebWorkerPermissionClientProxy* |
1431 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( | 1451 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( |
1432 content::RenderFrame* render_frame, | 1452 content::RenderFrame* render_frame, |
1433 blink::WebFrame* frame) { | 1453 blink::WebFrame* frame) { |
1434 return new WorkerPermissionClientProxy(render_frame, frame); | 1454 return new WorkerPermissionClientProxy(render_frame, frame); |
1435 } | 1455 } |
| 1456 |
| 1457 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { |
| 1458 #if defined(ENABLE_PLUGINS) |
| 1459 // Allow access for tests. |
| 1460 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1461 switches::kEnablePepperTesting)) { |
| 1462 return true; |
| 1463 } |
| 1464 |
| 1465 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 1466 // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown" |
| 1467 // releases of Chrome. Permitting "Unknown" allows these APIs to be used on |
| 1468 // Chromium builds as well. |
| 1469 return channel <= chrome::VersionInfo::CHANNEL_DEV; |
| 1470 #else |
| 1471 return false; |
| 1472 #endif |
| 1473 } |
| 1474 |
| 1475 bool ChromeContentRendererClient::IsPluginAllowedToUseCompositorAPI( |
| 1476 const GURL& url) { |
| 1477 #if defined(ENABLE_PLUGINS) |
| 1478 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1479 switches::kEnablePepperTesting)) |
| 1480 return true; |
| 1481 return IsExtensionOrSharedModuleWhitelisted(url, allowed_compositor_origins_); |
| 1482 #else |
| 1483 return false; |
| 1484 #endif |
| 1485 } |
| 1486 |
| 1487 bool ChromeContentRendererClient::IsPluginAllowedToUseVideoDecodeAPI( |
| 1488 const GURL& url) { |
| 1489 #if defined(ENABLE_PLUGINS) |
| 1490 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1491 switches::kEnablePepperTesting)) |
| 1492 return true; |
| 1493 return IsExtensionOrSharedModuleWhitelisted(url, |
| 1494 allowed_video_decode_origins_); |
| 1495 #else |
| 1496 return false; |
| 1497 #endif |
| 1498 } |
OLD | NEW |