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

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 11 matching lines...) Expand all
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;
98 102
103
104 #if !defined(DISABLE_NACL)
105 const char kNaClPluginMimeType[] = "application/x-nacl";
viettrungluu 2014/08/19 21:36:34 Where did this part of the change come from? (It d
106 const char kNaClPluginExtension[] = "";
107 const char kNaClPluginDescription[] = "Native Client Executable";
108 const uint32 kNaClPluginPermissions = ppapi::PERMISSION_PRIVATE |
109 ppapi::PERMISSION_DEV;
110
111 const char kPnaclPluginMimeType[] = "application/x-pnacl";
112 const char kPnaclPluginExtension[] = "";
113 const char kPnaclPluginDescription[] = "Portable Native Client Executable";
114 #endif // !defined(DISABLE_NACL)
115 #endif // defined(ENABLE_PLUGINS)
116
99 #if defined(ENABLE_REMOTING) 117 #if defined(ENABLE_REMOTING)
100 #if defined(GOOGLE_CHROME_BUILD) 118 #if defined(GOOGLE_CHROME_BUILD)
101 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer"; 119 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer";
102 #else 120 #else
103 const char kRemotingViewerPluginName[] = "Chromoting Viewer"; 121 const char kRemotingViewerPluginName[] = "Chromoting Viewer";
104 #endif // defined(GOOGLE_CHROME_BUILD) 122 #endif // defined(GOOGLE_CHROME_BUILD)
105 const char kRemotingViewerPluginDescription[] = 123 const char kRemotingViewerPluginDescription[] =
106 "This plugin allows you to securely access other computers that have been " 124 "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 " 125 "shared with you. To use this plugin you must first install the "
108 "<a href=\"https://chrome.google.com/remotedesktop\">" 126 "<a href=\"https://chrome.google.com/remotedesktop\">"
109 "Chrome Remote Desktop</a> webapp."; 127 "Chrome Remote Desktop</a> webapp.";
110 // Use a consistent MIME-type regardless of branding. 128 // Use a consistent MIME-type regardless of branding.
111 const char kRemotingViewerPluginMimeType[] = 129 const char kRemotingViewerPluginMimeType[] =
112 "application/vnd.chromium.remoting-viewer"; 130 "application/vnd.chromium.remoting-viewer";
113 const char kRemotingViewerPluginMimeExtension[] = ""; 131 const char kRemotingViewerPluginMimeExtension[] = "";
114 const char kRemotingViewerPluginMimeDescription[] = ""; 132 const char kRemotingViewerPluginMimeDescription[] = "";
115 const uint32 kRemotingViewerPluginPermissions = ppapi::PERMISSION_PRIVATE | 133 const uint32 kRemotingViewerPluginPermissions = ppapi::PERMISSION_PRIVATE |
116 ppapi::PERMISSION_DEV; 134 ppapi::PERMISSION_DEV;
117 #endif // defined(ENABLE_REMOTING) 135 #endif // defined(ENABLE_REMOTING)
118 136
137 #if defined(ENABLE_PLUGINS)
119 // Appends the known built-in plugins to the given vector. Some built-in 138 // 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, 139 // 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 140 // and some are extra shared libraries distributed with the browser (these are
122 // not marked internal, aside from being automatically registered, they're just 141 // not marked internal, aside from being automatically registered, they're just
123 // regular plugins). 142 // regular plugins).
124 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) { 143 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
125 // PDF. 144 // PDF.
126 // 145 //
127 // Once we're sandboxed, we can't know if the PDF plugin is available or not; 146 // 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. 147 // 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; 419 base::FilePath flash_path;
401 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path)) 420 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
402 return false; 421 return false;
403 422
404 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING); 423 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
405 return true; 424 return true;
406 #else 425 #else
407 return false; 426 return false;
408 #endif // FLAPPER_AVAILABLE 427 #endif // FLAPPER_AVAILABLE
409 } 428 }
429 #endif // defined(ENABLE_PLUGINS)
410 430
411 std::string GetProduct() { 431 std::string GetProduct() {
412 chrome::VersionInfo version_info; 432 chrome::VersionInfo version_info;
413 return version_info.is_valid() ? 433 return version_info.is_valid() ?
414 version_info.ProductNameAndVersionForUserAgent() : std::string(); 434 version_info.ProductNameAndVersionForUserAgent() : std::string();
415 } 435 }
416 436
417 } // namespace 437 } // namespace
418 438
419 std::string GetUserAgent() { 439 std::string GetUserAgent() {
(...skipping 30 matching lines...) Expand all
450 #if defined(OS_MACOSX) 470 #if defined(OS_MACOSX)
451 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version); 471 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version);
452 #elif defined(OS_POSIX) 472 #elif defined(OS_POSIX)
453 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor); 473 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
454 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer); 474 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
455 #endif 475 #endif
456 } 476 }
457 477
458 void ChromeContentClient::AddPepperPlugins( 478 void ChromeContentClient::AddPepperPlugins(
459 std::vector<content::PepperPluginInfo>* plugins) { 479 std::vector<content::PepperPluginInfo>* plugins) {
480 #if defined(ENABLE_PLUGINS)
460 ComputeBuiltInPlugins(plugins); 481 ComputeBuiltInPlugins(plugins);
461 AddPepperFlashFromCommandLine(plugins); 482 AddPepperFlashFromCommandLine(plugins);
462 483
463 content::PepperPluginInfo plugin; 484 content::PepperPluginInfo plugin;
464 if (GetBundledPepperFlash(&plugin)) 485 if (GetBundledPepperFlash(&plugin))
465 plugins->push_back(plugin); 486 plugins->push_back(plugin);
487 #endif
466 } 488 }
467 489
468 void ChromeContentClient::AddAdditionalSchemes( 490 void ChromeContentClient::AddAdditionalSchemes(
469 std::vector<std::string>* standard_schemes, 491 std::vector<std::string>* standard_schemes,
470 std::vector<std::string>* savable_schemes) { 492 std::vector<std::string>* savable_schemes) {
471 standard_schemes->push_back(extensions::kExtensionScheme); 493 standard_schemes->push_back(extensions::kExtensionScheme);
472 savable_schemes->push_back(extensions::kExtensionScheme); 494 savable_schemes->push_back(extensions::kExtensionScheme);
473 standard_schemes->push_back(chrome::kChromeNativeScheme); 495 standard_schemes->push_back(chrome::kChromeNativeScheme);
474 standard_schemes->push_back(extensions::kExtensionResourceScheme); 496 standard_schemes->push_back(extensions::kExtensionResourceScheme);
475 savable_schemes->push_back(extensions::kExtensionResourceScheme); 497 savable_schemes->push_back(extensions::kExtensionResourceScheme);
(...skipping 28 matching lines...) Expand all
504 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes( 526 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes(
505 int resource_id) const { 527 int resource_id) const {
506 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); 528 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
507 } 529 }
508 530
509 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const { 531 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const {
510 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); 532 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
511 } 533 }
512 534
513 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) { 535 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) {
536 #if !defined(DISABLE_NACL)
514 switch (type) { 537 switch (type) {
515 case PROCESS_TYPE_NACL_LOADER: 538 case PROCESS_TYPE_NACL_LOADER:
516 return "Native Client module"; 539 return "Native Client module";
517 case PROCESS_TYPE_NACL_BROKER: 540 case PROCESS_TYPE_NACL_BROKER:
518 return "Native Client broker"; 541 return "Native Client broker";
519 } 542 }
543 #endif
520 544
521 DCHECK(false) << "Unknown child process type!"; 545 NOTREACHED() << "Unknown child process type!";
522 return "Unknown"; 546 return "Unknown";
523 } 547 }
524 548
525 #if defined(OS_MACOSX) && !defined(OS_IOS) 549 #if defined(OS_MACOSX) && !defined(OS_IOS)
526 bool ChromeContentClient::GetSandboxProfileForSandboxType( 550 bool ChromeContentClient::GetSandboxProfileForSandboxType(
527 int sandbox_type, 551 int sandbox_type,
528 int* sandbox_profile_resource_id) const { 552 int* sandbox_profile_resource_id) const {
529 DCHECK(sandbox_profile_resource_id); 553 DCHECK(sandbox_profile_resource_id);
530 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) { 554 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) {
531 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE; 555 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE;
532 return true; 556 return true;
533 } 557 }
534 return false; 558 return false;
535 } 559 }
536 #endif 560 #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