Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: chrome/common/chrome_content_client.cc

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

Powered by Google App Engine
This is Rietveld 408576698