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 "chrome/common/extensions/chrome_extensions_client.h" | 5 #include "chrome/common/extensions/chrome_extensions_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/extensions/api/api_features.h" |
| 16 #include "chrome/common/extensions/api/behavior_features.h" |
15 #include "chrome/common/extensions/api/extension_action/action_info.h" | 17 #include "chrome/common/extensions/api/extension_action/action_info.h" |
16 #include "chrome/common/extensions/api/generated_schemas.h" | 18 #include "chrome/common/extensions/api/generated_schemas.h" |
| 19 #include "chrome/common/extensions/api/manifest_features.h" |
| 20 #include "chrome/common/extensions/api/permission_features.h" |
17 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 21 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
18 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
19 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" | 23 #include "chrome/common/extensions/manifest_handlers/theme_handler.h" |
20 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
21 #include "chrome/grit/chromium_strings.h" | 25 #include "chrome/grit/chromium_strings.h" |
22 #include "chrome/grit/common_resources.h" | 26 #include "chrome/grit/common_resources.h" |
23 #include "chrome/grit/extensions_api_resources.h" | 27 #include "chrome/grit/extensions_api_resources.h" |
24 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
25 #include "components/version_info/version_info.h" | 29 #include "components/version_info/version_info.h" |
26 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return permission_message_provider_; | 137 return permission_message_provider_; |
134 } | 138 } |
135 | 139 |
136 const std::string ChromeExtensionsClient::GetProductName() { | 140 const std::string ChromeExtensionsClient::GetProductName() { |
137 return l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); | 141 return l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); |
138 } | 142 } |
139 | 143 |
140 std::unique_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider( | 144 std::unique_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider( |
141 const std::string& name) const { | 145 const std::string& name) const { |
142 std::unique_ptr<FeatureProvider> provider; | 146 std::unique_ptr<FeatureProvider> provider; |
143 std::unique_ptr<JSONFeatureProviderSource> source( | |
144 CreateFeatureProviderSource(name)); | |
145 if (name == "api") { | 147 if (name == "api") { |
146 provider.reset(new JSONFeatureProvider(source->dictionary(), | 148 provider.reset(new APIFeatureProvider()); |
147 CreateFeature<APIFeature>)); | |
148 } else if (name == "manifest") { | 149 } else if (name == "manifest") { |
149 provider.reset(new JSONFeatureProvider(source->dictionary(), | 150 provider.reset(new ManifestFeatureProvider()); |
150 CreateFeature<ManifestFeature>)); | |
151 } else if (name == "permission") { | 151 } else if (name == "permission") { |
152 provider.reset(new JSONFeatureProvider(source->dictionary(), | 152 provider.reset(new PermissionFeatureProvider()); |
153 CreateFeature<PermissionFeature>)); | |
154 } else if (name == "behavior") { | 153 } else if (name == "behavior") { |
155 provider.reset(new JSONFeatureProvider(source->dictionary(), | 154 provider.reset(new BehaviorFeatureProvider()); |
156 CreateFeature<BehaviorFeature>)); | |
157 } else { | 155 } else { |
158 NOTREACHED(); | 156 NOTREACHED(); |
159 } | 157 } |
160 return provider; | 158 return provider; |
161 } | 159 } |
162 | 160 |
163 std::unique_ptr<JSONFeatureProviderSource> | 161 std::unique_ptr<JSONFeatureProviderSource> |
164 ChromeExtensionsClient::CreateFeatureProviderSource( | 162 ChromeExtensionsClient::CreateAPIFeatureSource() const { |
165 const std::string& name) const { | |
166 std::unique_ptr<JSONFeatureProviderSource> source( | 163 std::unique_ptr<JSONFeatureProviderSource> source( |
167 new JSONFeatureProviderSource(name)); | 164 new JSONFeatureProviderSource("api")); |
168 if (name == "api") { | 165 source->LoadJSON(IDR_EXTENSION_API_FEATURES); |
169 source->LoadJSON(IDR_EXTENSION_API_FEATURES); | 166 source->LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); |
170 source->LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); | |
171 } else if (name == "manifest") { | |
172 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | |
173 source->LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES); | |
174 } else if (name == "permission") { | |
175 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | |
176 source->LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES); | |
177 } else if (name == "behavior") { | |
178 source->LoadJSON(IDR_EXTENSION_BEHAVIOR_FEATURES); | |
179 } else { | |
180 NOTREACHED(); | |
181 source.reset(); | |
182 } | |
183 return source; | 167 return source; |
184 } | 168 } |
185 | 169 |
186 void ChromeExtensionsClient::FilterHostPermissions( | 170 void ChromeExtensionsClient::FilterHostPermissions( |
187 const URLPatternSet& hosts, | 171 const URLPatternSet& hosts, |
188 URLPatternSet* new_hosts, | 172 URLPatternSet* new_hosts, |
189 PermissionIDSet* permissions) const { | 173 PermissionIDSet* permissions) const { |
190 // When editing this function, be sure to add the same functionality to | 174 // When editing this function, be sure to add the same functionality to |
191 // FilterHostPermissions() above. | 175 // FilterHostPermissions() above. |
192 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i) { | 176 for (URLPatternSet::const_iterator i = hosts.begin(); i != hosts.end(); ++i) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 const { | 357 const { |
374 return GetCurrentChannel() == version_info::Channel::UNKNOWN; | 358 return GetCurrentChannel() == version_info::Channel::UNKNOWN; |
375 } | 359 } |
376 | 360 |
377 // static | 361 // static |
378 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 362 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
379 return g_client.Pointer(); | 363 return g_client.Pointer(); |
380 } | 364 } |
381 | 365 |
382 } // namespace extensions | 366 } // namespace extensions |
OLD | NEW |