| 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> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 9 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 11 #include "base/values.h" | 13 #include "base/values.h" |
| 12 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/extensions/api/extension_action/action_info.h" | 15 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 14 #include "chrome/common/extensions/api/generated_schemas.h" | 16 #include "chrome/common/extensions/api/generated_schemas.h" |
| 15 #include "chrome/common/extensions/chrome_manifest_handlers.h" | 17 #include "chrome/common/extensions/chrome_manifest_handlers.h" |
| 16 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const char kExtensionBlocklistUrlPrefix[] = | 60 const char kExtensionBlocklistUrlPrefix[] = |
| 59 "http://www.gstatic.com/chrome/extensions/blacklist"; | 61 "http://www.gstatic.com/chrome/extensions/blacklist"; |
| 60 const char kExtensionBlocklistHttpsUrlPrefix[] = | 62 const char kExtensionBlocklistHttpsUrlPrefix[] = |
| 61 "https://www.gstatic.com/chrome/extensions/blacklist"; | 63 "https://www.gstatic.com/chrome/extensions/blacklist"; |
| 62 | 64 |
| 63 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; | 65 const char kThumbsWhiteListedExtension[] = "khopmbdjffemhegeeobelklnbglcdgfh"; |
| 64 | 66 |
| 65 template <class FeatureClass> | 67 template <class FeatureClass> |
| 66 SimpleFeature* CreateFeature() { | 68 SimpleFeature* CreateFeature() { |
| 67 SimpleFeature* feature = new FeatureClass; | 69 SimpleFeature* feature = new FeatureClass; |
| 68 feature->AddFilter( | 70 feature->AddFilter(std::unique_ptr<SimpleFeatureFilter>( |
| 69 scoped_ptr<SimpleFeatureFilter>(new ChromeChannelFeatureFilter(feature))); | 71 new ChromeChannelFeatureFilter(feature))); |
| 70 return feature; | 72 return feature; |
| 71 } | 73 } |
| 72 | 74 |
| 73 // Mirrors version_info::Channel for histograms. | 75 // Mirrors version_info::Channel for histograms. |
| 74 enum ChromeChannelForHistogram { | 76 enum ChromeChannelForHistogram { |
| 75 CHANNEL_UNKNOWN, | 77 CHANNEL_UNKNOWN, |
| 76 CHANNEL_CANARY, | 78 CHANNEL_CANARY, |
| 77 CHANNEL_DEV, | 79 CHANNEL_DEV, |
| 78 CHANNEL_BETA, | 80 CHANNEL_BETA, |
| 79 CHANNEL_STABLE, | 81 CHANNEL_STABLE, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 137 |
| 136 const PermissionMessageProvider& | 138 const PermissionMessageProvider& |
| 137 ChromeExtensionsClient::GetPermissionMessageProvider() const { | 139 ChromeExtensionsClient::GetPermissionMessageProvider() const { |
| 138 return permission_message_provider_; | 140 return permission_message_provider_; |
| 139 } | 141 } |
| 140 | 142 |
| 141 const std::string ChromeExtensionsClient::GetProductName() { | 143 const std::string ChromeExtensionsClient::GetProductName() { |
| 142 return l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); | 144 return l10n_util::GetStringUTF8(IDS_PRODUCT_NAME); |
| 143 } | 145 } |
| 144 | 146 |
| 145 scoped_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider( | 147 std::unique_ptr<FeatureProvider> ChromeExtensionsClient::CreateFeatureProvider( |
| 146 const std::string& name) const { | 148 const std::string& name) const { |
| 147 scoped_ptr<FeatureProvider> provider; | 149 std::unique_ptr<FeatureProvider> provider; |
| 148 scoped_ptr<JSONFeatureProviderSource> source( | 150 std::unique_ptr<JSONFeatureProviderSource> source( |
| 149 CreateFeatureProviderSource(name)); | 151 CreateFeatureProviderSource(name)); |
| 150 if (name == "api") { | 152 if (name == "api") { |
| 151 provider.reset(new BaseFeatureProvider(source->dictionary(), | 153 provider.reset(new BaseFeatureProvider(source->dictionary(), |
| 152 CreateFeature<APIFeature>)); | 154 CreateFeature<APIFeature>)); |
| 153 } else if (name == "manifest") { | 155 } else if (name == "manifest") { |
| 154 provider.reset(new BaseFeatureProvider(source->dictionary(), | 156 provider.reset(new BaseFeatureProvider(source->dictionary(), |
| 155 CreateFeature<ManifestFeature>)); | 157 CreateFeature<ManifestFeature>)); |
| 156 } else if (name == "permission") { | 158 } else if (name == "permission") { |
| 157 provider.reset(new BaseFeatureProvider(source->dictionary(), | 159 provider.reset(new BaseFeatureProvider(source->dictionary(), |
| 158 CreateFeature<PermissionFeature>)); | 160 CreateFeature<PermissionFeature>)); |
| 159 } else if (name == "behavior") { | 161 } else if (name == "behavior") { |
| 160 provider.reset(new BaseFeatureProvider(source->dictionary(), | 162 provider.reset(new BaseFeatureProvider(source->dictionary(), |
| 161 CreateFeature<BehaviorFeature>)); | 163 CreateFeature<BehaviorFeature>)); |
| 162 } else { | 164 } else { |
| 163 NOTREACHED(); | 165 NOTREACHED(); |
| 164 } | 166 } |
| 165 return provider; | 167 return provider; |
| 166 } | 168 } |
| 167 | 169 |
| 168 scoped_ptr<JSONFeatureProviderSource> | 170 std::unique_ptr<JSONFeatureProviderSource> |
| 169 ChromeExtensionsClient::CreateFeatureProviderSource( | 171 ChromeExtensionsClient::CreateFeatureProviderSource( |
| 170 const std::string& name) const { | 172 const std::string& name) const { |
| 171 scoped_ptr<JSONFeatureProviderSource> source( | 173 std::unique_ptr<JSONFeatureProviderSource> source( |
| 172 new JSONFeatureProviderSource(name)); | 174 new JSONFeatureProviderSource(name)); |
| 173 if (name == "api") { | 175 if (name == "api") { |
| 174 source->LoadJSON(IDR_EXTENSION_API_FEATURES); | 176 source->LoadJSON(IDR_EXTENSION_API_FEATURES); |
| 175 source->LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); | 177 source->LoadJSON(IDR_CHROME_EXTENSION_API_FEATURES); |
| 176 } else if (name == "manifest") { | 178 } else if (name == "manifest") { |
| 177 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | 179 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); |
| 178 source->LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES); | 180 source->LoadJSON(IDR_CHROME_EXTENSION_MANIFEST_FEATURES); |
| 179 } else if (name == "permission") { | 181 } else if (name == "permission") { |
| 180 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | 182 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); |
| 181 source->LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES); | 183 source->LoadJSON(IDR_CHROME_EXTENSION_PERMISSION_FEATURES); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 377 |
| 376 return image_paths; | 378 return image_paths; |
| 377 } | 379 } |
| 378 | 380 |
| 379 // static | 381 // static |
| 380 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { | 382 ChromeExtensionsClient* ChromeExtensionsClient::GetInstance() { |
| 381 return g_client.Pointer(); | 383 return g_client.Pointer(); |
| 382 } | 384 } |
| 383 | 385 |
| 384 } // namespace extensions | 386 } // namespace extensions |
| OLD | NEW |