| 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/test/test_extensions_client.h" | 5 #include "extensions/test/test_extensions_client.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "extensions/common/api/generated_schemas.h" | 8 #include "extensions/common/api/generated_schemas.h" |
| 9 #include "extensions/common/common_manifest_handlers.h" | 9 #include "extensions/common/common_manifest_handlers.h" |
| 10 #include "extensions/common/extension_urls.h" | 10 #include "extensions/common/extension_urls.h" |
| 11 #include "extensions/common/features/api_feature.h" | 11 #include "extensions/common/features/api_feature.h" |
| 12 #include "extensions/common/features/behavior_feature.h" | 12 #include "extensions/common/features/behavior_feature.h" |
| 13 #include "extensions/common/features/feature_provider.h" | 13 #include "extensions/common/features/feature_provider.h" |
| 14 #include "extensions/common/features/json_feature_provider.h" | 14 #include "extensions/common/features/json_feature_provider.h" |
| 15 #include "extensions/common/features/json_feature_provider_source.h" | 15 #include "extensions/common/features/json_feature_provider_source.h" |
| 16 #include "extensions/common/features/manifest_feature.h" | 16 #include "extensions/common/features/manifest_feature.h" |
| 17 #include "extensions/common/features/permission_feature.h" | 17 #include "extensions/common/features/permission_feature.h" |
| 18 #include "extensions/common/manifest_handler.h" | 18 #include "extensions/common/manifest_handler.h" |
| 19 #include "extensions/common/permissions/extensions_api_permissions.h" | 19 #include "extensions/common/permissions/extensions_api_permissions.h" |
| 20 #include "extensions/common/permissions/permissions_info.h" | 20 #include "extensions/common/permissions/permissions_info.h" |
| 21 #include "extensions/common/url_pattern_set.h" | 21 #include "extensions/common/url_pattern_set.h" |
| 22 #include "extensions/test/test_api_features.h" |
| 23 #include "extensions/test/test_behavior_features.h" |
| 24 #include "extensions/test/test_manifest_features.h" |
| 25 #include "extensions/test/test_permission_features.h" |
| 22 #include "extensions/test/test_permission_message_provider.h" | 26 #include "extensions/test/test_permission_message_provider.h" |
| 23 #include "grit/extensions_resources.h" | 27 #include "grit/extensions_resources.h" |
| 24 | 28 |
| 25 namespace extensions { | 29 namespace extensions { |
| 26 | 30 |
| 27 namespace { | 31 namespace { |
| 28 | 32 |
| 29 template <class FeatureClass> | 33 template <class FeatureClass> |
| 30 SimpleFeature* CreateFeature() { | 34 SimpleFeature* CreateFeature() { |
| 31 return new FeatureClass; | 35 return new FeatureClass; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return provider; | 72 return provider; |
| 69 } | 73 } |
| 70 | 74 |
| 71 const std::string TestExtensionsClient::GetProductName() { | 75 const std::string TestExtensionsClient::GetProductName() { |
| 72 return "extensions_test"; | 76 return "extensions_test"; |
| 73 } | 77 } |
| 74 | 78 |
| 75 std::unique_ptr<FeatureProvider> TestExtensionsClient::CreateFeatureProvider( | 79 std::unique_ptr<FeatureProvider> TestExtensionsClient::CreateFeatureProvider( |
| 76 const std::string& name) const { | 80 const std::string& name) const { |
| 77 std::unique_ptr<FeatureProvider> provider; | 81 std::unique_ptr<FeatureProvider> provider; |
| 78 std::unique_ptr<JSONFeatureProviderSource> source( | |
| 79 CreateFeatureProviderSource(name)); | |
| 80 if (name == "api") { | 82 if (name == "api") { |
| 81 provider.reset(new JSONFeatureProvider(source->dictionary(), | 83 provider.reset(new TestAPIFeatureProvider()); |
| 82 CreateFeature<APIFeature>)); | |
| 83 } else if (name == "manifest") { | 84 } else if (name == "manifest") { |
| 84 provider.reset(new JSONFeatureProvider(source->dictionary(), | 85 provider.reset(new TestManifestFeatureProvider()); |
| 85 CreateFeature<ManifestFeature>)); | |
| 86 } else if (name == "permission") { | 86 } else if (name == "permission") { |
| 87 provider.reset(new JSONFeatureProvider(source->dictionary(), | 87 provider.reset(new TestPermissionFeatureProvider()); |
| 88 CreateFeature<PermissionFeature>)); | |
| 89 } else if (name == "behavior") { | 88 } else if (name == "behavior") { |
| 90 provider.reset(new JSONFeatureProvider(source->dictionary(), | 89 provider.reset(new TestBehaviorFeatureProvider()); |
| 91 CreateFeature<BehaviorFeature>)); | |
| 92 } else { | 90 } else { |
| 93 NOTREACHED(); | 91 NOTREACHED(); |
| 94 } | 92 } |
| 95 return provider; | 93 return provider; |
| 96 } | 94 } |
| 97 | 95 |
| 98 std::unique_ptr<JSONFeatureProviderSource> | 96 std::unique_ptr<JSONFeatureProviderSource> |
| 99 TestExtensionsClient::CreateFeatureProviderSource( | 97 TestExtensionsClient::CreateAPIFeatureSource() const { |
| 100 const std::string& name) const { | |
| 101 std::unique_ptr<JSONFeatureProviderSource> source( | 98 std::unique_ptr<JSONFeatureProviderSource> source( |
| 102 new JSONFeatureProviderSource(name)); | 99 new JSONFeatureProviderSource("api")); |
| 103 if (name == "api") { | 100 source->LoadJSON(IDR_EXTENSION_API_FEATURES); |
| 104 source->LoadJSON(IDR_EXTENSION_API_FEATURES); | |
| 105 } else if (name == "manifest") { | |
| 106 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | |
| 107 } else if (name == "permission") { | |
| 108 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | |
| 109 } else if (name == "behavior") { | |
| 110 source->LoadJSON(IDR_EXTENSION_BEHAVIOR_FEATURES); | |
| 111 } else { | |
| 112 NOTREACHED(); | |
| 113 source.reset(); | |
| 114 } | |
| 115 return source; | 101 return source; |
| 116 } | 102 } |
| 117 | 103 |
| 118 void TestExtensionsClient::FilterHostPermissions( | 104 void TestExtensionsClient::FilterHostPermissions( |
| 119 const URLPatternSet& hosts, | 105 const URLPatternSet& hosts, |
| 120 URLPatternSet* new_hosts, | 106 URLPatternSet* new_hosts, |
| 121 PermissionIDSet* permissions) const { | 107 PermissionIDSet* permissions) const { |
| 122 } | 108 } |
| 123 | 109 |
| 124 void TestExtensionsClient::SetScriptingWhitelist( | 110 void TestExtensionsClient::SetScriptingWhitelist( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 std::set<base::FilePath> TestExtensionsClient::GetBrowserImagePaths( | 164 std::set<base::FilePath> TestExtensionsClient::GetBrowserImagePaths( |
| 179 const Extension* extension) { | 165 const Extension* extension) { |
| 180 std::set<base::FilePath> result = | 166 std::set<base::FilePath> result = |
| 181 ExtensionsClient::GetBrowserImagePaths(extension); | 167 ExtensionsClient::GetBrowserImagePaths(extension); |
| 182 for (auto* filter : browser_image_filters_) | 168 for (auto* filter : browser_image_filters_) |
| 183 filter->Filter(extension, &result); | 169 filter->Filter(extension, &result); |
| 184 return result; | 170 return result; |
| 185 } | 171 } |
| 186 | 172 |
| 187 } // namespace extensions | 173 } // namespace extensions |
| OLD | NEW |