OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/shell/common/shell_extensions_client.h" | 5 #include "apps/shell/common/shell_extensions_client.h" |
6 | 6 |
7 #include "apps/shell/common/shell_app_runtime.h" | 7 #include "apps/shell/common/shell_app_runtime.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/common/extensions/api/generated_schemas.h" | 9 #include "chrome/common/extensions/api/generated_schemas.h" |
10 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" | 10 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
11 #include "extensions/common/api/generated_schemas.h" | 11 #include "extensions/common/api/generated_schemas.h" |
12 #include "extensions/common/api/sockets/sockets_manifest_handler.h" | 12 #include "extensions/common/api/sockets/sockets_manifest_handler.h" |
13 #include "extensions/common/common_manifest_handlers.h" | 13 #include "extensions/common/common_manifest_handlers.h" |
14 #include "extensions/common/features/api_feature.h" | |
14 #include "extensions/common/features/base_feature_provider.h" | 15 #include "extensions/common/features/base_feature_provider.h" |
16 #include "extensions/common/features/json_feature_provider_source.h" | |
17 #include "extensions/common/features/manifest_feature.h" | |
18 #include "extensions/common/features/permission_feature.h" | |
19 #include "extensions/common/features/simple_feature.h" | |
15 #include "extensions/common/manifest_handler.h" | 20 #include "extensions/common/manifest_handler.h" |
16 #include "extensions/common/permissions/permission_message_provider.h" | 21 #include "extensions/common/permissions/permission_message_provider.h" |
17 #include "extensions/common/permissions/permissions_provider.h" | 22 #include "extensions/common/permissions/permissions_provider.h" |
18 #include "extensions/common/url_pattern_set.h" | 23 #include "extensions/common/url_pattern_set.h" |
24 #include "grit/common_resources.h" | |
25 #include "grit/extensions_resources.h" | |
19 | 26 |
20 using extensions::APIPermissionInfo; | 27 using extensions::APIPermissionInfo; |
21 using extensions::APIPermissionSet; | 28 using extensions::APIPermissionSet; |
29 using extensions::BaseFeatureProvider; | |
22 using extensions::Extension; | 30 using extensions::Extension; |
23 using extensions::Manifest; | 31 using extensions::Manifest; |
24 using extensions::PermissionMessage; | 32 using extensions::PermissionMessage; |
25 using extensions::PermissionMessages; | 33 using extensions::PermissionMessages; |
26 using extensions::PermissionSet; | 34 using extensions::PermissionSet; |
27 using extensions::URLPatternSet; | 35 using extensions::URLPatternSet; |
28 | 36 |
29 namespace apps { | 37 namespace apps { |
30 | 38 |
31 namespace { | 39 namespace { |
32 | 40 |
41 template <class FeatureClass> | |
42 extensions::SimpleFeature* CreateFeature() { | |
43 return new FeatureClass; | |
44 } | |
45 | |
33 // TODO(jamescook): Refactor ChromePermissionsMessageProvider so we can share | 46 // TODO(jamescook): Refactor ChromePermissionsMessageProvider so we can share |
34 // code. | 47 // code. |
35 class ShellPermissionMessageProvider | 48 class ShellPermissionMessageProvider |
36 : public extensions::PermissionMessageProvider { | 49 : public extensions::PermissionMessageProvider { |
37 public: | 50 public: |
38 ShellPermissionMessageProvider() {} | 51 ShellPermissionMessageProvider() {} |
39 virtual ~ShellPermissionMessageProvider() {} | 52 virtual ~ShellPermissionMessageProvider() {} |
40 | 53 |
41 // PermissionMessageProvider implementation. | 54 // PermissionMessageProvider implementation. |
42 virtual PermissionMessages GetPermissionMessages( | 55 virtual PermissionMessages GetPermissionMessages( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 return provider; | 120 return provider; |
108 } | 121 } |
109 | 122 |
110 const extensions::PermissionMessageProvider& | 123 const extensions::PermissionMessageProvider& |
111 ShellExtensionsClient::GetPermissionMessageProvider() const { | 124 ShellExtensionsClient::GetPermissionMessageProvider() const { |
112 NOTIMPLEMENTED(); | 125 NOTIMPLEMENTED(); |
113 static ShellPermissionMessageProvider provider; | 126 static ShellPermissionMessageProvider provider; |
114 return provider; | 127 return provider; |
115 } | 128 } |
116 | 129 |
117 extensions::FeatureProvider* ShellExtensionsClient::GetFeatureProviderByName( | 130 extensions::FeatureProvider* ShellExtensionsClient::CreateFeatureProvider( |
not at google - send to devlin
2014/04/22 21:39:09
scoped_ptr<> ?
Yoyo Zhou
2014/04/22 23:17:40
I think this is silly because it gets immediately
not at google - send to devlin
2014/04/23 01:22:32
make_linked_ptr should accept a scoped_ptr rvalue.
Yoyo Zhou
2014/04/24 16:34:50
Nope
| |
118 const std::string& name) const { | 131 const std::string& name) const { |
119 // TODO(jamescook): Factor out an extensions module feature provider. | 132 extensions::JSONFeatureProviderSource source(name); |
120 return extensions::BaseFeatureProvider::GetByName(name); | 133 if (name == "api") { |
134 // TODO(yoz): Only include src/extensions resources. | |
135 source.LoadJSON(IDR_EXTENSION_API_FEATURES); | |
136 source.LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); | |
137 return new BaseFeatureProvider(source.dictionary(), | |
138 &CreateFeature<extensions::APIFeature>); | |
139 } else if (name == "manifest") { | |
140 source.LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | |
141 source.LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES); | |
142 return new BaseFeatureProvider(source.dictionary(), | |
143 &CreateFeature<extensions::ManifestFeature>); | |
144 } else if (name == "permission") { | |
145 source.LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | |
146 source.LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES); | |
147 return new BaseFeatureProvider( | |
148 source.dictionary(), &CreateFeature<extensions::PermissionFeature>); | |
149 } else { | |
150 NOTREACHED(); | |
151 } | |
152 return NULL; | |
121 } | 153 } |
122 | 154 |
123 void ShellExtensionsClient::FilterHostPermissions( | 155 void ShellExtensionsClient::FilterHostPermissions( |
124 const URLPatternSet& hosts, | 156 const URLPatternSet& hosts, |
125 URLPatternSet* new_hosts, | 157 URLPatternSet* new_hosts, |
126 std::set<PermissionMessage>* messages) const { | 158 std::set<PermissionMessage>* messages) const { |
127 NOTIMPLEMENTED(); | 159 NOTIMPLEMENTED(); |
128 } | 160 } |
129 | 161 |
130 void ShellExtensionsClient::SetScriptingWhitelist( | 162 void ShellExtensionsClient::SetScriptingWhitelist( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 if (extensions::api::GeneratedSchemas::IsGenerated(name)) | 201 if (extensions::api::GeneratedSchemas::IsGenerated(name)) |
170 return extensions::api::GeneratedSchemas::Get(name); | 202 return extensions::api::GeneratedSchemas::Get(name); |
171 | 203 |
172 // Special-case our simplified app.runtime implementation. | 204 // Special-case our simplified app.runtime implementation. |
173 if (name == extensions::ShellAppRuntime::GetName()) | 205 if (name == extensions::ShellAppRuntime::GetName()) |
174 return extensions::ShellAppRuntime::GetSchema(); | 206 return extensions::ShellAppRuntime::GetSchema(); |
175 | 207 |
176 return extensions::core_api::GeneratedSchemas::Get(name); | 208 return extensions::core_api::GeneratedSchemas::Get(name); |
177 } | 209 } |
178 | 210 |
179 void ShellExtensionsClient::AddExtraFeatureFilters( | |
180 extensions::SimpleFeature* feature) const {} | |
181 | |
182 bool ShellExtensionsClient::ShouldSuppressFatalErrors() const { return true; } | 211 bool ShellExtensionsClient::ShouldSuppressFatalErrors() const { return true; } |
183 | 212 |
184 } // namespace apps | 213 } // namespace apps |
OLD | NEW |