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_extensions_client.h" | 5 #include "extensions/shell/common/shell_extensions_client.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "extensions/common/api/generated_schemas.h" | 10 #include "extensions/common/api/generated_schemas.h" |
11 #include "extensions/common/common_manifest_handlers.h" | 11 #include "extensions/common/common_manifest_handlers.h" |
12 #include "extensions/common/extension_urls.h" | 12 #include "extensions/common/extension_urls.h" |
13 #include "extensions/common/features/api_feature.h" | 13 #include "extensions/common/features/api_feature.h" |
14 #include "extensions/common/features/behavior_feature.h" | 14 #include "extensions/common/features/behavior_feature.h" |
15 #include "extensions/common/features/json_feature_provider.h" | 15 #include "extensions/common/features/json_feature_provider.h" |
16 #include "extensions/common/features/json_feature_provider_source.h" | 16 #include "extensions/common/features/json_feature_provider_source.h" |
17 #include "extensions/common/features/manifest_feature.h" | 17 #include "extensions/common/features/manifest_feature.h" |
18 #include "extensions/common/features/permission_feature.h" | 18 #include "extensions/common/features/permission_feature.h" |
19 #include "extensions/common/features/simple_feature.h" | 19 #include "extensions/common/features/simple_feature.h" |
20 #include "extensions/common/manifest_handler.h" | 20 #include "extensions/common/manifest_handler.h" |
21 #include "extensions/common/permissions/permission_message_provider.h" | 21 #include "extensions/common/permissions/permission_message_provider.h" |
22 #include "extensions/common/permissions/permissions_info.h" | 22 #include "extensions/common/permissions/permissions_info.h" |
23 #include "extensions/common/permissions/permissions_provider.h" | 23 #include "extensions/common/permissions/permissions_provider.h" |
24 #include "extensions/common/url_pattern_set.h" | 24 #include "extensions/common/url_pattern_set.h" |
25 #include "extensions/shell/common/api/generated_schemas.h" | 25 #include "extensions/shell/common/api/generated_schemas.h" |
| 26 #include "extensions/shell/common/api/shell_api_features.h" |
| 27 #include "extensions/shell/common/api/shell_behavior_features.h" |
| 28 #include "extensions/shell/common/api/shell_manifest_features.h" |
| 29 #include "extensions/shell/common/api/shell_permission_features.h" |
26 #include "grit/app_shell_resources.h" | 30 #include "grit/app_shell_resources.h" |
27 #include "grit/extensions_resources.h" | 31 #include "grit/extensions_resources.h" |
28 | 32 |
29 namespace extensions { | 33 namespace extensions { |
30 | 34 |
31 namespace { | 35 namespace { |
32 | 36 |
33 template <class FeatureClass> | 37 template <class FeatureClass> |
34 SimpleFeature* CreateFeature() { | 38 SimpleFeature* CreateFeature() { |
35 return new FeatureClass; | 39 return new FeatureClass; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return g_permission_message_provider.Get(); | 96 return g_permission_message_provider.Get(); |
93 } | 97 } |
94 | 98 |
95 const std::string ShellExtensionsClient::GetProductName() { | 99 const std::string ShellExtensionsClient::GetProductName() { |
96 return "app_shell"; | 100 return "app_shell"; |
97 } | 101 } |
98 | 102 |
99 std::unique_ptr<FeatureProvider> ShellExtensionsClient::CreateFeatureProvider( | 103 std::unique_ptr<FeatureProvider> ShellExtensionsClient::CreateFeatureProvider( |
100 const std::string& name) const { | 104 const std::string& name) const { |
101 std::unique_ptr<FeatureProvider> provider; | 105 std::unique_ptr<FeatureProvider> provider; |
102 std::unique_ptr<JSONFeatureProviderSource> source( | |
103 CreateFeatureProviderSource(name)); | |
104 if (name == "api") { | 106 if (name == "api") { |
105 provider.reset(new JSONFeatureProvider(source->dictionary(), | 107 provider.reset(new ShellAPIFeatureProvider()); |
106 CreateFeature<APIFeature>)); | |
107 } else if (name == "manifest") { | 108 } else if (name == "manifest") { |
108 provider.reset(new JSONFeatureProvider(source->dictionary(), | 109 provider.reset(new ShellManifestFeatureProvider()); |
109 CreateFeature<ManifestFeature>)); | |
110 } else if (name == "permission") { | 110 } else if (name == "permission") { |
111 provider.reset(new JSONFeatureProvider(source->dictionary(), | 111 provider.reset(new ShellPermissionFeatureProvider()); |
112 CreateFeature<PermissionFeature>)); | |
113 } else if (name == "behavior") { | 112 } else if (name == "behavior") { |
114 provider.reset(new JSONFeatureProvider(source->dictionary(), | 113 provider.reset(new ShellBehaviorFeatureProvider()); |
115 CreateFeature<BehaviorFeature>)); | |
116 } else { | 114 } else { |
117 NOTREACHED(); | 115 NOTREACHED(); |
118 } | 116 } |
119 return provider; | 117 return provider; |
120 } | 118 } |
121 | 119 |
122 std::unique_ptr<JSONFeatureProviderSource> | 120 std::unique_ptr<JSONFeatureProviderSource> |
123 ShellExtensionsClient::CreateFeatureProviderSource( | 121 ShellExtensionsClient::CreateAPIFeatureSource() const { |
124 const std::string& name) const { | |
125 std::unique_ptr<JSONFeatureProviderSource> source( | 122 std::unique_ptr<JSONFeatureProviderSource> source( |
126 new JSONFeatureProviderSource(name)); | 123 new JSONFeatureProviderSource("api")); |
127 if (name == "api") { | 124 source->LoadJSON(IDR_EXTENSION_API_FEATURES); |
128 source->LoadJSON(IDR_EXTENSION_API_FEATURES); | 125 source->LoadJSON(IDR_SHELL_EXTENSION_API_FEATURES); |
129 source->LoadJSON(IDR_SHELL_EXTENSION_API_FEATURES); | |
130 } else if (name == "manifest") { | |
131 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | |
132 } else if (name == "permission") { | |
133 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | |
134 } else if (name == "behavior") { | |
135 source->LoadJSON(IDR_EXTENSION_BEHAVIOR_FEATURES); | |
136 } else { | |
137 NOTREACHED(); | |
138 source.reset(); | |
139 } | |
140 return source; | 126 return source; |
141 } | 127 } |
142 | 128 |
143 void ShellExtensionsClient::FilterHostPermissions( | 129 void ShellExtensionsClient::FilterHostPermissions( |
144 const URLPatternSet& hosts, | 130 const URLPatternSet& hosts, |
145 URLPatternSet* new_hosts, | 131 URLPatternSet* new_hosts, |
146 PermissionIDSet* permissions) const { | 132 PermissionIDSet* permissions) const { |
147 NOTIMPLEMENTED(); | 133 NOTIMPLEMENTED(); |
148 } | 134 } |
149 | 135 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return extension_urls::kChromeWebstoreUpdateURL; | 192 return extension_urls::kChromeWebstoreUpdateURL; |
207 } | 193 } |
208 | 194 |
209 bool ShellExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { | 195 bool ShellExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { |
210 // TODO(rockot): Maybe we want to do something else here. For now we accept | 196 // TODO(rockot): Maybe we want to do something else here. For now we accept |
211 // any URL as a blacklist URL because we don't really care. | 197 // any URL as a blacklist URL because we don't really care. |
212 return true; | 198 return true; |
213 } | 199 } |
214 | 200 |
215 } // namespace extensions | 201 } // namespace extensions |
OLD | NEW |