OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/shell/common/shell_content_client.h" | 5 #include "extensions/shell/common/shell_content_client.h" |
6 | 6 |
7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/public/common/user_agent.h" | 9 #include "content/public/common/user_agent.h" |
10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 | 13 |
14 #if !defined(DISABLE_NACL) | |
15 #include "base/base_paths.h" | |
16 #include "base/files/file_path.h" | |
17 #include "base/path_service.h" | |
18 #include "content/public/common/pepper_plugin_info.h" | |
19 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h" | |
20 #include "ppapi/shared_impl/ppapi_permissions.h" | |
21 #endif | |
22 | |
14 namespace extensions { | 23 namespace extensions { |
24 namespace { | |
25 | |
26 // TODO(jamescook): Should these be shared with ChromeContentClient? They are | |
27 // too specific for the ppapi module and not really part of the extensions | |
28 // module. Perhaps they should live in components/nacl. | |
teravest
2014/08/12 15:48:32
components/nacl is probably a better place for thi
James Cook
2014/08/12 18:17:06
Moved into components/nacl/common and updated all
| |
29 #if !defined(DISABLE_NACL) | |
30 const char kNaClPluginName[] = "Native Client"; | |
31 | |
32 const char kNaClPluginMimeType[] = "application/x-nacl"; | |
33 const char kNaClPluginExtension[] = ""; | |
34 const char kNaClPluginDescription[] = "Native Client Executable"; | |
35 const uint32 kNaClPluginPermissions = ppapi::PERMISSION_PRIVATE | | |
36 ppapi::PERMISSION_DEV; | |
37 | |
38 const char kPnaclPluginMimeType[] = "application/x-pnacl"; | |
39 const char kPnaclPluginExtension[] = ""; | |
40 const char kPnaclPluginDescription[] = "Portable Native Client Executable"; | |
41 | |
42 const base::FilePath::CharType kInternalNaClPluginFileName[] = | |
43 FILE_PATH_LITERAL("internal-nacl-plugin"); | |
44 | |
45 bool GetNaClPluginPath(base::FilePath* path) { | |
46 // On Posix, plugins live in the module directory. | |
47 base::FilePath module; | |
48 if (!PathService::Get(base::DIR_MODULE, &module)) | |
49 return false; | |
50 *path = module.Append(kInternalNaClPluginFileName); | |
51 return true; | |
52 } | |
53 #endif // !defined(DISABLE_NACL) | |
54 | |
55 } // namespace | |
15 | 56 |
16 ShellContentClient::ShellContentClient() { | 57 ShellContentClient::ShellContentClient() { |
17 } | 58 } |
18 | 59 |
19 ShellContentClient::~ShellContentClient() { | 60 ShellContentClient::~ShellContentClient() { |
20 } | 61 } |
21 | 62 |
63 void ShellContentClient::AddPepperPlugins( | |
64 std::vector<content::PepperPluginInfo>* plugins) { | |
65 #if !defined(DISABLE_NACL) | |
66 base::FilePath path; | |
67 if (!GetNaClPluginPath(&path)) | |
68 return; | |
69 | |
70 content::PepperPluginInfo nacl; | |
71 // The nacl plugin is now built into the binary. | |
72 nacl.is_internal = true; | |
73 nacl.path = path; | |
74 nacl.name = kNaClPluginName; | |
75 content::WebPluginMimeType nacl_mime_type(kNaClPluginMimeType, | |
76 kNaClPluginExtension, | |
77 kNaClPluginDescription); | |
78 nacl.mime_types.push_back(nacl_mime_type); | |
79 content::WebPluginMimeType pnacl_mime_type(kPnaclPluginMimeType, | |
80 kPnaclPluginExtension, | |
81 kPnaclPluginDescription); | |
82 nacl.mime_types.push_back(pnacl_mime_type); | |
83 nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface; | |
84 nacl.internal_entry_points.initialize_module = | |
85 nacl_plugin::PPP_InitializeModule; | |
86 nacl.internal_entry_points.shutdown_module = | |
87 nacl_plugin::PPP_ShutdownModule; | |
88 nacl.permissions = kNaClPluginPermissions; | |
89 plugins->push_back(nacl); | |
90 #endif // !defined(DISABLE_NACL) | |
91 } | |
92 | |
22 void ShellContentClient::AddAdditionalSchemes( | 93 void ShellContentClient::AddAdditionalSchemes( |
23 std::vector<std::string>* standard_schemes, | 94 std::vector<std::string>* standard_schemes, |
24 std::vector<std::string>* savable_schemes) { | 95 std::vector<std::string>* savable_schemes) { |
25 standard_schemes->push_back(kExtensionScheme); | 96 standard_schemes->push_back(kExtensionScheme); |
26 savable_schemes->push_back(kExtensionScheme); | 97 savable_schemes->push_back(kExtensionScheme); |
27 standard_schemes->push_back(kExtensionResourceScheme); | 98 standard_schemes->push_back(kExtensionResourceScheme); |
28 savable_schemes->push_back(kExtensionResourceScheme); | 99 savable_schemes->push_back(kExtensionResourceScheme); |
29 } | 100 } |
30 | 101 |
31 std::string ShellContentClient::GetUserAgent() const { | 102 std::string ShellContentClient::GetUserAgent() const { |
(...skipping 16 matching lines...) Expand all Loading... | |
48 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( | 119 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( |
49 int resource_id) const { | 120 int resource_id) const { |
50 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); | 121 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); |
51 } | 122 } |
52 | 123 |
53 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { | 124 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { |
54 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); | 125 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); |
55 } | 126 } |
56 | 127 |
57 } // namespace extensions | 128 } // namespace extensions |
OLD | NEW |