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" |
24 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
26 #include "chrome/grit/common_resources.h" | 27 #include "chrome/grit/common_resources.h" |
27 #include "components/dom_distiller/core/url_constants.h" | 28 #include "components/dom_distiller/core/url_constants.h" |
| 29 #include "components/nacl/common/nacl_process_type.h" |
28 #include "content/public/common/content_constants.h" | 30 #include "content/public/common/content_constants.h" |
29 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
30 #include "content/public/common/pepper_plugin_info.h" | 32 #include "content/public/common/pepper_plugin_info.h" |
31 #include "content/public/common/url_constants.h" | 33 #include "content/public/common/url_constants.h" |
32 #include "content/public/common/user_agent.h" | 34 #include "content/public/common/user_agent.h" |
33 #include "extensions/common/constants.h" | 35 #include "extensions/common/constants.h" |
34 #include "gpu/config/gpu_info.h" | 36 #include "gpu/config/gpu_info.h" |
| 37 #include "ppapi/shared_impl/ppapi_permissions.h" |
35 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
36 #include "ui/base/layout.h" | 39 #include "ui/base/layout.h" |
37 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
38 | 41 |
| 42 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. |
39 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 43 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
40 | 44 |
41 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
42 #include "base/win/registry.h" | 46 #include "base/win/registry.h" |
43 #include "base/win/windows_version.h" | 47 #include "base/win/windows_version.h" |
44 #elif defined(OS_MACOSX) | 48 #elif defined(OS_MACOSX) |
45 #include "components/nacl/common/nacl_sandbox_type_mac.h" | 49 #include "components/nacl/common/nacl_sandbox_type_mac.h" |
46 #endif | 50 #endif |
47 | 51 |
48 #if !defined(DISABLE_NACL) | 52 #if !defined(DISABLE_NACL) |
49 #include "components/nacl/common/nacl_constants.h" | 53 #include "components/nacl/common/nacl_constants.h" |
50 #include "components/nacl/common/nacl_process_type.h" | |
51 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h" | 54 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h" |
52 #endif | 55 #endif |
53 | 56 |
54 #if defined(ENABLE_PLUGINS) | |
55 #include "chrome/common/pepper_flash.h" | |
56 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR. | |
57 #include "ppapi/shared_impl/ppapi_permissions.h" | |
58 #endif | |
59 | |
60 #if defined(ENABLE_REMOTING) | 57 #if defined(ENABLE_REMOTING) |
61 #include "remoting/client/plugin/pepper_entrypoints.h" | 58 #include "remoting/client/plugin/pepper_entrypoints.h" |
62 #endif | 59 #endif |
63 | 60 |
64 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ | 61 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ |
65 !defined(WIDEVINE_CDM_IS_COMPONENT) | 62 !defined(WIDEVINE_CDM_IS_COMPONENT) |
66 #include "chrome/common/widevine_cdm_constants.h" | 63 #include "chrome/common/widevine_cdm_constants.h" |
67 #endif | 64 #endif |
68 | 65 |
69 namespace { | 66 namespace { |
70 | 67 |
71 #if defined(ENABLE_PLUGINS) | |
72 const char kPDFPluginMimeType[] = "application/pdf"; | 68 const char kPDFPluginMimeType[] = "application/pdf"; |
73 const char kPDFPluginExtension[] = "pdf"; | 69 const char kPDFPluginExtension[] = "pdf"; |
74 const char kPDFPluginDescription[] = "Portable Document Format"; | 70 const char kPDFPluginDescription[] = "Portable Document Format"; |
75 const char kPDFPluginPrintPreviewMimeType[] = | 71 const char kPDFPluginPrintPreviewMimeType[] = |
76 "application/x-google-chrome-print-preview-pdf"; | 72 "application/x-google-chrome-print-preview-pdf"; |
77 const char kPDFPluginOutOfProcessMimeType[] = | 73 const char kPDFPluginOutOfProcessMimeType[] = |
78 "application/x-google-chrome-pdf"; | 74 "application/x-google-chrome-pdf"; |
79 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | | 75 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE | |
80 ppapi::PERMISSION_DEV; | 76 ppapi::PERMISSION_DEV; |
81 | 77 |
(...skipping 10 matching lines...) Expand all Loading... |
92 const char kEffectsPluginDescription[] = "Google Talk Effects Plugin"; | 88 const char kEffectsPluginDescription[] = "Google Talk Effects Plugin"; |
93 const uint32 kEffectsPluginPermissions = ppapi::PERMISSION_PRIVATE | | 89 const uint32 kEffectsPluginPermissions = ppapi::PERMISSION_PRIVATE | |
94 ppapi::PERMISSION_DEV; | 90 ppapi::PERMISSION_DEV; |
95 | 91 |
96 const char kGTalkPluginName[] = "Google Talk Plugin"; | 92 const char kGTalkPluginName[] = "Google Talk Plugin"; |
97 const char kGTalkPluginMimeType[] ="application/googletalk"; | 93 const char kGTalkPluginMimeType[] ="application/googletalk"; |
98 const char kGTalkPluginExtension[] = ".googletalk"; | 94 const char kGTalkPluginExtension[] = ".googletalk"; |
99 const char kGTalkPluginDescription[] = "Google Talk Plugin"; | 95 const char kGTalkPluginDescription[] = "Google Talk Plugin"; |
100 const uint32 kGTalkPluginPermissions = ppapi::PERMISSION_PRIVATE | | 96 const uint32 kGTalkPluginPermissions = ppapi::PERMISSION_PRIVATE | |
101 ppapi::PERMISSION_DEV; | 97 ppapi::PERMISSION_DEV; |
102 #endif // defined(ENABLE_PLUGINS) | |
103 | 98 |
104 #if defined(ENABLE_REMOTING) | 99 #if defined(ENABLE_REMOTING) |
105 #if defined(GOOGLE_CHROME_BUILD) | 100 #if defined(GOOGLE_CHROME_BUILD) |
106 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer"; | 101 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer"; |
107 #else | 102 #else |
108 const char kRemotingViewerPluginName[] = "Chromoting Viewer"; | 103 const char kRemotingViewerPluginName[] = "Chromoting Viewer"; |
109 #endif // defined(GOOGLE_CHROME_BUILD) | 104 #endif // defined(GOOGLE_CHROME_BUILD) |
110 const char kRemotingViewerPluginDescription[] = | 105 const char kRemotingViewerPluginDescription[] = |
111 "This plugin allows you to securely access other computers that have been " | 106 "This plugin allows you to securely access other computers that have been " |
112 "shared with you. To use this plugin you must first install the " | 107 "shared with you. To use this plugin you must first install the " |
113 "<a href=\"https://chrome.google.com/remotedesktop\">" | 108 "<a href=\"https://chrome.google.com/remotedesktop\">" |
114 "Chrome Remote Desktop</a> webapp."; | 109 "Chrome Remote Desktop</a> webapp."; |
115 // Use a consistent MIME-type regardless of branding. | 110 // Use a consistent MIME-type regardless of branding. |
116 const char kRemotingViewerPluginMimeType[] = | 111 const char kRemotingViewerPluginMimeType[] = |
117 "application/vnd.chromium.remoting-viewer"; | 112 "application/vnd.chromium.remoting-viewer"; |
118 const char kRemotingViewerPluginMimeExtension[] = ""; | 113 const char kRemotingViewerPluginMimeExtension[] = ""; |
119 const char kRemotingViewerPluginMimeDescription[] = ""; | 114 const char kRemotingViewerPluginMimeDescription[] = ""; |
120 const uint32 kRemotingViewerPluginPermissions = ppapi::PERMISSION_PRIVATE | | 115 const uint32 kRemotingViewerPluginPermissions = ppapi::PERMISSION_PRIVATE | |
121 ppapi::PERMISSION_DEV; | 116 ppapi::PERMISSION_DEV; |
122 #endif // defined(ENABLE_REMOTING) | 117 #endif // defined(ENABLE_REMOTING) |
123 | 118 |
124 #if defined(ENABLE_PLUGINS) | |
125 // Appends the known built-in plugins to the given vector. Some built-in | 119 // Appends the known built-in plugins to the given vector. Some built-in |
126 // plugins are "internal" which means they are compiled into the Chrome binary, | 120 // plugins are "internal" which means they are compiled into the Chrome binary, |
127 // and some are extra shared libraries distributed with the browser (these are | 121 // and some are extra shared libraries distributed with the browser (these are |
128 // not marked internal, aside from being automatically registered, they're just | 122 // not marked internal, aside from being automatically registered, they're just |
129 // regular plugins). | 123 // regular plugins). |
130 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { | 124 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { |
131 // PDF. | 125 // PDF. |
132 // | 126 // |
133 // Once we're sandboxed, we can't know if the PDF plugin is available or not; | 127 // Once we're sandboxed, we can't know if the PDF plugin is available or not; |
134 // but (on Linux) this function is always called once before we're sandboxed. | 128 // but (on Linux) this function is always called once before we're sandboxed. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 base::FilePath flash_path; | 400 base::FilePath flash_path; |
407 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) | 401 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) |
408 return false; | 402 return false; |
409 | 403 |
410 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); | 404 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); |
411 return true; | 405 return true; |
412 #else | 406 #else |
413 return false; | 407 return false; |
414 #endif // FLAPPER_AVAILABLE | 408 #endif // FLAPPER_AVAILABLE |
415 } | 409 } |
416 #endif // defined(ENABLE_PLUGINS) | |
417 | 410 |
418 std::string GetProduct() { | 411 std::string GetProduct() { |
419 chrome::VersionInfo version_info; | 412 chrome::VersionInfo version_info; |
420 return version_info.is_valid() ? | 413 return version_info.is_valid() ? |
421 version_info.ProductNameAndVersionForUserAgent() : std::string(); | 414 version_info.ProductNameAndVersionForUserAgent() : std::string(); |
422 } | 415 } |
423 | 416 |
424 } // namespace | 417 } // namespace |
425 | 418 |
426 std::string GetUserAgent() { | 419 std::string GetUserAgent() { |
(...skipping 30 matching lines...) Expand all Loading... |
457 #if defined(OS_MACOSX) | 450 #if defined(OS_MACOSX) |
458 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); | 451 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); |
459 #elif defined(OS_POSIX) | 452 #elif defined(OS_POSIX) |
460 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); | 453 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); |
461 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); | 454 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); |
462 #endif | 455 #endif |
463 } | 456 } |
464 | 457 |
465 void ChromeContentClient::AddPepperPlugins( | 458 void ChromeContentClient::AddPepperPlugins( |
466 std::vector<content::PepperPluginInfo>* plugins) { | 459 std::vector<content::PepperPluginInfo>* plugins) { |
467 #if defined(ENABLE_PLUGINS) | |
468 ComputeBuiltInPlugins(plugins); | 460 ComputeBuiltInPlugins(plugins); |
469 AddPepperFlashFromCommandLine(plugins); | 461 AddPepperFlashFromCommandLine(plugins); |
470 | 462 |
471 content::PepperPluginInfo plugin; | 463 content::PepperPluginInfo plugin; |
472 if (GetBundledPepperFlash(&plugin)) | 464 if (GetBundledPepperFlash(&plugin)) |
473 plugins->push_back(plugin); | 465 plugins->push_back(plugin); |
474 #endif | |
475 } | 466 } |
476 | 467 |
477 void ChromeContentClient::AddAdditionalSchemes( | 468 void ChromeContentClient::AddAdditionalSchemes( |
478 std::vector<std::string>* standard_schemes, | 469 std::vector<std::string>* standard_schemes, |
479 std::vector<std::string>* savable_schemes) { | 470 std::vector<std::string>* savable_schemes) { |
480 standard_schemes->push_back(extensions::kExtensionScheme); | 471 standard_schemes->push_back(extensions::kExtensionScheme); |
481 savable_schemes->push_back(extensions::kExtensionScheme); | 472 savable_schemes->push_back(extensions::kExtensionScheme); |
482 standard_schemes->push_back(chrome::kChromeNativeScheme); | 473 standard_schemes->push_back(chrome::kChromeNativeScheme); |
483 standard_schemes->push_back(extensions::kExtensionResourceScheme); | 474 standard_schemes->push_back(extensions::kExtensionResourceScheme); |
484 savable_schemes->push_back(extensions::kExtensionResourceScheme); | 475 savable_schemes->push_back(extensions::kExtensionResourceScheme); |
(...skipping 28 matching lines...) Expand all Loading... |
513 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes( | 504 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes( |
514 int resource_id) const { | 505 int resource_id) const { |
515 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | 506 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); |
516 } | 507 } |
517 | 508 |
518 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const { | 509 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const { |
519 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | 510 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
520 } | 511 } |
521 | 512 |
522 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) { | 513 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) { |
523 #if !defined(DISABLE_NACL) | |
524 switch (type) { | 514 switch (type) { |
525 case PROCESS_TYPE_NACL_LOADER: | 515 case PROCESS_TYPE_NACL_LOADER: |
526 return "Native Client module"; | 516 return "Native Client module"; |
527 case PROCESS_TYPE_NACL_BROKER: | 517 case PROCESS_TYPE_NACL_BROKER: |
528 return "Native Client broker"; | 518 return "Native Client broker"; |
529 } | 519 } |
530 #endif | |
531 | 520 |
532 NOTREACHED() << "Unknown child process type!"; | 521 DCHECK(false) << "Unknown child process type!"; |
533 return "Unknown"; | 522 return "Unknown"; |
534 } | 523 } |
535 | 524 |
536 #if defined(OS_MACOSX) && !defined(OS_IOS) | 525 #if defined(OS_MACOSX) && !defined(OS_IOS) |
537 bool ChromeContentClient::GetSandboxProfileForSandboxType( | 526 bool ChromeContentClient::GetSandboxProfileForSandboxType( |
538 int sandbox_type, | 527 int sandbox_type, |
539 int* sandbox_profile_resource_id) const { | 528 int* sandbox_profile_resource_id) const { |
540 DCHECK(sandbox_profile_resource_id); | 529 DCHECK(sandbox_profile_resource_id); |
541 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { | 530 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { |
542 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; | 531 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; |
543 return true; | 532 return true; |
544 } | 533 } |
545 return false; | 534 return false; |
546 } | 535 } |
547 #endif | 536 #endif |
OLD | NEW |