Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / common / chrome_content_client.cc
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.
4
5 #include "chrome/common/chrome_content_client.h"
6
7 #include "base/command_line.h"
8 #include "base/cpu.h"
9 #include "base/debug/crash_logging.h"
10 #include "base/file_util.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_paths.h"
21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/chrome_version_info.h"
23 #include "chrome/common/crash_keys.h"
24 #include "chrome/common/pepper_flash.h"
25 #include "chrome/common/render_messages.h"
26 #include "chrome/common/url_constants.h"
27 #include "chrome/grit/common_resources.h"
28 #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"
31 #include "content/public/common/content_switches.h"
32 #include "content/public/common/pepper_plugin_info.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 "ppapi/shared_impl/ppapi_permissions.h"
38 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/layout.h"
40 #include "ui/base/resource/resource_bundle.h"
41
42 #include "flapper_version.h"  // In SHARED_INTERMEDIATE_DIR.
43 #include "widevine_cdm_version.h"  // In SHARED_INTERMEDIATE_DIR.
44
45 #if defined(OS_WIN)
46 #include "base/win/registry.h"
47 #include "base/win/windows_version.h"
48 #elif defined(OS_MACOSX)
49 #include "components/nacl/common/nacl_sandbox_type_mac.h"
50 #endif
51
52 #if !defined(DISABLE_NACL)
53 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h"
54 #endif
55
56 #if defined(ENABLE_REMOTING)
57 #include "remoting/client/plugin/pepper_entrypoints.h"
58 #endif
59
60 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
61     !defined(WIDEVINE_CDM_IS_COMPONENT)
62 #include "chrome/common/widevine_cdm_constants.h"
63 #endif
64
65 namespace {
66
67 const char kPDFPluginMimeType[] = "application/pdf";
68 const char kPDFPluginExtension[] = "pdf";
69 const char kPDFPluginDescription[] = "Portable Document Format";
70 const char kPDFPluginPrintPreviewMimeType[] =
71    "application/x-google-chrome-print-preview-pdf";
72 const char kPDFPluginOutOfProcessMimeType[] =
73    "application/x-google-chrome-pdf";
74 const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE |
75                                      ppapi::PERMISSION_DEV;
76
77 #if !defined(DISABLE_NACL)
78 const char kNaClPluginMimeType[] = "application/x-nacl";
79 const char kNaClPluginExtension[] = "";
80 const char kNaClPluginDescription[] = "Native Client Executable";
81 const uint32 kNaClPluginPermissions = ppapi::PERMISSION_PRIVATE |
82                                       ppapi::PERMISSION_DEV;
83
84 const char kPnaclPluginMimeType[] = "application/x-pnacl";
85 const char kPnaclPluginExtension[] = "";
86 const char kPnaclPluginDescription[] = "Portable Native Client Executable";
87 #endif  // !defined(DISABLE_NACL)
88
89 const char kO1DPluginName[] = "Google Talk Plugin Video Renderer";
90 const char kO1DPluginMimeType[] ="application/o1d";
91 const char kO1DPluginExtension[] = "";
92 const char kO1DPluginDescription[] = "Google Talk Plugin Video Renderer";
93 const uint32 kO1DPluginPermissions = ppapi::PERMISSION_PRIVATE |
94                                      ppapi::PERMISSION_DEV;
95
96 const char kEffectsPluginName[] = "Google Talk Effects Plugin";
97 const char kEffectsPluginMimeType[] ="application/x-ppapi-hangouts-effects";
98 const char kEffectsPluginExtension[] = "";
99 const char kEffectsPluginDescription[] = "Google Talk Effects Plugin";
100 const uint32 kEffectsPluginPermissions = ppapi::PERMISSION_PRIVATE |
101                                          ppapi::PERMISSION_DEV;
102
103 const char kGTalkPluginName[] = "Google Talk Plugin";
104 const char kGTalkPluginMimeType[] ="application/googletalk";
105 const char kGTalkPluginExtension[] = ".googletalk";
106 const char kGTalkPluginDescription[] = "Google Talk Plugin";
107 const uint32 kGTalkPluginPermissions = ppapi::PERMISSION_PRIVATE |
108                                        ppapi::PERMISSION_DEV;
109
110 #if defined(ENABLE_REMOTING)
111 #if defined(GOOGLE_CHROME_BUILD)
112 const char kRemotingViewerPluginName[] = "Chrome Remote Desktop Viewer";
113 #else
114 const char kRemotingViewerPluginName[] = "Chromoting Viewer";
115 #endif  // defined(GOOGLE_CHROME_BUILD)
116 const char kRemotingViewerPluginDescription[] =
117     "This plugin allows you to securely access other computers that have been "
118     "shared with you. To use this plugin you must first install the "
119     "<a href=\"https://chrome.google.com/remotedesktop\">"
120     "Chrome Remote Desktop</a> webapp.";
121 // Use a consistent MIME-type regardless of branding.
122 const char kRemotingViewerPluginMimeType[] =
123     "application/vnd.chromium.remoting-viewer";
124 const char kRemotingViewerPluginMimeExtension[] = "";
125 const char kRemotingViewerPluginMimeDescription[] = "";
126 const uint32 kRemotingViewerPluginPermissions = ppapi::PERMISSION_PRIVATE |
127                                                 ppapi::PERMISSION_DEV;
128 #endif  // defined(ENABLE_REMOTING)
129
130 // Appends the known built-in plugins to the given vector. Some built-in
131 // plugins are "internal" which means they are compiled into the Chrome binary,
132 // and some are extra shared libraries distributed with the browser (these are
133 // not marked internal, aside from being automatically registered, they're just
134 // regular plugins).
135 void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
136   // PDF.
137   //
138   // Once we're sandboxed, we can't know if the PDF plugin is available or not;
139   // but (on Linux) this function is always called once before we're sandboxed.
140   // So the first time through test if the file is available and then skip the
141   // check on subsequent calls if yes.
142   static bool skip_pdf_file_check = false;
143   base::FilePath path;
144   if (PathService::Get(chrome::FILE_PDF_PLUGIN, &path)) {
145     if (skip_pdf_file_check || base::PathExists(path)) {
146       content::PepperPluginInfo pdf;
147       pdf.path = path;
148       pdf.name = ChromeContentClient::kPDFPluginName;
149       if (CommandLine::ForCurrentProcess()->HasSwitch(
150               switches::kOutOfProcessPdf)) {
151         pdf.is_out_of_process = true;
152         content::WebPluginMimeType pdf_mime_type(kPDFPluginOutOfProcessMimeType,
153                                                  kPDFPluginExtension,
154                                                  kPDFPluginDescription);
155         pdf.mime_types.push_back(pdf_mime_type);
156         // TODO(raymes): Make print preview work with out of process PDF.
157       } else {
158         content::WebPluginMimeType pdf_mime_type(kPDFPluginMimeType,
159                                                  kPDFPluginExtension,
160                                                  kPDFPluginDescription);
161         content::WebPluginMimeType print_preview_pdf_mime_type(
162             kPDFPluginPrintPreviewMimeType,
163             kPDFPluginExtension,
164             kPDFPluginDescription);
165         pdf.mime_types.push_back(pdf_mime_type);
166         pdf.mime_types.push_back(print_preview_pdf_mime_type);
167       }
168       pdf.permissions = kPDFPluginPermissions;
169       plugins->push_back(pdf);
170
171       skip_pdf_file_check = true;
172     }
173   }
174
175 #if !defined(DISABLE_NACL)
176   // Handle Native Client just like the PDF plugin. This means that it is
177   // enabled by default for the non-portable case.  This allows apps installed
178   // from the Chrome Web Store to use NaCl even if the command line switch
179   // isn't set.  For other uses of NaCl we check for the command line switch.
180   if (PathService::Get(chrome::FILE_NACL_PLUGIN, &path)) {
181     content::PepperPluginInfo nacl;
182     // The nacl plugin is now built into the Chromium binary.
183     nacl.is_internal = true;
184     nacl.path = path;
185     nacl.name = ChromeContentClient::kNaClPluginName;
186     content::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType,
187                                               kNaClPluginExtension,
188                                               kNaClPluginDescription);
189     nacl.mime_types.push_back(nacl_mime_type);
190     content::WebPluginMimeType pnacl_mime_type(kPnaclPluginMimeType,
191                                                kPnaclPluginExtension,
192                                                kPnaclPluginDescription);
193     nacl.mime_types.push_back(pnacl_mime_type);
194     nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface;
195     nacl.internal_entry_points.initialize_module =
196         nacl_plugin::PPP_InitializeModule;
197     nacl.internal_entry_points.shutdown_module =
198         nacl_plugin::PPP_ShutdownModule;
199     nacl.permissions = kNaClPluginPermissions;
200     plugins->push_back(nacl);
201   }
202 #endif  // !defined(DISABLE_NACL)
203
204   static bool skip_o1d_file_check = false;
205   if (PathService::Get(chrome::FILE_O1D_PLUGIN, &path)) {
206     if (skip_o1d_file_check || base::PathExists(path)) {
207       content::PepperPluginInfo o1d;
208       o1d.path = path;
209       o1d.name = kO1DPluginName;
210       o1d.is_out_of_process = true;
211       o1d.is_sandboxed = false;
212       o1d.permissions = kO1DPluginPermissions;
213       content::WebPluginMimeType o1d_mime_type(kO1DPluginMimeType,
214                                                kO1DPluginExtension,
215                                                kO1DPluginDescription);
216       o1d.mime_types.push_back(o1d_mime_type);
217       plugins->push_back(o1d);
218
219       skip_o1d_file_check = true;
220     }
221   }
222
223   // TODO(vrk): Remove this when NaCl effects plugin replaces the ppapi effects
224   // plugin.
225   static bool skip_effects_file_check = false;
226   if (PathService::Get(chrome::FILE_EFFECTS_PLUGIN, &path)) {
227     if (skip_effects_file_check || base::PathExists(path)) {
228       content::PepperPluginInfo effects;
229       effects.path = path;
230       effects.name = kEffectsPluginName;
231       effects.is_out_of_process = true;
232       effects.is_sandboxed = true;
233       effects.permissions = kEffectsPluginPermissions;
234       content::WebPluginMimeType effects_mime_type(kEffectsPluginMimeType,
235                                                    kEffectsPluginExtension,
236                                                    kEffectsPluginDescription);
237       effects.mime_types.push_back(effects_mime_type);
238       plugins->push_back(effects);
239
240       skip_effects_file_check = true;
241     }
242   }
243
244   static bool skip_gtalk_file_check = false;
245   if (PathService::Get(chrome::FILE_GTALK_PLUGIN, &path)) {
246     if (skip_gtalk_file_check || base::PathExists(path)) {
247       content::PepperPluginInfo gtalk;
248       gtalk.path = path;
249       gtalk.name = kGTalkPluginName;
250       gtalk.is_out_of_process = true;
251       gtalk.is_sandboxed = false;
252       gtalk.permissions = kGTalkPluginPermissions;
253       content::WebPluginMimeType gtalk_mime_type(kGTalkPluginMimeType,
254                                                  kGTalkPluginExtension,
255                                                  kGTalkPluginDescription);
256       gtalk.mime_types.push_back(gtalk_mime_type);
257       plugins->push_back(gtalk);
258
259       skip_gtalk_file_check = true;
260     }
261   }
262
263 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
264     !defined(WIDEVINE_CDM_IS_COMPONENT)
265   static bool skip_widevine_cdm_file_check = false;
266   if (PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &path)) {
267     if (skip_widevine_cdm_file_check || base::PathExists(path)) {
268       content::PepperPluginInfo widevine_cdm;
269       widevine_cdm.is_out_of_process = true;
270       widevine_cdm.path = path;
271       widevine_cdm.name = kWidevineCdmDisplayName;
272       widevine_cdm.description = kWidevineCdmDescription;
273       widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
274       content::WebPluginMimeType widevine_cdm_mime_type(
275           kWidevineCdmPluginMimeType,
276           kWidevineCdmPluginExtension,
277           kWidevineCdmPluginMimeTypeDescription);
278
279       // Add the supported codecs as if they came from the component manifest.
280       std::vector<std::string> codecs;
281       codecs.push_back(kCdmSupportedCodecVorbis);
282       codecs.push_back(kCdmSupportedCodecVp8);
283       codecs.push_back(kCdmSupportedCodecVp9);
284 #if defined(USE_PROPRIETARY_CODECS)
285 // TODO(ddorwin): Rename these macros to reflect their real meaning: whether the
286 // CDM Chrome was built [and shipped] with support these types.
287 #if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
288       codecs.push_back(kCdmSupportedCodecAac);
289 #endif
290 #if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
291       codecs.push_back(kCdmSupportedCodecAvc1);
292 #endif
293 #endif  // defined(USE_PROPRIETARY_CODECS)
294       std::string codec_string =
295           JoinString(codecs, kCdmSupportedCodecsValueDelimiter);
296       widevine_cdm_mime_type.additional_param_names.push_back(
297           base::ASCIIToUTF16(kCdmSupportedCodecsParamName));
298       widevine_cdm_mime_type.additional_param_values.push_back(
299           base::ASCIIToUTF16(codec_string));
300
301       widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
302       widevine_cdm.permissions = kWidevineCdmPluginPermissions;
303       plugins->push_back(widevine_cdm);
304
305       skip_widevine_cdm_file_check = true;
306     }
307   }
308 #endif  // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) &&
309         // !defined(WIDEVINE_CDM_IS_COMPONENT)
310
311   // The Remoting Viewer plugin is built-in.
312 #if defined(ENABLE_REMOTING)
313   content::PepperPluginInfo info;
314   info.is_internal = true;
315   info.is_out_of_process = true;
316   info.name = kRemotingViewerPluginName;
317   info.description = kRemotingViewerPluginDescription;
318   info.path = base::FilePath::FromUTF8Unsafe(
319       ChromeContentClient::kRemotingViewerPluginPath);
320   content::WebPluginMimeType remoting_mime_type(
321       kRemotingViewerPluginMimeType,
322       kRemotingViewerPluginMimeExtension,
323       kRemotingViewerPluginMimeDescription);
324   info.mime_types.push_back(remoting_mime_type);
325   info.internal_entry_points.get_interface = remoting::PPP_GetInterface;
326   info.internal_entry_points.initialize_module =
327       remoting::PPP_InitializeModule;
328   info.internal_entry_points.shutdown_module = remoting::PPP_ShutdownModule;
329   info.permissions = kRemotingViewerPluginPermissions;
330
331   plugins->push_back(info);
332 #endif
333 }
334
335 content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
336                                                 const std::string& version) {
337   content::PepperPluginInfo plugin;
338
339   plugin.is_out_of_process = true;
340   plugin.name = content::kFlashPluginName;
341   plugin.path = path;
342   plugin.permissions = kPepperFlashPermissions;
343
344   std::vector<std::string> flash_version_numbers;
345   base::SplitString(version, '.', &flash_version_numbers);
346   if (flash_version_numbers.size() < 1)
347     flash_version_numbers.push_back("11");
348   // |SplitString()| puts in an empty string given an empty string. :(
349   else if (flash_version_numbers[0].empty())
350     flash_version_numbers[0] = "11";
351   if (flash_version_numbers.size() < 2)
352     flash_version_numbers.push_back("2");
353   if (flash_version_numbers.size() < 3)
354     flash_version_numbers.push_back("999");
355   if (flash_version_numbers.size() < 4)
356     flash_version_numbers.push_back("999");
357   // E.g., "Shockwave Flash 10.2 r154":
358   plugin.description = plugin.name + " " + flash_version_numbers[0] + "." +
359       flash_version_numbers[1] + " r" + flash_version_numbers[2];
360   plugin.version = JoinString(flash_version_numbers, '.');
361   content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType,
362                                            content::kFlashPluginSwfExtension,
363                                            content::kFlashPluginSwfDescription);
364   plugin.mime_types.push_back(swf_mime_type);
365   content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType,
366                                            content::kFlashPluginSplExtension,
367                                            content::kFlashPluginSplDescription);
368   plugin.mime_types.push_back(spl_mime_type);
369
370   return plugin;
371 }
372
373 void AddPepperFlashFromCommandLine(
374     std::vector<content::PepperPluginInfo>* plugins) {
375   const CommandLine::StringType flash_path =
376       CommandLine::ForCurrentProcess()->GetSwitchValueNative(
377           switches::kPpapiFlashPath);
378   if (flash_path.empty())
379     return;
380
381   // Also get the version from the command-line. Should be something like 11.2
382   // or 11.2.123.45.
383   std::string flash_version =
384       CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
385           switches::kPpapiFlashVersion);
386
387   plugins->push_back(
388       CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
389 }
390
391 bool GetBundledPepperFlash(content::PepperPluginInfo* plugin) {
392 #if defined(FLAPPER_AVAILABLE)
393   CommandLine* command_line = CommandLine::ForCurrentProcess();
394
395   // Ignore bundled Pepper Flash if there is Pepper Flash specified from the
396   // command-line.
397   if (command_line->HasSwitch(switches::kPpapiFlashPath))
398     return false;
399
400   bool force_disable =
401       command_line->HasSwitch(switches::kDisableBundledPpapiFlash);
402   if (force_disable)
403     return false;
404
405 // For Linux ia32, Flapper requires SSE2.
406 #if defined(OS_LINUX) && defined(ARCH_CPU_X86)
407   if (!base::CPU().has_sse2())
408     return false;
409 #endif  // ARCH_CPU_X86
410
411   base::FilePath flash_path;
412   if (!PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &flash_path))
413     return false;
414
415   *plugin = CreatePepperFlashInfo(flash_path, FLAPPER_VERSION_STRING);
416   return true;
417 #else
418   return false;
419 #endif  // FLAPPER_AVAILABLE
420 }
421
422 std::string GetProduct() {
423   chrome::VersionInfo version_info;
424   return version_info.is_valid() ?
425       version_info.ProductNameAndVersionForUserAgent() : std::string();
426 }
427
428 }  // namespace
429
430 std::string GetUserAgent() {
431   CommandLine* command_line = CommandLine::ForCurrentProcess();
432   if (command_line->HasSwitch(switches::kUserAgent))
433     return command_line->GetSwitchValueASCII(switches::kUserAgent);
434
435   std::string product = GetProduct();
436 #if defined(OS_ANDROID)
437   if (command_line->HasSwitch(switches::kUseMobileUserAgent))
438     product += " Mobile";
439 #endif
440   return content::BuildUserAgentFromProduct(product);
441 }
442
443 void ChromeContentClient::SetActiveURL(const GURL& url) {
444   base::debug::SetCrashKeyValue(crash_keys::kActiveURL,
445                                 url.possibly_invalid_spec());
446 }
447
448 void ChromeContentClient::SetGpuInfo(const gpu::GPUInfo& gpu_info) {
449 #if !defined(OS_ANDROID)
450   base::debug::SetCrashKeyValue(crash_keys::kGPUVendorID,
451       base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id));
452   base::debug::SetCrashKeyValue(crash_keys::kGPUDeviceID,
453       base::StringPrintf("0x%04x", gpu_info.gpu.device_id));
454 #endif
455   base::debug::SetCrashKeyValue(crash_keys::kGPUDriverVersion,
456       gpu_info.driver_version);
457   base::debug::SetCrashKeyValue(crash_keys::kGPUPixelShaderVersion,
458       gpu_info.pixel_shader_version);
459   base::debug::SetCrashKeyValue(crash_keys::kGPUVertexShaderVersion,
460       gpu_info.vertex_shader_version);
461 #if defined(OS_MACOSX)
462   base::debug::SetCrashKeyValue(crash_keys::kGPUGLVersion, gpu_info.gl_version);
463 #elif defined(OS_POSIX)
464   base::debug::SetCrashKeyValue(crash_keys::kGPUVendor, gpu_info.gl_vendor);
465   base::debug::SetCrashKeyValue(crash_keys::kGPURenderer, gpu_info.gl_renderer);
466 #endif
467 }
468
469 void ChromeContentClient::AddPepperPlugins(
470     std::vector<content::PepperPluginInfo>* plugins) {
471   ComputeBuiltInPlugins(plugins);
472   AddPepperFlashFromCommandLine(plugins);
473
474   content::PepperPluginInfo plugin;
475   if (GetBundledPepperFlash(&plugin))
476     plugins->push_back(plugin);
477 }
478
479 void ChromeContentClient::AddAdditionalSchemes(
480     std::vector<std::string>* standard_schemes,
481     std::vector<std::string>* savable_schemes) {
482   standard_schemes->push_back(extensions::kExtensionScheme);
483   savable_schemes->push_back(extensions::kExtensionScheme);
484   standard_schemes->push_back(chrome::kChromeNativeScheme);
485   standard_schemes->push_back(extensions::kExtensionResourceScheme);
486   savable_schemes->push_back(extensions::kExtensionResourceScheme);
487   standard_schemes->push_back(chrome::kChromeSearchScheme);
488   savable_schemes->push_back(chrome::kChromeSearchScheme);
489   standard_schemes->push_back(dom_distiller::kDomDistillerScheme);
490   savable_schemes->push_back(dom_distiller::kDomDistillerScheme);
491 #if defined(OS_CHROMEOS)
492   standard_schemes->push_back(chrome::kCrosScheme);
493 #endif
494 }
495
496 std::string ChromeContentClient::GetProduct() const {
497   return ::GetProduct();
498 }
499
500 std::string ChromeContentClient::GetUserAgent() const {
501   return ::GetUserAgent();
502 }
503
504 base::string16 ChromeContentClient::GetLocalizedString(int message_id) const {
505   return l10n_util::GetStringUTF16(message_id);
506 }
507
508 base::StringPiece ChromeContentClient::GetDataResource(
509     int resource_id,
510     ui::ScaleFactor scale_factor) const {
511   return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
512       resource_id, scale_factor);
513 }
514
515 base::RefCountedStaticMemory* ChromeContentClient::GetDataResourceBytes(
516     int resource_id) const {
517   return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
518 }
519
520 gfx::Image& ChromeContentClient::GetNativeImageNamed(int resource_id) const {
521   return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
522 }
523
524 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) {
525   switch (type) {
526     case PROCESS_TYPE_NACL_LOADER:
527       return "Native Client module";
528     case PROCESS_TYPE_NACL_BROKER:
529       return "Native Client broker";
530   }
531
532   DCHECK(false) << "Unknown child process type!";
533   return "Unknown";
534 }
535
536 #if defined(OS_MACOSX) && !defined(OS_IOS)
537 bool ChromeContentClient::GetSandboxProfileForSandboxType(
538     int sandbox_type,
539     int* sandbox_profile_resource_id) const {
540   DCHECK(sandbox_profile_resource_id);
541   if (sandbox_type == NACL_SANDBOX_TYPE_NACL_LOADER) {
542     *sandbox_profile_resource_id = IDR_NACL_SANDBOX_PROFILE;
543     return true;
544   }
545   return false;
546 }
547 #endif