Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: extensions/shell/common/shell_content_client.cc

Issue 437503004: Add NaCl support to app_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (nacl-init) rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/shell/common/shell_content_client.h ('k') | extensions/shell/renderer/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/nacl/common/nacl_constants.h"
19 #include "content/public/common/pepper_plugin_info.h"
20 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h"
21 #include "ppapi/shared_impl/ppapi_permissions.h"
22 #endif
23
14 namespace extensions { 24 namespace extensions {
25 namespace {
26
27 #if !defined(DISABLE_NACL)
28 bool GetNaClPluginPath(base::FilePath* path) {
29 // On Posix, plugins live in the module directory.
30 base::FilePath module;
31 if (!PathService::Get(base::DIR_MODULE, &module))
32 return false;
33 *path = module.Append(nacl::kInternalNaClPluginFileName);
34 return true;
35 }
36 #endif // !defined(DISABLE_NACL)
37
38 } // namespace
15 39
16 ShellContentClient::ShellContentClient() { 40 ShellContentClient::ShellContentClient() {
17 } 41 }
18 42
19 ShellContentClient::~ShellContentClient() { 43 ShellContentClient::~ShellContentClient() {
20 } 44 }
21 45
46 void ShellContentClient::AddPepperPlugins(
47 std::vector<content::PepperPluginInfo>* plugins) {
48 #if !defined(DISABLE_NACL)
49 base::FilePath path;
50 if (!GetNaClPluginPath(&path))
51 return;
52
53 content::PepperPluginInfo nacl;
54 // The nacl plugin is now built into the binary.
55 nacl.is_internal = true;
56 nacl.path = path;
57 nacl.name = nacl::kNaClPluginName;
58 content::WebPluginMimeType nacl_mime_type(nacl::kNaClPluginMimeType,
59 nacl::kNaClPluginExtension,
60 nacl::kNaClPluginDescription);
61 nacl.mime_types.push_back(nacl_mime_type);
62 content::WebPluginMimeType pnacl_mime_type(nacl::kPnaclPluginMimeType,
63 nacl::kPnaclPluginExtension,
64 nacl::kPnaclPluginDescription);
65 nacl.mime_types.push_back(pnacl_mime_type);
66 nacl.internal_entry_points.get_interface = nacl_plugin::PPP_GetInterface;
67 nacl.internal_entry_points.initialize_module =
68 nacl_plugin::PPP_InitializeModule;
69 nacl.internal_entry_points.shutdown_module =
70 nacl_plugin::PPP_ShutdownModule;
71 nacl.permissions = ppapi::PERMISSION_PRIVATE | ppapi::PERMISSION_DEV;
72 plugins->push_back(nacl);
73 #endif // !defined(DISABLE_NACL)
74 }
75
22 void ShellContentClient::AddAdditionalSchemes( 76 void ShellContentClient::AddAdditionalSchemes(
23 std::vector<std::string>* standard_schemes, 77 std::vector<std::string>* standard_schemes,
24 std::vector<std::string>* savable_schemes) { 78 std::vector<std::string>* savable_schemes) {
25 standard_schemes->push_back(kExtensionScheme); 79 standard_schemes->push_back(kExtensionScheme);
26 savable_schemes->push_back(kExtensionScheme); 80 savable_schemes->push_back(kExtensionScheme);
27 standard_schemes->push_back(kExtensionResourceScheme); 81 standard_schemes->push_back(kExtensionResourceScheme);
28 savable_schemes->push_back(kExtensionResourceScheme); 82 savable_schemes->push_back(kExtensionResourceScheme);
29 } 83 }
30 84
31 std::string ShellContentClient::GetUserAgent() const { 85 std::string ShellContentClient::GetUserAgent() const {
(...skipping 16 matching lines...) Expand all
48 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes( 102 base::RefCountedStaticMemory* ShellContentClient::GetDataResourceBytes(
49 int resource_id) const { 103 int resource_id) const {
50 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id); 104 return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
51 } 105 }
52 106
53 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const { 107 gfx::Image& ShellContentClient::GetNativeImageNamed(int resource_id) const {
54 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id); 108 return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
55 } 109 }
56 110
57 } // namespace extensions 111 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/common/shell_content_client.h ('k') | extensions/shell/renderer/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698