Roll src/third_party/skia a6ae14e:85693c1
[chromium-blink-merge.git] / chrome / common / chrome_content_client.cc
blobce52fa34e6201d6fbac6fb4ac1efb429e50c16da
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"
7 #include "base/command_line.h"
8 #include "base/debug/crash_logging.h"
9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h"
11 #include "base/path_service.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h"
18 #include "build/build_config.h"
19 #include "chrome/common/child_process_logging.h"
20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/chrome_version_info.h"
24 #include "chrome/common/crash_keys.h"
25 #include "chrome/common/pepper_flash.h"
26 #include "chrome/common/render_messages.h"
27 #include "chrome/common/secure_origin_whitelist.h"
28 #include "chrome/common/url_constants.h"
29 #include "chrome/grit/common_resources.h"
30 #include "components/dom_distiller/core/url_constants.h"
31 #include "content/public/common/content_constants.h"
32 #include "content/public/common/content_switches.h"
33 #include "content/public/common/url_constants.h"
34 #include "content/public/common/user_agent.h"
35 #include "extensions/common/constants.h"
36 #include "gpu/config/gpu_info.h"
37 #include "net/http/http_util.h"
38 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/layout.h"
40 #include "ui/base/resource/resource_bundle.h"
42 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
44 #if defined(OS_WIN)
45 #include "base/win/registry.h"
46 #include "base/win/windows_version.h"
47 #endif
49 #if !defined(DISABLE_NACL)
50 #include "components/nacl/common/nacl_constants.h"
51 #include "components/nacl/common/nacl_process_type.h"
52 #include "components/nacl/common/nacl_sandbox_type.h"
53 #endif
55 #if defined(ENABLE_PLUGINS)
56 #include "chrome/common/pepper_flash.h"
57 #include "content/public/common/pepper_plugin_info.h"
58 #include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR.
59 #include "ppapi/shared_impl/ppapi_permissions.h"
60 #endif
62 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
63 !defined(WIDEVINE_CDM_IS_COMPONENT)
64 #include "chrome/common/widevine_cdm_constants.h"
65 #endif
67 namespace {
69 #if defined(ENABLE_PLUGINS)
70 const char kPDFPluginExtension[] = "pdf";
71 const char kPDFPluginDescription[] = "Portable Document Format";
72 const char kPDFPluginOutOfProcessMimeType[] =
73 "application/x-google-chrome-pdf";
74 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE |
75 ppapi::PERMISSION_DEV;
77 content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface;
78 content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module;
79 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_pdf_shutdown_module;
81 #if defined(ENABLE_REMOTING)
83 content::PepperPluginInfo::GetInterfaceFunc g_remoting_get_interface;
84 content::PepperPluginInfo::PPP_InitializeModuleFunc
85 g_remoting_initialize_module;
86 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_remoting_shutdown_module;
88 #if defined(GOOGLE_CHROME_BUILD)
89 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer";
90 #else
91 const char kRemotingViewerPluginName[] = "Chromoting Viewer";
92 #endif // defined(GOOGLE_CHROME_BUILD)
93 const char kRemotingViewerPluginDescription[] =
94 "This plugin allows you to securely access other computers that have been "
95 "shared with you. To use this plugin you must first install the "
96 "<a href=\"https://chrome.google.com/remotedesktop\">"
97 "Chrome Remote Desktop</a> webapp.";
98 // Use a consistent MIME-type regardless of branding.
99 const char kRemotingViewerPluginMimeType[] =
100 "application/vnd.chromium.remoting-viewer";
101 const char kRemotingViewerPluginMimeExtension[] = "";
102 const char kRemotingViewerPluginMimeDescription[] = "";
103 const uint32 kRemotingViewerPluginPermissions = ppapi::PERMISSION_PRIVATE |
104 ppapi::PERMISSION_DEV;
105 #endif // defined(ENABLE_REMOTING)
107 #if !defined(DISABLE_NACL)
108 content::PepperPluginInfo::GetInterfaceFunc g_nacl_get_interface;
109 content::PepperPluginInfo::PPP_InitializeModuleFunc g_nacl_initialize_module;
110 content::PepperPluginInfo::PPP_ShutdownModuleFunc g_nacl_shutdown_module;
111 #endif
113 // Appends the known built-in plugins to the given vector. Some built-in
114 // plugins are "internal" which means they are compiled into the Chrome binary,
115 // and some are extra shared libraries distributed with the browser (these are
116 // not marked internal, aside from being automatically registered, they're just
117 // regular plugins).
118 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
119 content::PepperPluginInfo pdf_info;
120 pdf_info.is_internal = true;
121 pdf_info.is_out_of_process = true;
122 pdf_info.name = ChromeContentClient::kPDFPluginName;
123 pdf_info.description = kPDFPluginDescription;
124 pdf_info.path = base::FilePath::FromUTF8Unsafe(
125 ChromeContentClient::kPDFPluginPath);
126 content::WebPluginMimeType pdf_mime_type(
127 kPDFPluginOutOfProcessMimeType,
128 kPDFPluginExtension,
129 kPDFPluginDescription);
130 pdf_info.mime_types.push_back(pdf_mime_type);
131 pdf_info.internal_entry_points.get_interface = g_pdf_get_interface;
132 pdf_info.internal_entry_points.initialize_module = g_pdf_initialize_module;
133 pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module;
134 pdf_info.permissions = kPDFPluginPermissions;
135 plugins->push_back(pdf_info);
137 base::FilePath path;
139 #if !defined(DISABLE_NACL)
140 // Handle Native Client just like the PDF plugin. This means that it is
141 // enabled by default for the non-portable case. This allows apps installed
142 // from the Chrome Web Store to use NaCl even if the command line switch
143 // isn't set. For other uses of NaCl we check for the command line switch.
144 if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
145 content::PepperPluginInfo nacl;
146 // The nacl plugin is now built into the Chromium binary.
147 nacl.is_internal = true;
148 nacl.path = path;
149 nacl.name = nacl::kNaClPluginName;
150 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType,
151 nacl::kNaClPluginExtension,
152 nacl::kNaClPluginDescription);
153 nacl.mime_types.push_back(nacl_mime_type);
154 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType,
155 nacl::kPnaclPluginExtension,
156 nacl::kPnaclPluginDescription);
157 nacl.mime_types.push_back(pnacl_mime_type);
158 nacl.internal_entry_points.get_interface = g_nacl_get_interface;
159 nacl.internal_entry_points.initialize_module = g_nacl_initialize_module;
160 nacl.internal_entry_points.shutdown_module = g_nacl_shutdown_module;
161 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
162 plugins->push_back(nacl);
164 #endif // !defined(DISABLE_NACL)
166 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
167 !defined(WIDEVINE_CDM_IS_COMPONENT)
168 static bool skip_widevine_cdm_file_check = false;
169 if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) {
170 if (skip_widevine_cdm_file_check || base::PathExists(path)) {
171 content::PepperPluginInfo widevine_cdm;
172 widevine_cdm.is_out_of_process = true;
173 widevine_cdm.path = path;
174 widevine_cdm.name = kWidevineCdmDisplayName;
175 widevine_cdm.description = kWidevineCdmDescription +
176 std::string(" (version: ") +
177 WIDEVINE_CDM_VERSION_STRING + ")";
178 widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
179 content::WebPluginMimeType widevine_cdm_mime_type(
180 kWidevineCdmPluginMimeType,
181 kWidevineCdmPluginExtension,
182 kWidevineCdmPluginMimeTypeDescription);
184 // Add the supported codecs as if they came from the component manifest.
185 std::vector<std::string> codecs;
186 codecs.push_back(kCdmSupportedCodecVorbis);
187 codecs.push_back(kCdmSupportedCodecVp8);
188 codecs.push_back(kCdmSupportedCodecVp9);
189 #if defined(USE_PROPRIETARY_CODECS)
190 codecs.push_back(kCdmSupportedCodecAac);
191 codecs.push_back(kCdmSupportedCodecAvc1);
192 #endif // defined(USE_PROPRIETARY_CODECS)
193 std::string codec_string = base::JoinString(
194 codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
195 widevine_cdm_mime_type.additional_param_names.push_back(
196 base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
197 widevine_cdm_mime_type.additional_param_values.push_back(
198 base::ASCIIToUTF16(codec_string));
200 widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
201 widevine_cdm.permissions = kWidevineCdmPluginPermissions;
202 plugins->push_back(widevine_cdm);
204 skip_widevine_cdm_file_check = true;
207 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
208 // !defined(WIDEVINE_CDM_IS_COMPONENT)
210 // The Remoting Viewer plugin is built-in.
211 #if defined(ENABLE_REMOTING)
212 content::PepperPluginInfo info;
213 info.is_internal = true;
214 info.is_out_of_process = true;
215 info.name = kRemotingViewerPluginName;
216 info.description = kRemotingViewerPluginDescription;
217 info.path = base::FilePath::FromUTF8Unsafe(
218 ChromeContentClient::kRemotingViewerPluginPath);
219 content::WebPluginMimeType remoting_mime_type(
220 kRemotingViewerPluginMimeType,
221 kRemotingViewerPluginMimeExtension,
222 kRemotingViewerPluginMimeDescription);
223 info.mime_types.push_back(remoting_mime_type);
224 info.internal_entry_points.get_interface = g_remoting_get_interface;
225 info.internal_entry_points.initialize_module = g_remoting_initialize_module;
226 info.internal_entry_points.shutdown_module = g_remoting_shutdown_module;
227 info.permissions = kRemotingViewerPluginPermissions;
229 plugins->push_back(info);
230 #endif
233 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
234 const std::string& version) {
235 content::PepperPluginInfo plugin;
237 plugin.is_out_of_process = true;
238 plugin.name = content::kFlashPluginName;
239 plugin.path = path;
240 plugin.permissions = chrome::kPepperFlashPermissions;
242 std::vector<std::string> flash_version_numbers;
243 base::SplitString(version, '.', &flash_version_numbers);
244 if (flash_version_numbers.size() < 1)
245 flash_version_numbers.push_back("11");
246 // |SplitString()| puts in an empty string given an empty string. :(
247 else if (flash_version_numbers[0].empty())
248 flash_version_numbers[0] = "11";
249 if (flash_version_numbers.size() < 2)
250 flash_version_numbers.push_back("2");
251 if (flash_version_numbers.size() < 3)
252 flash_version_numbers.push_back("999");
253 if (flash_version_numbers.size() < 4)
254 flash_version_numbers.push_back("999");
255 // E.g., "Shockwave Flash 10.2 r154":
256 plugin.description = plugin.name + " " + flash_version_numbers[0] + "." +
257 flash_version_numbers[1] + " r" + flash_version_numbers[2];
258 plugin.version = base::JoinString(flash_version_numbers, ".");
259 content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType,
260 content::kFlashPluginSwfExtension,
261 content::kFlashPluginSwfDescription);
262 plugin.mime_types.push_back(swf_mime_type);
263 content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType,
264 content::kFlashPluginSplExtension,
265 content::kFlashPluginSplDescription);
266 plugin.mime_types.push_back(spl_mime_type);
268 return plugin;
271 void AddPepperFlashFromCommandLine(
272 std::vector<content::PepperPluginInfo>* plugins) {
273 const base::CommandLine::StringType flash_path =
274 base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(
275 switches::kPpapiFlashPath);
276 if (flash_path.empty())
277 return;
279 // Also get the version from the command-line. Should be something like 11.2
280 // or 11.2.123.45.
281 std::string flash_version =
282 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
283 switches::kPpapiFlashVersion);
285 plugins->push_back(
286 CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
289 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
290 #if defined(FLAPPER_AVAILABLE)
291 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
293 // Ignore bundled Pepper Flash if there is Pepper Flash specified from the
294 // command-line.
295 if (command_line->HasSwitch(switches::kPpapiFlashPath))
296 return false;
298 bool force_disable =
299 command_line->HasSwitch(switches::kDisableBundledPpapiFlash);
300 if (force_disable)
301 return false;
303 base::FilePath flash_path;
304 if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
305 return false;
307 *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
308 return true;
309 #else
310 return false;
311 #endif // FLAPPER_AVAILABLE
314 #if defined(OS_WIN)
315 const char kPepperFlashDLLBaseName[] =
316 #if defined(ARCH_CPU_X86)
317 "pepflashplayer32_";
318 #elif defined(ARCH_CPU_X86_64)
319 "pepflashplayer64_";
320 #else
321 #error Unsupported Windows CPU architecture.
322 #endif // defined(ARCH_CPU_X86)
323 #endif // defined(OS_WIN)
325 #if defined(FLAPPER_AVAILABLE)
326 bool IsSystemFlashScriptDebuggerPresent() {
327 #if defined(OS_WIN)
328 const wchar_t kFlashRegistryRoot[] =
329 L"SOFTWARE\\Macromedia\\FlashPlayerPepper";
330 const wchar_t kIsDebuggerValueName[] = L"isScriptDebugger";
332 base::win::RegKey path_key(HKEY_LOCAL_MACHINE, kFlashRegistryRoot, KEY_READ);
333 DWORD debug_value;
334 if (FAILED(path_key.ReadValueDW(kIsDebuggerValueName, &debug_value)))
335 return false;
337 return (debug_value == 1);
338 #else
339 // TODO(wfh): implement this on OS X and Linux. crbug.com/497996.
340 return false;
341 #endif
343 #endif
345 bool GetSystemPepperFlash(content::PepperPluginInfo* plugin) {
346 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
348 #if defined(FLAPPER_AVAILABLE)
349 // If flapper is available, only try the system plugin if either:
350 // --disable-bundled-ppapi-flash is specified, or the system debugger is the
351 // Flash Script Debugger.
352 if (!command_line->HasSwitch(switches::kDisableBundledPpapiFlash) &&
353 !IsSystemFlashScriptDebuggerPresent())
354 return false;
355 #endif // defined(FLAPPER_AVAILABLE)
357 // Do not try and find System Pepper Flash if there is a specific path on
358 // the commmand-line.
359 if (command_line->HasSwitch(switches::kPpapiFlashPath))
360 return false;
362 base::FilePath flash_path;
363 if (!PathService::Get(chrome::DIR_PEPPER_FLASH_SYSTEM_PLUGIN, &flash_path))
364 return false;
366 if (!base::PathExists(flash_path))
367 return false;
369 base::FilePath manifest_path(flash_path.AppendASCII("manifest.json"));
371 std::string manifest_data;
372 if (!base::ReadFileToString(manifest_path, &manifest_data))
373 return false;
374 scoped_ptr<base::Value> manifest_value(
375 base::JSONReader::Read(manifest_data, base::JSON_ALLOW_TRAILING_COMMAS));
376 if (!manifest_value.get())
377 return false;
378 base::DictionaryValue* manifest = NULL;
379 if (!manifest_value->GetAsDictionary(&manifest))
380 return false;
382 Version version;
383 if (!chrome::CheckPepperFlashManifest(*manifest, &version))
384 return false;
386 #if defined(OS_WIN)
387 // PepperFlash DLLs on Windows look like basename_v_x_y_z.dll.
388 std::string filename(kPepperFlashDLLBaseName);
389 filename.append(version.GetString());
390 base::ReplaceChars(filename, ".", "_", &filename);
391 filename.append(".dll");
393 base::FilePath path(flash_path.Append(base::ASCIIToUTF16(filename)));
394 #else
395 // PepperFlash on OS X is called PepperFlashPlayer.plugin
396 base::FilePath path(flash_path.Append(chrome::kPepperFlashPluginFilename));
397 #endif
399 if (!base::PathExists(path))
400 return false;
402 *plugin = CreatePepperFlashInfo(path, version.GetString());
403 return true;
405 #endif // defined(ENABLE_PLUGINS)
407 std::string GetProduct() {
408 chrome::VersionInfo version_info;
409 return version_info.ProductNameAndVersionForUserAgent();
412 } // namespace
414 std::string GetUserAgent() {
415 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
416 if (command_line->HasSwitch(switches::kUserAgent)) {
417 std::string ua = command_line->GetSwitchValueASCII(switches::kUserAgent);
418 if (net::HttpUtil::IsValidHeaderValue(ua))
419 return ua;
420 LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent;
423 std::string product = GetProduct();
424 #if defined(OS_ANDROID)
425 if (command_line->HasSwitch(switches::kUseMobileUserAgent))
426 product += " Mobile";
427 #endif
428 return content::BuildUserAgentFromProduct(product);
432 #if defined(ENABLE_REMOTING)
434 void ChromeContentClient::SetRemotingEntryFunctions(
435 content::PepperPluginInfo::GetInterfaceFunc get_interface,
436 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module,
437 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) {
438 g_remoting_get_interface = get_interface;
439 g_remoting_initialize_module = initialize_module;
440 g_remoting_shutdown_module = shutdown_module;
442 #endif
444 #if !defined(DISABLE_NACL)
445 void ChromeContentClient::SetNaClEntryFunctions(
446 content::PepperPluginInfo::GetInterfaceFunc get_interface,
447 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module,
448 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) {
449 g_nacl_get_interface = get_interface;
450 g_nacl_initialize_module = initialize_module;
451 g_nacl_shutdown_module = shutdown_module;
453 #endif
455 #if defined(ENABLE_PLUGINS)
456 void ChromeContentClient::SetPDFEntryFunctions(
457 content::PepperPluginInfo::GetInterfaceFunc get_interface,
458 content::PepperPluginInfo::PPP_InitializeModuleFunc initialize_module,
459 content::PepperPluginInfo::PPP_ShutdownModuleFunc shutdown_module) {
460 g_pdf_get_interface = get_interface;
461 g_pdf_initialize_module = initialize_module;
462 g_pdf_shutdown_module = shutdown_module;
464 #endif
466 void ChromeContentClient::SetActiveURL(const GURL& url) {
467 base::debug::SetCrashKeyValue(crash_keys::kActiveURL,
468 url.possibly_invalid_spec());
471 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) {
472 #if !defined(OS_ANDROID)
473 base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID,
474 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id));
475 base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID,
476 base::StringPrintf("0x%04x", gpu_info.gpu.device_id));
477 #endif
478 base::debug::SetCrashKeyValue(crash_keys::kGPUDriverVersion,
479 gpu_info.driver_version);
480 base::debug::SetCrashKeyValue(crash_keys::kGPUPixelShaderVersion,
481 gpu_info.pixel_shader_version);
482 base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion,
483 gpu_info.vertex_shader_version);
484 #if defined(OS_MACOSX)
485 base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version);
486 #elif defined(OS_POSIX)
487 base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
488 base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
489 #endif
492 void ChromeContentClient::AddPepperPlugins(
493 std::vector<content::PepperPluginInfo>* plugins) {
494 #if defined(ENABLE_PLUGINS)
495 ComputeBuiltInPlugins(plugins);
496 AddPepperFlashFromCommandLine(plugins);
498 content::PepperPluginInfo plugin;
499 if (GetBundledPepperFlash(&plugin))
500 plugins->push_back(plugin);
501 if (GetSystemPepperFlash(&plugin))
502 plugins->push_back(plugin);
503 #endif
506 void ChromeContentClient::AddAdditionalSchemes(
507 std::vector<std::string>* standard_schemes,
508 std::vector<std::string>* savable_schemes) {
509 standard_schemes->push_back(extensions::kExtensionScheme);
510 savable_schemes->push_back(extensions::kExtensionScheme);
511 standard_schemes->push_back(chrome::kChromeNativeScheme);
512 standard_schemes->push_back(extensions::kExtensionResourceScheme);
513 savable_schemes->push_back(extensions::kExtensionResourceScheme);
514 standard_schemes->push_back(chrome::kChromeSearchScheme);
515 savable_schemes->push_back(chrome::kChromeSearchScheme);
516 standard_schemes->push_back(dom_distiller::kDomDistillerScheme);
517 savable_schemes->push_back(dom_distiller::kDomDistillerScheme);
518 #if defined(OS_CHROMEOS)
519 standard_schemes->push_back(chrome::kCrosScheme);
520 #endif
523 std::string ChromeContentClient::GetProduct() const {
524 return ::GetProduct();
527 std::string ChromeContentClient::GetUserAgent() const {
528 return ::GetUserAgent();
531 base::string16 ChromeContentClient::GetLocalizedString(int message_id) const {
532 return l10n_util::GetStringUTF16(message_id);
535 base::StringPiece ChromeContentClient::GetDataResource(
536 int resource_id,
537 ui::ScaleFactor scale_factor) const {
538 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
539 resource_id, scale_factor);
542 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes(
543 int resource_id) const {
544 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
547 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const {
548 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
551 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) {
552 #if !defined(DISABLE_NACL)
553 switch (type) {
554 case PROCESS_TYPE_NACL_LOADER:
555 return "Native Client module";
556 case PROCESS_TYPE_NACL_BROKER:
557 return "Native Client broker";
559 #endif
561 NOTREACHED() << "Unknown child process type!";
562 return "Unknown";
565 #if defined(OS_MACOSX) && !defined(OS_IOS)
566 bool ChromeContentClient::GetSandboxProfileForSandboxType(
567 int sandbox_type,
568 int* sandbox_profile_resource_id) const {
569 DCHECK(sandbox_profile_resource_id);
570 #if !defined(DISABLE_NACL)
571 if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) {
572 *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE;
573 return true;
575 #endif
576 return false;
578 #endif
580 void ChromeContentClient::AddSecureSchemesAndOrigins(
581 std::set<std::string>* schemes,
582 std::set<GURL>* origins) {
583 schemes->insert(content::kChromeUIScheme);
584 schemes->insert(extensions::kExtensionScheme);
585 schemes->insert(extensions::kExtensionResourceScheme);
586 GetSecureOriginWhitelist(origins);