| 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/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "chrome/common/child_process_logging.h" | 19 #include "chrome/common/child_process_logging.h" |
| 20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/chrome_version_info.h" | 22 #include "chrome/common/chrome_version_info.h" |
| 23 #include "chrome/common/crash_keys.h" | 23 #include "chrome/common/crash_keys.h" |
| 24 #include "chrome/common/pepper_flash.h" | |
| 25 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
| 26 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 27 #include "chrome/grit/common_resources.h" | 26 #include "chrome/grit/common_resources.h" |
| 28 #include "components/dom_distiller/core/url_constants.h" | 27 #include "components/dom_distiller/core/url_constants.h" |
| 29 #include "components/nacl/common/nacl_process_type.h" | |
| 30 #include "content/public/common/content_constants.h" | 28 #include "content/public/common/content_constants.h" |
| 31 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 32 #include "content/public/common/pepper_plugin_info.h" | 30 #include "content/public/common/pepper_plugin_info.h" |
| 33 #include "content/public/common/url_constants.h" | 31 #include "content/public/common/url_constants.h" |
| 34 #include "content/public/common/user_agent.h" | 32 #include "content/public/common/user_agent.h" |
| 35 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
| 36 #include "gpu/config/gpu_info.h" | 34 #include "gpu/config/gpu_info.h" |
| 37 #include "net/http/http_util.h" | 35 #include "net/http/http_util.h" |
| 38 #include "ppapi/shared_impl/ppapi_permissions.h" | |
| 39 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/layout.h" | 37 #include "ui/base/layout.h" |
| 41 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 42 | 39 |
| 43 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. | |
| 44 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 40 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 45 | 41 |
| 46 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
| 47 #include "base/win/registry.h" | 43 #include "base/win/registry.h" |
| 48 #include "base/win/windows_version.h" | 44 #include "base/win/windows_version.h" |
| 49 #elif defined(OS_MACOSX) | 45 #elif defined(OS_MACOSX) |
| 50 #include "components/nacl/common/nacl_sandbox_type_mac.h" | 46 #include "components/nacl/common/nacl_sandbox_type_mac.h" |
| 51 #endif | 47 #endif |
| 52 | 48 |
| 53 #if !defined(DISABLE_NACL) | 49 #if !defined(DISABLE_NACL) |
| 54 #include "components/nacl/common/nacl_constants.h" | 50 #include "components/nacl/common/nacl_constants.h" |
| 51 #include "components/nacl/common/nacl_process_type.h" |
| 55 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h" | 52 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h" |
| 56 #endif | 53 #endif |
| 57 | 54 |
| 55 #if defined(ENABLE_PLUGINS) |
| 56 #include "chrome/common/pepper_flash.h" |
| 57 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 58 #include "ppapi/shared_impl/ppapi_permissions.h" |
| 59 #endif |
| 60 |
| 58 #if defined(ENABLE_REMOTING) | 61 #if defined(ENABLE_REMOTING) |
| 59 #include "remoting/client/plugin/pepper_entrypoints.h" | 62 #include "remoting/client/plugin/pepper_entrypoints.h" |
| 60 #endif | 63 #endif |
| 61 | 64 |
| 62 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | 65 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
| 63 !defined(WIDEVINE_CDM_IS_COMPONENT) | 66 !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 64 #include "chrome/common/widevine_cdm_constants.h" | 67 #include "chrome/common/widevine_cdm_constants.h" |
| 65 #endif | 68 #endif |
| 66 | 69 |
| 67 namespace { | 70 namespace { |
| 68 | 71 |
| 72 #if defined(ENABLE_PLUGINS) |
| 69 const char kPDFPluginMimeType[] = "application/pdf"; | 73 const char kPDFPluginMimeType[] = "application/pdf"; |
| 70 const char kPDFPluginExtension[] = "pdf"; | 74 const char kPDFPluginExtension[] = "pdf"; |
| 71 const char kPDFPluginDescription[] = "Portable Document Format"; | 75 const char kPDFPluginDescription[] = "Portable Document Format"; |
| 72 const char kPDFPluginPrintPreviewMimeType[] = | 76 const char kPDFPluginPrintPreviewMimeType[] = |
| 73 "application/x-google-chrome-print-preview-pdf"; | 77 "application/x-google-chrome-print-preview-pdf"; |
| 74 const char kPDFPluginOutOfProcessMimeType[] = | 78 const char kPDFPluginOutOfProcessMimeType[] = |
| 75 "application/x-google-chrome-pdf"; | 79 "application/x-google-chrome-pdf"; |
| 76 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | | 80 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | |
| 77 ppapi::PERMISSION_DEV; | 81 ppapi::PERMISSION_DEV; |
| 78 | 82 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 base::FilePath flash_path; | 405 base::FilePath flash_path; |
| 402 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) | 406 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
| 403 return false; | 407 return false; |
| 404 | 408 |
| 405 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); | 409 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); |
| 406 return true; | 410 return true; |
| 407 #else | 411 #else |
| 408 return false; | 412 return false; |
| 409 #endif // FLAPPER_AVAILABLE | 413 #endif // FLAPPER_AVAILABLE |
| 410 } | 414 } |
| 415 #endif // defined(ENABLE_PLUGINS) |
| 411 | 416 |
| 412 std::string GetProduct() { | 417 std::string GetProduct() { |
| 413 chrome::VersionInfo version_info; | 418 chrome::VersionInfo version_info; |
| 414 return version_info.is_valid() ? | 419 return version_info.is_valid() ? |
| 415 version_info.ProductNameAndVersionForUserAgent() : std::string(); | 420 version_info.ProductNameAndVersionForUserAgent() : std::string(); |
| 416 } | 421 } |
| 417 | 422 |
| 418 } // namespace | 423 } // namespace |
| 419 | 424 |
| 420 std::string GetUserAgent() { | 425 std::string GetUserAgent() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 #if defined(OS_MACOSX) | 460 #if defined(OS_MACOSX) |
| 456 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); | 461 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); |
| 457 #elif defined(OS_POSIX) | 462 #elif defined(OS_POSIX) |
| 458 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); | 463 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); |
| 459 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); | 464 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); |
| 460 #endif | 465 #endif |
| 461 } | 466 } |
| 462 | 467 |
| 463 void ChromeContentClient::AddPepperPlugins( | 468 void ChromeContentClient::AddPepperPlugins( |
| 464 std::vector<content::PepperPluginInfo>* plugins) { | 469 std::vector<content::PepperPluginInfo>* plugins) { |
| 470 #if defined(ENABLE_PLUGINS) |
| 465 ComputeBuiltInPlugins(plugins); | 471 ComputeBuiltInPlugins(plugins); |
| 466 AddPepperFlashFromCommandLine(plugins); | 472 AddPepperFlashFromCommandLine(plugins); |
| 467 | 473 |
| 468 content::PepperPluginInfo plugin; | 474 content::PepperPluginInfo plugin; |
| 469 if (GetBundledPepperFlash(&plugin)) | 475 if (GetBundledPepperFlash(&plugin)) |
| 470 plugins->push_back(plugin); | 476 plugins->push_back(plugin); |
| 477 #endif |
| 471 } | 478 } |
| 472 | 479 |
| 473 void ChromeContentClient::AddAdditionalSchemes( | 480 void ChromeContentClient::AddAdditionalSchemes( |
| 474 std::vector<std::string>* standard_schemes, | 481 std::vector<std::string>* standard_schemes, |
| 475 std::vector<std::string>* savable_schemes) { | 482 std::vector<std::string>* savable_schemes) { |
| 476 standard_schemes->push_back(extensions::kExtensionScheme); | 483 standard_schemes->push_back(extensions::kExtensionScheme); |
| 477 savable_schemes->push_back(extensions::kExtensionScheme); | 484 savable_schemes->push_back(extensions::kExtensionScheme); |
| 478 standard_schemes->push_back(chrome::kChromeNativeScheme); | 485 standard_schemes->push_back(chrome::kChromeNativeScheme); |
| 479 standard_schemes->push_back(extensions::kExtensionResourceScheme); | 486 standard_schemes->push_back(extensions::kExtensionResourceScheme); |
| 480 savable_schemes->push_back(extensions::kExtensionResourceScheme); | 487 savable_schemes->push_back(extensions::kExtensionResourceScheme); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 509 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes( | 516 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes( |
| 510 int resource_id) const { | 517 int resource_id) const { |
| 511 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | 518 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); |
| 512 } | 519 } |
| 513 | 520 |
| 514 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const { | 521 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const { |
| 515 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | 522 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
| 516 } | 523 } |
| 517 | 524 |
| 518 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) { | 525 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) { |
| 526 #if !defined(DISABLE_NACL) |
| 519 switch (type) { | 527 switch (type) { |
| 520 case PROCESS_TYPE_NACL_LOADER: | 528 case PROCESS_TYPE_NACL_LOADER: |
| 521 return "Native Client module"; | 529 return "Native Client module"; |
| 522 case PROCESS_TYPE_NACL_BROKER: | 530 case PROCESS_TYPE_NACL_BROKER: |
| 523 return "Native Client broker"; | 531 return "Native Client broker"; |
| 524 } | 532 } |
| 533 #endif |
| 525 | 534 |
| 526 DCHECK(false) << "Unknown child process type!"; | 535 NOTREACHED() << "Unknown child process type!"; |
| 527 return "Unknown"; | 536 return "Unknown"; |
| 528 } | 537 } |
| 529 | 538 |
| 530 #if defined(OS_MACOSX) && !defined(OS_IOS) | 539 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 531 bool ChromeContentClient::GetSandboxProfileForSandboxType( | 540 bool ChromeContentClient::GetSandboxProfileForSandboxType( |
| 532 int sandbox_type, | 541 int sandbox_type, |
| 533 int* sandbox_profile_resource_id) const { | 542 int* sandbox_profile_resource_id) const { |
| 534 DCHECK(sandbox_profile_resource_id); | 543 DCHECK(sandbox_profile_resource_id); |
| 535 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { | 544 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { |
| 536 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; | 545 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; |
| 537 return true; | 546 return true; |
| 538 } | 547 } |
| 539 return false; | 548 return false; |
| 540 } | 549 } |
| 541 #endif | 550 #endif |
| OLD | NEW |