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/data_reduction_proxy/content/common/data_reduction_proxy_messages.h"
34 #include "components/dom_distiller/core/url_constants.h"
35 #include "components/version_info/version_info.h"
36 #include "content/public/common/content_constants.h"
37 #include "content/public/common/content_switches.h"
38 #include "content/public/common/url_constants.h"
39 #include "content/public/common/user_agent.h"
40 #include "extensions/common/constants.h"
41 #include "gpu/config/gpu_info.h"
42 #include "net/http/http_util.h"
43 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/base/layout.h"
45 #include "ui/base/resource/resource_bundle.h"
47 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
50 #include "chrome/common/component_flash_hint_file_linux.h"
51 #endif // defined(OS_LINUX)
54 #include "base/win/registry.h"
55 #include "base/win/windows_version.h"
58 #if !defined(DISABLE_NACL)
59 #include "components/nacl/common/nacl_constants.h"
60 #include "components/nacl/common/nacl_process_type.h"
61 #include "components/nacl/common/nacl_sandbox_type.h"
64 #if defined(ENABLE_PLUGINS)
65 #include "content/public/common/pepper_plugin_info.h"
66 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR.
67 #include "ppapi/shared_impl/ppapi_permissions.h"
70 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
71 !defined(WIDEVINE_CDM_IS_COMPONENT)
72 #include "chrome/common/widevine_cdm_constants.h"
77 #if defined(ENABLE_PLUGINS)
78 #if defined(ENABLE_PDF)
79 const char kPDFPluginExtension
[] = "pdf";
80 const char kPDFPluginDescription
[] = "Portable Document Format";
81 const char kPDFPluginOutOfProcessMimeType
[] =
82 "application/x-google-chrome-pdf";
83 const uint32 kPDFPluginPermissions
= ppapi::PERMISSION_PRIVATE
|
84 ppapi::PERMISSION_DEV
;
85 #endif // defined(ENABLE_PDF)
87 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface
;
88 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module
;
89 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module
;
91 #if !defined(DISABLE_NACL)
92 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface
;
93 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module
;
94 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module
;
97 // Appends the known built-in plugins to the given vector. Some built-in
98 // plugins are "internal" which means they are compiled into the Chrome binary,
99 // and some are extra shared libraries distributed with the browser (these are
100 // not marked internal, aside from being automatically registered, they're just
102 void ComputeBuiltInPlugins(std::vector
<content::PepperPluginInfo
>* plugins
) {
103 #if defined(ENABLE_PDF)
104 content::PepperPluginInfo pdf_info
;
105 pdf_info
.is_internal
= true;
106 pdf_info
.is_out_of_process
= true;
107 pdf_info
.name
= ChromeContentClient::kPDFPluginName
;
108 pdf_info
.description
= kPDFPluginDescription
;
109 pdf_info
.path
= base::FilePath::FromUTF8Unsafe(
110 ChromeContentClient::kPDFPluginPath
);
111 content::WebPluginMimeType
pdf_mime_type(
112 kPDFPluginOutOfProcessMimeType
,
114 kPDFPluginDescription
);
115 pdf_info
.mime_types
.push_back(pdf_mime_type
);
116 pdf_info
.internal_entry_points
.get_interface
= g_pdf_get_interface
;
117 pdf_info
.internal_entry_points
.initialize_module
= g_pdf_initialize_module
;
118 pdf_info
.internal_entry_points
.shutdown_module
= g_pdf_shutdown_module
;
119 pdf_info
.permissions
= kPDFPluginPermissions
;
120 plugins
->push_back(pdf_info
);
121 #endif // defined(ENABLE_PDF)
125 #if !defined(DISABLE_NACL)
126 // Handle Native Client just like the PDF plugin. This means that it is
127 // enabled by default for the non-portable case. This allows apps installed
128 // from the Chrome Web Store to use NaCl even if the command line switch
129 // isn't set. For other uses of NaCl we check for the command line switch.
130 if (PathService::Get(chrome::FILE_NACL_PLUGIN
, &path
)) {
131 content::PepperPluginInfo nacl
;
132 // The nacl plugin is now built into the Chromium binary.
133 nacl
.is_internal
= true;
135 nacl
.name
= nacl::kNaClPluginName
;
136 content::WebPluginMimeType
nacl_mime_type(nacl::kNaClPluginMimeType
,
137 nacl::kNaClPluginExtension
,
138 nacl::kNaClPluginDescription
);
139 nacl
.mime_types
.push_back(nacl_mime_type
);
140 content::WebPluginMimeType
pnacl_mime_type(nacl::kPnaclPluginMimeType
,
141 nacl::kPnaclPluginExtension
,
142 nacl::kPnaclPluginDescription
);
143 nacl
.mime_types
.push_back(pnacl_mime_type
);
144 nacl
.internal_entry_points
.get_interface
= g_nacl_get_interface
;
145 nacl
.internal_entry_points
.initialize_module
= g_nacl_initialize_module
;
146 nacl
.internal_entry_points
.shutdown_module
= g_nacl_shutdown_module
;
147 nacl
.permissions
= ppapi::PERMISSION_PRIVATE
| ppapi::PERMISSION_DEV
;
148 plugins
->push_back(nacl
);
150 #endif // !defined(DISABLE_NACL)
152 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
153 !defined(WIDEVINE_CDM_IS_COMPONENT)
154 static bool skip_widevine_cdm_file_check
= false;
155 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER
, &path
)) {
156 if (skip_widevine_cdm_file_check
|| base::PathExists(path
)) {
157 content::PepperPluginInfo widevine_cdm
;
158 widevine_cdm
.is_out_of_process
= true;
159 widevine_cdm
.path
= path
;
160 widevine_cdm
.name
= kWidevineCdmDisplayName
;
161 widevine_cdm
.description
= kWidevineCdmDescription
+
162 std::string(" (version: ") +
163 WIDEVINE_CDM_VERSION_STRING
+ ")";
164 widevine_cdm
.version
= WIDEVINE_CDM_VERSION_STRING
;
165 content::WebPluginMimeType
widevine_cdm_mime_type(
166 kWidevineCdmPluginMimeType
,
167 kWidevineCdmPluginExtension
,
168 kWidevineCdmPluginMimeTypeDescription
);
170 // Add the supported codecs as if they came from the component manifest.
171 std::vector
<std::string
> codecs
;
172 codecs
.push_back(kCdmSupportedCodecVorbis
);
173 codecs
.push_back(kCdmSupportedCodecVp8
);
174 codecs
.push_back(kCdmSupportedCodecVp9
);
175 #if defined(USE_PROPRIETARY_CODECS)
176 codecs
.push_back(kCdmSupportedCodecAac
);
177 codecs
.push_back(kCdmSupportedCodecAvc1
);
178 #endif // defined(USE_PROPRIETARY_CODECS)
179 std::string codec_string
= base::JoinString(
180 codecs
, std::string(1, kCdmSupportedCodecsValueDelimiter
));
181 widevine_cdm_mime_type
.additional_param_names
.push_back(
182 base::ASCIIToUTF16(kCdmSupportedCodecsParamName
));
183 widevine_cdm_mime_type
.additional_param_values
.push_back(
184 base::ASCIIToUTF16(codec_string
));
186 widevine_cdm
.mime_types
.push_back(widevine_cdm_mime_type
);
187 widevine_cdm
.permissions
= kWidevineCdmPluginPermissions
;
188 plugins
->push_back(widevine_cdm
);
190 skip_widevine_cdm_file_check
= true;
193 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
194 // !defined(WIDEVINE_CDM_IS_COMPONENT)
197 content::PepperPluginInfo
CreatePepperFlashInfo(const base::FilePath
& path
,
198 const std::string
& version
) {
199 content::PepperPluginInfo plugin
;
201 plugin
.is_out_of_process
= true;
202 plugin
.name
= content::kFlashPluginName
;
204 plugin
.permissions
= chrome::kPepperFlashPermissions
;
206 std::vector
<std::string
> flash_version_numbers
= base::SplitString(
207 version
, ".", base::TRIM_WHITESPACE
, base::SPLIT_WANT_NONEMPTY
);
208 if (flash_version_numbers
.size() < 1)
209 flash_version_numbers
.push_back("11");
210 if (flash_version_numbers
.size() < 2)
211 flash_version_numbers
.push_back("2");
212 if (flash_version_numbers
.size() < 3)
213 flash_version_numbers
.push_back("999");
214 if (flash_version_numbers
.size() < 4)
215 flash_version_numbers
.push_back("999");
216 // E.g., "Shockwave Flash 10.2 r154":
217 plugin
.description
= plugin
.name
+ " " + flash_version_numbers
[0] + "." +
218 flash_version_numbers
[1] + " r" + flash_version_numbers
[2];
219 plugin
.version
= base::JoinString(flash_version_numbers
, ".");
220 content::WebPluginMimeType
swf_mime_type(content::kFlashPluginSwfMimeType
,
221 content::kFlashPluginSwfExtension
,
222 content::kFlashPluginSwfDescription
);
223 plugin
.mime_types
.push_back(swf_mime_type
);
224 content::WebPluginMimeType
spl_mime_type(content::kFlashPluginSplMimeType
,
225 content::kFlashPluginSplExtension
,
226 content::kFlashPluginSplDescription
);
227 plugin
.mime_types
.push_back(spl_mime_type
);
232 void AddPepperFlashFromCommandLine(
233 std::vector
<content::PepperPluginInfo
>* plugins
) {
234 const base::CommandLine::StringType flash_path
=
235 base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
236 switches::kPpapiFlashPath
);
237 if (flash_path
.empty())
240 // Also get the version from the command-line. Should be something like 11.2
242 std::string flash_version
=
243 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
244 switches::kPpapiFlashVersion
);
247 CreatePepperFlashInfo(base::FilePath(flash_path
), flash_version
));
250 #if defined(OS_LINUX)
251 // This function tests if DIR_USER_DATA can be accessed, as a simple check to
252 // see if the zygote has been sandboxed at this point.
253 bool IsUserDataDirAvailable() {
254 base::FilePath user_data_dir
;
255 return PathService::Get(chrome::DIR_USER_DATA
, &user_data_dir
);
258 // This method is used on Linux only because of architectural differences in how
259 // it loads the component updated flash plugin, and not because the other
260 // platforms do not support component updated flash. On other platforms, the
261 // component updater sends an IPC message to all threads, at undefined points in
262 // time, with the URL of the component updated flash. Because the linux zygote
263 // thread has no access to the file system after it warms up, it must preload
264 // the component updated flash.
265 bool GetComponentUpdatedPepperFlash(content::PepperPluginInfo
* plugin
) {
266 #if defined(FLAPPER_AVAILABLE)
267 if (component_flash_hint_file::DoesHintFileExist()) {
268 base::FilePath flash_path
;
270 if (component_flash_hint_file::VerifyAndReturnFlashLocation(&flash_path
,
272 // Test if the file can be mapped as executable. If the user's home
273 // directory is mounted noexec, the component flash plugin will not load.
274 // By testing for this, Chrome can fallback to the bundled flash plugin.
275 if (!component_flash_hint_file::TestExecutableMapping(flash_path
)) {
276 LOG(WARNING
) << "The component updated flash plugin could not be "
277 "mapped as executable. Attempting to fallback to the "
278 "bundled or system plugin.";
281 *plugin
= CreatePepperFlashInfo(flash_path
, version
);
285 << "Failed to locate and load the component updated flash plugin.";
287 #endif // defined(FLAPPER_AVAILABLE)
290 #endif // defined(OS_LINUX)
292 bool GetBundledPepperFlash(content::PepperPluginInfo
* plugin
) {
293 #if defined(FLAPPER_AVAILABLE)
294 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
296 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the
298 if (command_line
->HasSwitch(switches::kPpapiFlashPath
))
302 command_line
->HasSwitch(switches::kDisableBundledPpapiFlash
);
306 base::FilePath flash_path
;
307 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN
, &flash_path
))
310 *plugin
= CreatePepperFlashInfo(flash_path
, FLAPPER_VERSION_STRING
);
314 #endif // FLAPPER_AVAILABLE
317 #if defined(FLAPPER_AVAILABLE)
318 bool IsSystemFlashScriptDebuggerPresent() {
320 const wchar_t kFlashRegistryRoot
[] =
321 L
"SOFTWARE\\Macromedia\\FlashPlayerPepper";
322 const wchar_t kIsDebuggerValueName
[] = L
"isScriptDebugger";
324 base::win::RegKey
path_key(HKEY_LOCAL_MACHINE
, kFlashRegistryRoot
, KEY_READ
);
326 if (FAILED(path_key
.ReadValueDW(kIsDebuggerValueName
, &debug_value
)))
329 return (debug_value
== 1);
331 // TODO(wfh): implement this on OS X and Linux. crbug.com/497996.
337 bool GetSystemPepperFlash(content::PepperPluginInfo
* plugin
) {
338 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
340 #if defined(FLAPPER_AVAILABLE)
341 // If flapper is available, only try the system plugin if either:
342 // --disable-bundled-ppapi-flash is specified, or the system debugger is the
343 // Flash Script Debugger.
344 if (!command_line
->HasSwitch(switches::kDisableBundledPpapiFlash
) &&
345 !IsSystemFlashScriptDebuggerPresent())
347 #endif // defined(FLAPPER_AVAILABLE)
349 // Do not try and find System Pepper Flash if there is a specific path on
350 // the commmand-line.
351 if (command_line
->HasSwitch(switches::kPpapiFlashPath
))
354 base::FilePath flash_filename
;
355 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN
,
359 if (!base::PathExists(flash_filename
))
362 base::FilePath
manifest_path(
363 flash_filename
.DirName().AppendASCII("manifest.json"));
365 std::string manifest_data
;
366 if (!base::ReadFileToString(manifest_path
, &manifest_data
))
368 scoped_ptr
<base::Value
> manifest_value(
369 base::JSONReader::Read(manifest_data
, base::JSON_ALLOW_TRAILING_COMMAS
));
370 if (!manifest_value
.get())
372 base::DictionaryValue
* manifest
= NULL
;
373 if (!manifest_value
->GetAsDictionary(&manifest
))
377 if (!chrome::CheckPepperFlashManifest(*manifest
, &version
))
380 *plugin
= CreatePepperFlashInfo(flash_filename
, version
.GetString());
383 #endif // defined(ENABLE_PLUGINS)
385 std::string
GetProduct() {
386 return version_info::GetProductNameAndVersionForUserAgent();
391 std::string
GetUserAgent() {
392 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
393 if (command_line
->HasSwitch(switches::kUserAgent
)) {
394 std::string ua
= command_line
->GetSwitchValueASCII(switches::kUserAgent
);
395 if (net::HttpUtil::IsValidHeaderValue(ua
))
397 LOG(WARNING
) << "Ignored invalid value for flag --" << switches::kUserAgent
;
400 std::string product
= GetProduct();
401 #if defined(OS_ANDROID)
402 if (command_line
->HasSwitch(switches::kUseMobileUserAgent
))
403 product
+= " Mobile";
405 return content::BuildUserAgentFromProduct(product
);
408 #if !defined(DISABLE_NACL)
409 void ChromeContentClient::SetNaClEntryFunctions(
410 content::PepperPluginInfo::GetInterfaceFunc get_interface
,
411 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module
,
412 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module
) {
413 g_nacl_get_interface
= get_interface
;
414 g_nacl_initialize_module
= initialize_module
;
415 g_nacl_shutdown_module
= shutdown_module
;
419 #if defined(ENABLE_PLUGINS)
420 void ChromeContentClient::SetPDFEntryFunctions(
421 content::PepperPluginInfo::GetInterfaceFunc get_interface
,
422 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module
,
423 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module
) {
424 g_pdf_get_interface
= get_interface
;
425 g_pdf_initialize_module
= initialize_module
;
426 g_pdf_shutdown_module
= shutdown_module
;
430 void ChromeContentClient::SetActiveURL(const GURL
& url
) {
431 base::debug::SetCrashKeyValue(crash_keys::kActiveURL
,
432 url
.possibly_invalid_spec());
435 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo
& gpu_info
) {
436 #if !defined(OS_ANDROID)
437 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID
,
438 base::StringPrintf("0x%04x", gpu_info
.gpu
.vendor_id
));
439 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID
,
440 base::StringPrintf("0x%04x", gpu_info
.gpu
.device_id
));
442 base::debug::SetCrashKeyValue(crash_keys::kGPUDriverVersion
,
443 gpu_info
.driver_version
);
444 base::debug::SetCrashKeyValue(crash_keys::kGPUPixelShaderVersion
,
445 gpu_info
.pixel_shader_version
);
446 base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion
,
447 gpu_info
.vertex_shader_version
);
448 #if defined(OS_MACOSX)
449 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion
, gpu_info
.gl_version
);
450 #elif defined(OS_POSIX)
451 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor
, gpu_info
.gl_vendor
);
452 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer
, gpu_info
.gl_renderer
);
456 #if defined(ENABLE_PLUGINS)
458 content::PepperPluginInfo
* ChromeContentClient::FindMostRecentPlugin(
459 const std::vector
<content::PepperPluginInfo
*>& plugins
) {
460 auto it
= std::max_element(
461 plugins
.begin(), plugins
.end(),
462 [](content::PepperPluginInfo
* x
, content::PepperPluginInfo
* y
) {
463 Version
version_x(x
->version
);
464 DCHECK(version_x
.IsValid());
465 return version_x
.IsOlderThan(y
->version
);
467 return it
!= plugins
.end() ? *it
: nullptr;
469 #endif // defined(ENABLE_PLUGINS)
471 void ChromeContentClient::AddPepperPlugins(
472 std::vector
<content::PepperPluginInfo
>* plugins
) {
473 #if defined(ENABLE_PLUGINS)
474 ComputeBuiltInPlugins(plugins
);
475 AddPepperFlashFromCommandLine(plugins
);
477 #if defined(OS_LINUX)
478 // Depending on the sandbox configurtion, the user data directory
479 // is not always available. If it is not available, do not try and load any
480 // flash plugin. The flash player, if any, preloaded before the sandbox
481 // initialization will continue to be used.
482 if (!IsUserDataDirAvailable()) {
485 #endif // defined(OS_LINUX)
487 ScopedVector
<content::PepperPluginInfo
> flash_versions
;
489 #if defined(OS_LINUX)
490 scoped_ptr
<content::PepperPluginInfo
> component_flash(
491 new content::PepperPluginInfo
);
492 if (GetComponentUpdatedPepperFlash(component_flash
.get()))
493 flash_versions
.push_back(component_flash
.release());
494 #endif // defined(OS_LINUX)
496 scoped_ptr
<content::PepperPluginInfo
> bundled_flash(
497 new content::PepperPluginInfo
);
498 if (GetBundledPepperFlash(bundled_flash
.get()))
499 flash_versions
.push_back(bundled_flash
.release());
501 scoped_ptr
<content::PepperPluginInfo
> system_flash(
502 new content::PepperPluginInfo
);
503 if (GetSystemPepperFlash(system_flash
.get()))
504 flash_versions
.push_back(system_flash
.release());
506 // This function will return only the most recent version of the flash plugin.
507 content::PepperPluginInfo
* max_flash
=
508 FindMostRecentPlugin(flash_versions
.get());
510 plugins
->push_back(*max_flash
);
511 #endif // defined(ENABLE_PLUGINS)
514 #if defined(OS_CHROMEOS)
515 static const int kNumChromeStandardURLSchemes
= 6;
517 static const int kNumChromeStandardURLSchemes
= 5;
519 static const url::SchemeWithType kChromeStandardURLSchemes
[
520 kNumChromeStandardURLSchemes
] = {
521 {extensions::kExtensionScheme
, url::SCHEME_WITHOUT_PORT
},
522 {chrome::kChromeNativeScheme
, url::SCHEME_WITHOUT_PORT
},
523 {extensions::kExtensionResourceScheme
, url::SCHEME_WITHOUT_PORT
},
524 {chrome::kChromeSearchScheme
, url::SCHEME_WITHOUT_PORT
},
525 {dom_distiller::kDomDistillerScheme
, url::SCHEME_WITHOUT_PORT
},
526 #if defined(OS_CHROMEOS)
527 {chrome::kCrosScheme
, url::SCHEME_WITHOUT_PORT
},
531 void ChromeContentClient::AddAdditionalSchemes(
532 std::vector
<url::SchemeWithType
>* standard_schemes
,
533 std::vector
<std::string
>* savable_schemes
) {
534 for (int i
= 0; i
< kNumChromeStandardURLSchemes
; i
++)
535 standard_schemes
->push_back(kChromeStandardURLSchemes
[i
]);
537 savable_schemes
->push_back(extensions::kExtensionScheme
);
538 savable_schemes
->push_back(extensions::kExtensionResourceScheme
);
539 savable_schemes
->push_back(chrome::kChromeSearchScheme
);
540 savable_schemes
->push_back(dom_distiller::kDomDistillerScheme
);
543 bool ChromeContentClient::CanSendWhileSwappedOut(const IPC::Message
* message
) {
544 return message
->type() ==
545 DataReductionProxyViewHostMsg_DataReductionProxyStatus::ID
;
548 std::string
ChromeContentClient::GetProduct() const {
549 return ::GetProduct();
552 std::string
ChromeContentClient::GetUserAgent() const {
553 return ::GetUserAgent();
556 base::string16
ChromeContentClient::GetLocalizedString(int message_id
) const {
557 return l10n_util::GetStringUTF16(message_id
);
560 base::StringPiece
ChromeContentClient::GetDataResource(
562 ui::ScaleFactor scale_factor
) const {
563 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
564 resource_id
, scale_factor
);
567 base::RefCountedStaticMemory
* ChromeContentClient::GetDataResourceBytes(
568 int resource_id
) const {
569 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id
);
572 gfx::Image
& ChromeContentClient::GetNativeImageNamed(int resource_id
) const {
573 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id
);
576 std::string
ChromeContentClient::GetProcessTypeNameInEnglish(int type
) {
577 #if !defined(DISABLE_NACL)
579 case PROCESS_TYPE_NACL_LOADER
:
580 return "Native Client module";
581 case PROCESS_TYPE_NACL_BROKER
:
582 return "Native Client broker";
586 NOTREACHED() << "Unknown child process type!";
590 #if defined(OS_MACOSX) && !defined(OS_IOS)
591 bool ChromeContentClient::GetSandboxProfileForSandboxType(
593 int* sandbox_profile_resource_id
) const {
594 DCHECK(sandbox_profile_resource_id
);
595 #if !defined(DISABLE_NACL)
596 if (sandbox_type
== NACL_SANDBOX_TYPE_NACL_LOADER
) {
597 *sandbox_profile_resource_id
= IDR_NACL_SANDBOX_PROFILE
;
605 void ChromeContentClient::AddSecureSchemesAndOrigins(
606 std::set
<std::string
>* schemes
,
607 std::set
<GURL
>* origins
) {
608 schemes
->insert(chrome::kChromeSearchScheme
);
609 schemes
->insert(content::kChromeUIScheme
);
610 schemes
->insert(extensions::kExtensionScheme
);
611 schemes
->insert(extensions::kExtensionResourceScheme
);
612 GetSecureOriginWhitelist(origins
);
615 void ChromeContentClient::AddServiceWorkerSchemes(
616 std::set
<std::string
>* schemes
) {
617 schemes
->insert(extensions::kExtensionScheme
);