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/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // Also get the version from the command-line. Should be something like 11.2 | 245 // Also get the version from the command-line. Should be something like 11.2 |
246 // or 11.2.123.45. | 246 // or 11.2.123.45. |
247 std::string flash_version = | 247 std::string flash_version = |
248 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 248 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
249 switches::kPpapiFlashVersion); | 249 switches::kPpapiFlashVersion); |
250 | 250 |
251 plugins->push_back( | 251 plugins->push_back( |
252 CreatePepperFlashInfo(FilePath(flash_path), flash_version)); | 252 CreatePepperFlashInfo(FilePath(flash_path), flash_version)); |
253 } | 253 } |
254 | 254 |
| 255 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin, |
| 256 bool* override_npapi_flash) { |
| 257 #if defined(FLAPPER_AVAILABLE) |
| 258 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the |
| 259 // command-line. |
| 260 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiFlashPath)) |
| 261 return false; |
| 262 |
| 263 bool force_disable = CommandLine::ForCurrentProcess()->HasSwitch( |
| 264 switches::kDisableBundledPpapiFlash); |
| 265 if (force_disable) |
| 266 return false; |
| 267 |
| 268 FilePath flash_path; |
| 269 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
| 270 return false; |
| 271 // It is an error to have FLAPPER_AVAILABLE defined but then not having the |
| 272 // plugin file in place, but this happens in Chrome OS builds. |
| 273 // Use --disable-bundled-ppapi-flash to skip this. |
| 274 DCHECK(file_util::PathExists(flash_path)); |
| 275 |
| 276 bool force_enable = CommandLine::ForCurrentProcess()->HasSwitch( |
| 277 switches::kEnableBundledPpapiFlash); |
| 278 |
| 279 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); |
| 280 *override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault(); |
| 281 return true; |
| 282 #else |
| 283 return false; |
| 284 #endif // FLAPPER_AVAILABLE |
| 285 } |
| 286 |
255 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
256 // Launches the privileged flash broker, used when flash is sandboxed. | 288 // Launches the privileged flash broker, used when flash is sandboxed. |
257 // The broker is the same flash dll, except that it uses a different | 289 // The broker is the same flash dll, except that it uses a different |
258 // entrypoint (BrokerMain) and it is hosted in windows' generic surrogate | 290 // entrypoint (BrokerMain) and it is hosted in windows' generic surrogate |
259 // process rundll32. After launching the broker we need to pass to | 291 // process rundll32. After launching the broker we need to pass to |
260 // the flash plugin the process id of the broker via the command line | 292 // the flash plugin the process id of the broker via the command line |
261 // using --flash-broker=pid. | 293 // using --flash-broker=pid. |
262 // More info about rundll32 at http://support.microsoft.com/kb/164787. | 294 // More info about rundll32 at http://support.microsoft.com/kb/164787. |
263 bool LoadFlashBroker(const FilePath& plugin_path, CommandLine* cmd_line) { | 295 bool LoadFlashBroker(const FilePath& plugin_path, CommandLine* cmd_line) { |
264 FilePath rundll; | 296 FilePath rundll; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 } | 352 } |
321 | 353 |
322 void ChromeContentClient::SetGpuInfo(const content::GPUInfo& gpu_info) { | 354 void ChromeContentClient::SetGpuInfo(const content::GPUInfo& gpu_info) { |
323 child_process_logging::SetGpuInfo(gpu_info); | 355 child_process_logging::SetGpuInfo(gpu_info); |
324 } | 356 } |
325 | 357 |
326 void ChromeContentClient::AddPepperPlugins( | 358 void ChromeContentClient::AddPepperPlugins( |
327 std::vector<content::PepperPluginInfo>* plugins) { | 359 std::vector<content::PepperPluginInfo>* plugins) { |
328 ComputeBuiltInPlugins(plugins); | 360 ComputeBuiltInPlugins(plugins); |
329 AddPepperFlashFromCommandLine(plugins); | 361 AddPepperFlashFromCommandLine(plugins); |
| 362 |
| 363 // Don't try to register Pepper Flash if there exists a Pepper Flash field |
| 364 // trial. It will be registered separately. |
| 365 if (!ConductingPepperFlashFieldTrial() && IsPepperFlashEnabledByDefault()) { |
| 366 content::PepperPluginInfo plugin; |
| 367 bool add_at_beginning = false; |
| 368 if (GetBundledPepperFlash(&plugin, &add_at_beginning)) |
| 369 plugins->push_back(plugin); |
| 370 } |
330 } | 371 } |
331 | 372 |
332 void ChromeContentClient::AddNPAPIPlugins( | 373 void ChromeContentClient::AddNPAPIPlugins( |
333 webkit::npapi::PluginList* plugin_list) { | 374 webkit::npapi::PluginList* plugin_list) { |
334 } | 375 } |
335 | 376 |
336 void ChromeContentClient::AddAdditionalSchemes( | 377 void ChromeContentClient::AddAdditionalSchemes( |
337 std::vector<std::string>* standard_schemes, | 378 std::vector<std::string>* standard_schemes, |
338 std::vector<std::string>* savable_schemes) { | 379 std::vector<std::string>* savable_schemes) { |
339 standard_schemes->push_back(kExtensionScheme); | 380 standard_schemes->push_back(kExtensionScheme); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 int* sandbox_profile_resource_id) const { | 490 int* sandbox_profile_resource_id) const { |
450 DCHECK(sandbox_profile_resource_id); | 491 DCHECK(sandbox_profile_resource_id); |
451 if (sandbox_type == CHROME_SANDBOX_TYPE_NACL_LOADER) { | 492 if (sandbox_type == CHROME_SANDBOX_TYPE_NACL_LOADER) { |
452 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; | 493 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; |
453 return true; | 494 return true; |
454 } | 495 } |
455 return false; | 496 return false; |
456 } | 497 } |
457 #endif | 498 #endif |
458 | 499 |
459 bool ChromeContentClient::GetBundledPepperFlash( | 500 bool ChromeContentClient::GetBundledFieldTrialPepperFlash( |
460 content::PepperPluginInfo* plugin, | 501 content::PepperPluginInfo* plugin, |
461 bool* override_npapi_flash) { | 502 bool* override_npapi_flash) { |
462 #if defined(FLAPPER_AVAILABLE) | 503 if (!ConductingPepperFlashFieldTrial()) |
463 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the | |
464 // command-line. | |
465 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kPpapiFlashPath)) | |
466 return false; | 504 return false; |
467 | 505 return GetBundledPepperFlash(plugin, override_npapi_flash); |
468 bool force_disable = CommandLine::ForCurrentProcess()->HasSwitch( | |
469 switches::kDisableBundledPpapiFlash); | |
470 if (force_disable) | |
471 return false; | |
472 | |
473 FilePath flash_path; | |
474 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) | |
475 return false; | |
476 // It is an error to have FLAPPER_AVAILABLE defined but then not having the | |
477 // plugin file in place, but this happens in Chrome OS builds. | |
478 // Use --disable-bundled-ppapi-flash to skip this. | |
479 DCHECK(file_util::PathExists(flash_path)); | |
480 | |
481 bool force_enable = CommandLine::ForCurrentProcess()->HasSwitch( | |
482 switches::kEnableBundledPpapiFlash); | |
483 | |
484 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); | |
485 *override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault(); | |
486 return true; | |
487 #else | |
488 return false; | |
489 #endif // FLAPPER_AVAILABLE | |
490 } | 506 } |
491 | 507 |
492 } // namespace chrome | 508 } // namespace chrome |
OLD | NEW |