| 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/cpu.h" | 8 #include "base/cpu.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Also get the version from the command-line. Should be something like 11.2 | 305 // Also get the version from the command-line. Should be something like 11.2 |
| 306 // or 11.2.123.45. | 306 // or 11.2.123.45. |
| 307 std::string flash_version = | 307 std::string flash_version = |
| 308 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 308 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 309 switches::kPpapiFlashVersion); | 309 switches::kPpapiFlashVersion); |
| 310 | 310 |
| 311 plugins->push_back( | 311 plugins->push_back( |
| 312 CreatePepperFlashInfo(FilePath(flash_path), flash_version)); | 312 CreatePepperFlashInfo(FilePath(flash_path), flash_version)); |
| 313 } | 313 } |
| 314 | 314 |
| 315 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin, | 315 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) { |
| 316 bool* override_npapi_flash) { | |
| 317 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 316 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 318 if (!command_line->HasSwitch(switches::kDisablePepperThreading) && | 317 if (!command_line->HasSwitch(switches::kDisablePepperThreading) && |
| 319 !command_line->HasSwitch(switches::kEnablePepperThreading)) { | 318 !command_line->HasSwitch(switches::kEnablePepperThreading)) { |
| 320 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 319 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 321 if (channel == chrome::VersionInfo::CHANNEL_CANARY) | 320 if (channel == chrome::VersionInfo::CHANNEL_CANARY) |
| 322 command_line->AppendSwitch(switches::kEnablePepperThreading); | 321 command_line->AppendSwitch(switches::kEnablePepperThreading); |
| 323 } | 322 } |
| 324 | 323 |
| 325 #if defined(FLAPPER_AVAILABLE) | 324 #if defined(FLAPPER_AVAILABLE) |
| 326 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the | 325 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the |
| 327 // command-line. | 326 // command-line. |
| 328 if (command_line->HasSwitch(switches::kPpapiFlashPath)) | 327 if (command_line->HasSwitch(switches::kPpapiFlashPath)) |
| 329 return false; | 328 return false; |
| 330 | 329 |
| 331 bool force_disable = | 330 bool force_disable = |
| 332 command_line->HasSwitch(switches::kDisableBundledPpapiFlash); | 331 command_line->HasSwitch(switches::kDisableBundledPpapiFlash); |
| 333 if (force_disable) | 332 if (force_disable) |
| 334 return false; | 333 return false; |
| 335 | 334 |
| 336 // For Linux ia32, Flapper requires SSE2. | 335 // For Linux ia32, Flapper requires SSE2. |
| 337 #if defined(OS_LINUX) && defined(ARCH_CPU_X86) | 336 #if defined(OS_LINUX) && defined(ARCH_CPU_X86) |
| 338 if (!base::CPU().has_sse2()) | 337 if (!base::CPU().has_sse2()) |
| 339 return false; | 338 return false; |
| 340 #endif // ARCH_CPU_X86 | 339 #endif // ARCH_CPU_X86 |
| 341 | 340 |
| 342 FilePath flash_path; | 341 FilePath flash_path; |
| 343 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) | 342 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
| 344 return false; | 343 return false; |
| 345 | 344 |
| 346 bool force_enable = | |
| 347 command_line->HasSwitch(switches::kEnableBundledPpapiFlash); | |
| 348 | |
| 349 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); | 345 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); |
| 350 *override_npapi_flash = force_enable || IsPepperFlashEnabledByDefault(); | |
| 351 return true; | 346 return true; |
| 352 #else | 347 #else |
| 353 return false; | 348 return false; |
| 354 #endif // FLAPPER_AVAILABLE | 349 #endif // FLAPPER_AVAILABLE |
| 355 } | 350 } |
| 356 | 351 |
| 357 } // namespace | 352 } // namespace |
| 358 | 353 |
| 359 namespace chrome { | 354 namespace chrome { |
| 360 | 355 |
| 361 const char* const ChromeContentClient::kPDFPluginName = ::kPDFPluginName; | 356 const char* const ChromeContentClient::kPDFPluginName = ::kPDFPluginName; |
| 362 const char* const ChromeContentClient::kNaClPluginName = ::kNaClPluginName; | 357 const char* const ChromeContentClient::kNaClPluginName = ::kNaClPluginName; |
| 363 const char* const ChromeContentClient::kNaClOldPluginName = | 358 const char* const ChromeContentClient::kNaClOldPluginName = |
| 364 ::kNaClOldPluginName; | 359 ::kNaClOldPluginName; |
| 365 | 360 |
| 366 void ChromeContentClient::SetActiveURL(const GURL& url) { | 361 void ChromeContentClient::SetActiveURL(const GURL& url) { |
| 367 child_process_logging::SetActiveURL(url); | 362 child_process_logging::SetActiveURL(url); |
| 368 } | 363 } |
| 369 | 364 |
| 370 void ChromeContentClient::SetGpuInfo(const content::GPUInfo& gpu_info) { | 365 void ChromeContentClient::SetGpuInfo(const content::GPUInfo& gpu_info) { |
| 371 child_process_logging::SetGpuInfo(gpu_info); | 366 child_process_logging::SetGpuInfo(gpu_info); |
| 372 } | 367 } |
| 373 | 368 |
| 374 void ChromeContentClient::AddPepperPlugins( | 369 void ChromeContentClient::AddPepperPlugins( |
| 375 std::vector<content::PepperPluginInfo>* plugins) { | 370 std::vector<content::PepperPluginInfo>* plugins) { |
| 376 ComputeBuiltInPlugins(plugins); | 371 ComputeBuiltInPlugins(plugins); |
| 377 AddPepperFlashFromCommandLine(plugins); | 372 AddPepperFlashFromCommandLine(plugins); |
| 378 | 373 |
| 379 // Don't try to register Pepper Flash if there exists a Pepper Flash field | 374 content::PepperPluginInfo plugin; |
| 380 // trial. It will be registered separately. | 375 if (GetBundledPepperFlash(&plugin)) |
| 381 if (!ConductingPepperFlashFieldTrial() && IsPepperFlashEnabledByDefault()) { | 376 plugins->push_back(plugin); |
| 382 content::PepperPluginInfo plugin; | |
| 383 bool add_at_beginning = false; | |
| 384 if (GetBundledPepperFlash(&plugin, &add_at_beginning)) | |
| 385 plugins->push_back(plugin); | |
| 386 } | |
| 387 } | 377 } |
| 388 | 378 |
| 389 void ChromeContentClient::AddNPAPIPlugins( | 379 void ChromeContentClient::AddNPAPIPlugins( |
| 390 webkit::npapi::PluginList* plugin_list) { | 380 webkit::npapi::PluginList* plugin_list) { |
| 391 } | 381 } |
| 392 | 382 |
| 393 void ChromeContentClient::AddAdditionalSchemes( | 383 void ChromeContentClient::AddAdditionalSchemes( |
| 394 std::vector<std::string>* standard_schemes, | 384 std::vector<std::string>* standard_schemes, |
| 395 std::vector<std::string>* savable_schemes) { | 385 std::vector<std::string>* savable_schemes) { |
| 396 standard_schemes->push_back(extensions::kExtensionScheme); | 386 standard_schemes->push_back(extensions::kExtensionScheme); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 return true; | 454 return true; |
| 465 } | 455 } |
| 466 return false; | 456 return false; |
| 467 } | 457 } |
| 468 | 458 |
| 469 std::string ChromeContentClient::GetCarbonInterposePath() const { | 459 std::string ChromeContentClient::GetCarbonInterposePath() const { |
| 470 return std::string(kInterposeLibraryPath); | 460 return std::string(kInterposeLibraryPath); |
| 471 } | 461 } |
| 472 #endif | 462 #endif |
| 473 | 463 |
| 474 bool ChromeContentClient::GetBundledFieldTrialPepperFlash( | |
| 475 content::PepperPluginInfo* plugin, | |
| 476 bool* override_npapi_flash) { | |
| 477 if (!ConductingPepperFlashFieldTrial()) | |
| 478 return false; | |
| 479 return GetBundledPepperFlash(plugin, override_npapi_flash); | |
| 480 } | |
| 481 | |
| 482 } // namespace chrome | 464 } // namespace chrome |
| OLD | NEW |