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
3 // found in the LICENSE file.
5 #include "chrome/common/chrome_content_client.h"
9 #endif // defined(OS_LINUX)
11 #include "base/command_line.h"
12 #include "base/debug/crash_logging.h"
13 #include "base/files/file_util.h"
14 #include "base/json/json_reader.h"
15 #include "base/memory/scoped_vector.h"
16 #include "base/path_service.h"
17 #include "base/strings/string16.h"
18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h"
23 #include "build/build_config.h"
24 #include "chrome/common/child_process_logging.h"
25 #include "chrome/common/chrome_constants.h"
26 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/crash_keys.h"
29 #include "chrome/common/pepper_flash.h"
30 #include "chrome/common/secure_origin_whitelist.h"
31 #include "chrome/common/url_constants.h"
32 #include "chrome/grit/common_resources.h"
33 #include "components/dom_distiller/core/url_constants.h"
34 #include "components/version_info/version_info.h"
35 #include "content/public/common/content_constants.h"
36 #include "content/public/common/content_switches.h"
37 #include "content/public/common/url_constants.h"
38 #include "content/public/common/user_agent.h"
39 #include "extensions/common/constants.h"
40 #include "gpu/config/gpu_info.h"
41 #include "net/http/http_util.h"
42 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/layout.h"
44 #include "ui/base/resource/resource_bundle.h"
46 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
49 #include "chrome/common/component_flash_hint_file_linux.h"
50 #endif // defined(OS_LINUX)
53 #include "base/win/registry.h"
54 #include "base/win/windows_version.h"
57 #if !defined(DISABLE_NACL)
58 #include "components/nacl/common/nacl_constants.h"
59 #include "components/nacl/common/nacl_process_type.h"
60 #include "components/nacl/common/nacl_sandbox_type.h"
63 #if defined(ENABLE_PLUGINS)
64 #include "content/public/common/pepper_plugin_info.h"
65 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR.
66 #include "ppapi/shared_impl/ppapi_permissions.h"
69 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
70 !defined(WIDEVINE_CDM_IS_COMPONENT)
71 #include "chrome/common/widevine_cdm_constants.h"
76 #if defined(ENABLE_PLUGINS)
77 #if defined(ENABLE_PDF)
78 const char kPDFPluginExtension
[] = "pdf";
79 const char kPDFPluginDescription
[] = "Portable Document Format";
80 const char kPDFPluginOutOfProcessMimeType
[] =
81 "application/x-google-chrome-pdf";
82 const uint32 kPDFPluginPermissions
= ppapi::PERMISSION_PRIVATE
|
83 ppapi::PERMISSION_DEV
;
84 #endif // defined(ENABLE_PDF)
86 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface
;
87 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module
;
88 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module
;
90 #if !defined(DISABLE_NACL)
91 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface
;
92 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module
;
93 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module
;
96 // Appends the known built-in plugins to the given vector. Some built-in
97 // plugins are "internal" which means they are compiled into the Chrome binary,
98 // and some are extra shared libraries distributed with the browser (these are
99 // not marked internal, aside from being automatically registered, they're just
101 void ComputeBuiltInPlugins(std::vector
<content::PepperPluginInfo
>* plugins
) {
102 #if defined(ENABLE_PDF)
103 content::PepperPluginInfo pdf_info
;
104 pdf_info
.is_internal
= true;
105 pdf_info
.is_out_of_process
= true;
106 pdf_info
.name
= ChromeContentClient::kPDFPluginName
;
107 pdf_info
.description
= kPDFPluginDescription
;
108 pdf_info
.path
= base::FilePath::FromUTF8Unsafe(
109 ChromeContentClient::kPDFPluginPath
);
110 content::WebPluginMimeType
pdf_mime_type(
111 kPDFPluginOutOfProcessMimeType
,
113 kPDFPluginDescription
);
114 pdf_info
.mime_types
.push_back(pdf_mime_type
);
115 pdf_info
.internal_entry_points
.get_interface
= g_pdf_get_interface
;
116 pdf_info
.internal_entry_points
.initialize_module
= g_pdf_initialize_module
;
117 pdf_info
.internal_entry_points
.shutdown_module
= g_pdf_shutdown_module
;
118 pdf_info
.permissions
= kPDFPluginPermissions
;
119 plugins
->push_back(pdf_info
);
120 #endif // defined(ENABLE_PDF)
124 #if !defined(DISABLE_NACL)
125 // Handle Native Client just like the PDF plugin. This means that it is
126 // enabled by default for the non-portable case. This allows apps installed
127 // from the Chrome Web Store to use NaCl even if the command line switch
128 // isn't set. For other uses of NaCl we check for the command line switch.
129 if (PathService::Get(chrome::FILE_NACL_PLUGIN
, &path
)) {
130 content::PepperPluginInfo nacl
;
131 // The nacl plugin is now built into the Chromium binary.
132 nacl
.is_internal
= true;
134 nacl
.name
= nacl::kNaClPluginName
;
135 content::WebPluginMimeType
nacl_mime_type(nacl::kNaClPluginMimeType
,
136 nacl::kNaClPluginExtension
,
137 nacl::kNaClPluginDescription
);
138 nacl
.mime_types
.push_back(nacl_mime_type
);
139 content::WebPluginMimeType
pnacl_mime_type(nacl::kPnaclPluginMimeType
,
140 nacl::kPnaclPluginExtension
,
141 nacl::kPnaclPluginDescription
);
142 nacl
.mime_types
.push_back(pnacl_mime_type
);
143 nacl
.internal_entry_points
.get_interface
= g_nacl_get_interface
;
144 nacl
.internal_entry_points
.initialize_module
= g_nacl_initialize_module
;
145 nacl
.internal_entry_points
.shutdown_module
= g_nacl_shutdown_module
;
146 nacl
.permissions
= ppapi::PERMISSION_PRIVATE
| ppapi::PERMISSION_DEV
;
147 plugins
->push_back(nacl
);
149 #endif // !defined(DISABLE_NACL)
151 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
152 !defined(WIDEVINE_CDM_IS_COMPONENT)
153 static bool skip_widevine_cdm_file_check
= false;
154 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER
, &path
)) {
155 if (skip_widevine_cdm_file_check
|| base::PathExists(path
)) {
156 content::PepperPluginInfo widevine_cdm
;
157 widevine_cdm
.is_out_of_process
= true;
158 widevine_cdm
.path
= path
;
159 widevine_cdm
.name
= kWidevineCdmDisplayName
;
160 widevine_cdm
.description
= kWidevineCdmDescription
+
161 std::string(" (version: ") +
162 WIDEVINE_CDM_VERSION_STRING
+ ")";
163 widevine_cdm
.version
= WIDEVINE_CDM_VERSION_STRING
;
164 content::WebPluginMimeType
widevine_cdm_mime_type(
165 kWidevineCdmPluginMimeType
,
166 kWidevineCdmPluginExtension
,
167 kWidevineCdmPluginMimeTypeDescription
);
169 // Add the supported codecs as if they came from the component manifest.
170 std::vector
<std::string
> codecs
;
171 codecs
.push_back(kCdmSupportedCodecVorbis
);
172 codecs
.push_back(kCdmSupportedCodecVp8
);
173 codecs
.push_back(kCdmSupportedCodecVp9
);
174 #if defined(USE_PROPRIETARY_CODECS)
175 codecs
.push_back(kCdmSupportedCodecAac
);
176 codecs
.push_back(kCdmSupportedCodecAvc1
);
177 #endif // defined(USE_PROPRIETARY_CODECS)
178 std::string codec_string
= base::JoinString(
179 codecs
, std::string(1, kCdmSupportedCodecsValueDelimiter
));
180 widevine_cdm_mime_type
.additional_param_names
.push_back(
181 base::ASCIIToUTF16(kCdmSupportedCodecsParamName
));
182 widevine_cdm_mime_type
.additional_param_values
.push_back(
183 base::ASCIIToUTF16(codec_string
));
185 widevine_cdm
.mime_types
.push_back(widevine_cdm_mime_type
);
186 widevine_cdm
.permissions
= kWidevineCdmPluginPermissions
;
187 plugins
->push_back(widevine_cdm
);
189 skip_widevine_cdm_file_check
= true;
192 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
193 // !defined(WIDEVINE_CDM_IS_COMPONENT)
196 content::PepperPluginInfo
CreatePepperFlashInfo(const base::FilePath
& path
,
197 const std::string
& version
) {
198 content::PepperPluginInfo plugin
;
200 plugin
.is_out_of_process
= true;
201 plugin
.name
= content::kFlashPluginName
;
203 plugin
.permissions
= chrome::kPepperFlashPermissions
;
205 std::vector
<std::string
> flash_version_numbers
= base::SplitString(
206 version
, ".", base::TRIM_WHITESPACE
, base::SPLIT_WANT_NONEMPTY
);
207 if (flash_version_numbers
.size() < 1)
208 flash_version_numbers
.push_back("11");
209 if (flash_version_numbers
.size() < 2)
210 flash_version_numbers
.push_back("2");
211 if (flash_version_numbers
.size() < 3)
212 flash_version_numbers
.push_back("999");
213 if (flash_version_numbers
.size() < 4)
214 flash_version_numbers
.push_back("999");
215 // E.g., "Shockwave Flash 10.2 r154":
216 plugin
.description
= plugin
.name
+ " " + flash_version_numbers
[0] + "." +
217 flash_version_numbers
[1] + " r" + flash_version_numbers
[2];
218 plugin
.version
= base::JoinString(flash_version_numbers
, ".");
219 content::WebPluginMimeType
swf_mime_type(content::kFlashPluginSwfMimeType
,
220 content::kFlashPluginSwfExtension
,
221 content::kFlashPluginSwfDescription
);
222 plugin
.mime_types
.push_back(swf_mime_type
);
223 content::WebPluginMimeType
spl_mime_type(content::kFlashPluginSplMimeType
,
224 content::kFlashPluginSplExtension
,
225 content::kFlashPluginSplDescription
);
226 plugin
.mime_types
.push_back(spl_mime_type
);
231 void AddPepperFlashFromCommandLine(
232 std::vector
<content::PepperPluginInfo
>* plugins
) {
233 const base::CommandLine::StringType flash_path
=
234 base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
235 switches::kPpapiFlashPath
);
236 if (flash_path
.empty())
239 // Also get the version from the command-line. Should be something like 11.2
241 std::string flash_version
=
242 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
243 switches::kPpapiFlashVersion
);
246 CreatePepperFlashInfo(base::FilePath(flash_path
), flash_version
));
249 #if defined(OS_LINUX)
250 // This function tests if DIR_USER_DATA can be accessed, as a simple check to
251 // see if the zygote has been sandboxed at this point.
252 bool IsUserDataDirAvailable() {
253 base::FilePath user_data_dir
;
254 return PathService::Get(chrome::DIR_USER_DATA
, &user_data_dir
);
257 // This method is used on Linux only because of architectural differences in how
258 // it loads the component updated flash plugin, and not because the other
259 // platforms do not support component updated flash. On other platforms, the
260 // component updater sends an IPC message to all threads, at undefined points in
261 // time, with the URL of the component updated flash. Because the linux zygote
262 // thread has no access to the file system after it warms up, it must preload
263 // the component updated flash.
264 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo
* plugin
) {
265 #if defined(FLAPPER_AVAILABLE)
266 if (component_flash_hint_file::DoesHintFileExist()) {
267 base::FilePath flash_path
;
269 if (component_flash_hint_file::VerifyAndReturnFlashLocation(&flash_path
,
271 // Test if the file can be mapped as executable. If the user's home
272 // directory is mounted noexec, the component flash plugin will not load.
273 // By testing for this, Chrome can fallback to the bundled flash plugin.
274 if (!component_flash_hint_file::TestExecutableMapping(flash_path
)) {
275 LOG(WARNING
) << "The component updated flash plugin could not be "
276 "mapped as executable. Attempting to fallback to the "
277 "bundled or system plugin.";
280 *plugin
= CreatePepperFlashInfo(flash_path
, version
);
284 << "Failed to locate and load the component updated flash plugin.";
286 #endif // defined(FLAPPER_AVAILABLE)
289 #endif // defined(OS_LINUX)
291 bool GetBundledPepperFlash(content::PepperPluginInfo
* plugin
) {
292 #if defined(FLAPPER_AVAILABLE)
293 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
295 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the
297 if (command_line
->HasSwitch(switches::kPpapiFlashPath
))
301 command_line
->HasSwitch(switches::kDisableBundledPpapiFlash
);
305 base::FilePath flash_path
;
306 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN
, &flash_path
))
309 *plugin
= CreatePepperFlashInfo(flash_path
, FLAPPER_VERSION_STRING
);
313 #endif // FLAPPER_AVAILABLE
316 #if defined(FLAPPER_AVAILABLE)
317 bool IsSystemFlashScriptDebuggerPresent() {
319 const wchar_t kFlashRegistryRoot
[] =
320 L
"SOFTWARE\\Macromedia\\FlashPlayerPepper";
321 const wchar_t kIsDebuggerValueName
[] = L
"isScriptDebugger";
323 base::win::RegKey
path_key(HKEY_LOCAL_MACHINE
, kFlashRegistryRoot
, KEY_READ
);
325 if (FAILED(path_key
.ReadValueDW(kIsDebuggerValueName
, &debug_value
)))
328 return (debug_value
== 1);
330 // TODO(wfh): implement this on OS X and Linux. crbug.com/497996.
336 bool GetSystemPepperFlash(content::PepperPluginInfo
* plugin
) {
337 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
339 #if defined(FLAPPER_AVAILABLE)
340 // If flapper is available, only try the system plugin if either:
341 // --disable-bundled-ppapi-flash is specified, or the system debugger is the
342 // Flash Script Debugger.
343 if (!command_line
->HasSwitch(switches::kDisableBundledPpapiFlash
) &&
344 !IsSystemFlashScriptDebuggerPresent())
346 #endif // defined(FLAPPER_AVAILABLE)
348 // Do not try and find System Pepper Flash if there is a specific path on
349 // the commmand-line.
350 if (command_line
->HasSwitch(switches::kPpapiFlashPath
))
353 base::FilePath flash_filename
;
354 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN
,
358 if (!base::PathExists(flash_filename
))
361 base::FilePath
manifest_path(
362 flash_filename
.DirName().AppendASCII("manifest.json"));
364 std::string manifest_data
;
365 if (!base::ReadFileToString(manifest_path
, &manifest_data
))
367 scoped_ptr
<base::Value
> manifest_value(
368 base::JSONReader::Read(manifest_data
, base::JSON_ALLOW_TRAILING_COMMAS
));
369 if (!manifest_value
.get())
371 base::DictionaryValue
* manifest
= NULL
;
372 if (!manifest_value
->GetAsDictionary(&manifest
))
376 if (!chrome::CheckPepperFlashManifest(*manifest
, &version
))
379 *plugin
= CreatePepperFlashInfo(flash_filename
, version
.GetString());
382 #endif // defined(ENABLE_PLUGINS)
384 std::string
GetProduct() {
385 return version_info::GetProductNameAndVersionForUserAgent();
390 std::string
GetUserAgent() {
391 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
392 if (command_line
->HasSwitch(switches::kUserAgent
)) {
393 std::string ua
= command_line
->GetSwitchValueASCII(switches::kUserAgent
);
394 if (net::HttpUtil::IsValidHeaderValue(ua
))
396 LOG(WARNING
) << "Ignored invalid value for flag --" << switches::kUserAgent
;
399 std::string product
= GetProduct();
400 #if defined(OS_ANDROID)
401 if (command_line
->HasSwitch(switches::kUseMobileUserAgent
))
402 product
+= " Mobile";
404 return content::BuildUserAgentFromProduct(product
);
407 #if !defined(DISABLE_NACL)
408 void ChromeContentClient::SetNaClEntryFunctions(
409 content::PepperPluginInfo::GetInterfaceFunc get_interface
,
410 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module
,
411 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module
) {
412 g_nacl_get_interface
= get_interface
;
413 g_nacl_initialize_module
= initialize_module
;
414 g_nacl_shutdown_module
= shutdown_module
;
418 #if defined(ENABLE_PLUGINS)
419 void ChromeContentClient::SetPDFEntryFunctions(
420 content::PepperPluginInfo::GetInterfaceFunc get_interface
,
421 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module
,
422 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module
) {
423 g_pdf_get_interface
= get_interface
;
424 g_pdf_initialize_module
= initialize_module
;
425 g_pdf_shutdown_module
= shutdown_module
;
429 void ChromeContentClient::SetActiveURL(const GURL
& url
) {
430 base::debug::SetCrashKeyValue(crash_keys::kActiveURL
,
431 url
.possibly_invalid_spec());
434 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo
& gpu_info
) {
435 #if !defined(OS_ANDROID)
436 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID
,
437 base::StringPrintf("0x%04x", gpu_info
.gpu
.vendor_id
));
438 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID
,
439 base::StringPrintf("0x%04x", gpu_info
.gpu
.device_id
));
441 base::debug::SetCrashKeyValue(crash_keys::kGPUDriverVersion
,
442 gpu_info
.driver_version
);
443 base::debug::SetCrashKeyValue(crash_keys::kGPUPixelShaderVersion
,
444 gpu_info
.pixel_shader_version
);
445 base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion
,
446 gpu_info
.vertex_shader_version
);
447 #if defined(OS_MACOSX)
448 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion
, gpu_info
.gl_version
);
449 #elif defined(OS_POSIX)
450 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor
, gpu_info
.gl_vendor
);
451 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer
, gpu_info
.gl_renderer
);
455 #if defined(ENABLE_PLUGINS)
457 content::PepperPluginInfo
* ChromeContentClient::FindMostRecentPlugin(
458 const std::vector
<content::PepperPluginInfo
*>& plugins
) {
459 auto it
= std::max_element(
460 plugins
.begin(), plugins
.end(),
461 [](content::PepperPluginInfo
* x
, content::PepperPluginInfo
* y
) {
462 Version
version_x(x
->version
);
463 DCHECK(version_x
.IsValid());
464 return version_x
.IsOlderThan(y
->version
);
466 return it
!= plugins
.end() ? *it
: nullptr;
468 #endif // defined(ENABLE_PLUGINS)
470 void ChromeContentClient::AddPepperPlugins(
471 std::vector
<content::PepperPluginInfo
>* plugins
) {
472 #if defined(ENABLE_PLUGINS)
473 ComputeBuiltInPlugins(plugins
);
474 AddPepperFlashFromCommandLine(plugins
);
476 #if defined(OS_LINUX)
477 // Depending on the sandbox configurtion, the user data directory
478 // is not always available. If it is not available, do not try and load any
479 // flash plugin. The flash player, if any, preloaded before the sandbox
480 // initialization will continue to be used.
481 if (!IsUserDataDirAvailable()) {
484 #endif // defined(OS_LINUX)
486 ScopedVector
<content::PepperPluginInfo
> flash_versions
;
488 #if defined(OS_LINUX)
489 scoped_ptr
<content::PepperPluginInfo
> component_flash(
490 new content::PepperPluginInfo
);
491 if (GetComponentUpdatedPepperFlash(component_flash
.get()))
492 flash_versions
.push_back(component_flash
.release());
493 #endif // defined(OS_LINUX)
495 scoped_ptr
<content::PepperPluginInfo
> bundled_flash(
496 new content::PepperPluginInfo
);
497 if (GetBundledPepperFlash(bundled_flash
.get()))
498 flash_versions
.push_back(bundled_flash
.release());
500 scoped_ptr
<content::PepperPluginInfo
> system_flash(
501 new content::PepperPluginInfo
);
502 if (GetSystemPepperFlash(system_flash
.get()))
503 flash_versions
.push_back(system_flash
.release());
505 // This function will return only the most recent version of the flash plugin.
506 content::PepperPluginInfo
* max_flash
=
507 FindMostRecentPlugin(flash_versions
.get());
509 plugins
->push_back(*max_flash
);
510 #endif // defined(ENABLE_PLUGINS)
513 #if defined(OS_CHROMEOS)
514 static const int kNumChromeStandardURLSchemes
= 6;
516 static const int kNumChromeStandardURLSchemes
= 5;
518 static const url::SchemeWithType kChromeStandardURLSchemes
[
519 kNumChromeStandardURLSchemes
] = {
520 {extensions::kExtensionScheme
, url::SCHEME_WITHOUT_PORT
},
521 {chrome::kChromeNativeScheme
, url::SCHEME_WITHOUT_PORT
},
522 {extensions::kExtensionResourceScheme
, url::SCHEME_WITHOUT_PORT
},
523 {chrome::kChromeSearchScheme
, url::SCHEME_WITHOUT_PORT
},
524 {dom_distiller::kDomDistillerScheme
, url::SCHEME_WITHOUT_PORT
},
525 #if defined(OS_CHROMEOS)
526 {chrome::kCrosScheme
, url::SCHEME_WITHOUT_PORT
},
530 void ChromeContentClient::AddAdditionalSchemes(
531 std::vector
<url::SchemeWithType
>* standard_schemes
,
532 std::vector
<std::string
>* savable_schemes
) {
533 for (int i
= 0; i
< kNumChromeStandardURLSchemes
; i
++)
534 standard_schemes
->push_back(kChromeStandardURLSchemes
[i
]);
536 savable_schemes
->push_back(extensions::kExtensionScheme
);
537 savable_schemes
->push_back(extensions::kExtensionResourceScheme
);
538 savable_schemes
->push_back(chrome::kChromeSearchScheme
);
539 savable_schemes
->push_back(dom_distiller::kDomDistillerScheme
);
542 std::string
ChromeContentClient::GetProduct() const {
543 return ::GetProduct();
546 std::string
ChromeContentClient::GetUserAgent() const {
547 return ::GetUserAgent();
550 base::string16
ChromeContentClient::GetLocalizedString(int message_id
) const {
551 return l10n_util::GetStringUTF16(message_id
);
554 base::StringPiece
ChromeContentClient::GetDataResource(
556 ui::ScaleFactor scale_factor
) const {
557 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
558 resource_id
, scale_factor
);
561 base::RefCountedStaticMemory
* ChromeContentClient::GetDataResourceBytes(
562 int resource_id
) const {
563 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id
);
566 gfx::Image
& ChromeContentClient::GetNativeImageNamed(int resource_id
) const {
567 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id
);
570 std::string
ChromeContentClient::GetProcessTypeNameInEnglish(int type
) {
571 #if !defined(DISABLE_NACL)
573 case PROCESS_TYPE_NACL_LOADER
:
574 return "Native Client module";
575 case PROCESS_TYPE_NACL_BROKER
:
576 return "Native Client broker";
580 NOTREACHED() << "Unknown child process type!";
584 #if defined(OS_MACOSX) && !defined(OS_IOS)
585 bool ChromeContentClient::GetSandboxProfileForSandboxType(
587 int* sandbox_profile_resource_id
) const {
588 DCHECK(sandbox_profile_resource_id
);
589 #if !defined(DISABLE_NACL)
590 if (sandbox_type
== NACL_SANDBOX_TYPE_NACL_LOADER
) {
591 *sandbox_profile_resource_id
= IDR_NACL_SANDBOX_PROFILE
;
599 void ChromeContentClient::AddSecureSchemesAndOrigins(
600 std::set
<std::string
>* schemes
,
601 std::set
<GURL
>* origins
) {
602 schemes
->insert(chrome::kChromeSearchScheme
);
603 schemes
->insert(content::kChromeUIScheme
);
604 schemes
->insert(extensions::kExtensionScheme
);
605 schemes
->insert(extensions::kExtensionResourceScheme
);
606 GetSecureOriginWhitelist(origins
);
609 void ChromeContentClient::AddServiceWorkerSchemes(
610 std::set
<std::string
>* schemes
) {
611 schemes
->insert(extensions::kExtensionScheme
);