| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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/features/simple_feature.h" |    5 #include "chrome/common/extensions/features/simple_feature.h" | 
|    6  |    6  | 
|    7 #include <map> |    7 #include <map> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/command_line.h" |   10 #include "base/command_line.h" | 
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  201       extension_types_ == other.extension_types_ && |  201       extension_types_ == other.extension_types_ && | 
|  202       contexts_ == other.contexts_ && |  202       contexts_ == other.contexts_ && | 
|  203       matches_ == other.matches_ && |  203       matches_ == other.matches_ && | 
|  204       location_ == other.location_ && |  204       location_ == other.location_ && | 
|  205       platform_ == other.platform_ && |  205       platform_ == other.platform_ && | 
|  206       min_manifest_version_ == other.min_manifest_version_ && |  206       min_manifest_version_ == other.min_manifest_version_ && | 
|  207       max_manifest_version_ == other.max_manifest_version_ && |  207       max_manifest_version_ == other.max_manifest_version_ && | 
|  208       channel_ == other.channel_; |  208       channel_ == other.channel_; | 
|  209 } |  209 } | 
|  210  |  210  | 
|  211 void SimpleFeature::Parse(const DictionaryValue* value) { |  211 std::string SimpleFeature::Parse(const DictionaryValue* value) { | 
|  212   ParseURLPatterns(value, "matches", &matches_); |  212   ParseURLPatterns(value, "matches", &matches_); | 
|  213   ParseSet(value, "whitelist", &whitelist_); |  213   ParseSet(value, "whitelist", &whitelist_); | 
 |  214   ParseSet(value, "dependencies", &dependencies_); | 
|  214   ParseEnumSet<Manifest::Type>(value, "extension_types", &extension_types_, |  215   ParseEnumSet<Manifest::Type>(value, "extension_types", &extension_types_, | 
|  215                                 g_mappings.Get().extension_types); |  216                                 g_mappings.Get().extension_types); | 
|  216   ParseEnumSet<Context>(value, "contexts", &contexts_, |  217   ParseEnumSet<Context>(value, "contexts", &contexts_, | 
|  217                         g_mappings.Get().contexts); |  218                         g_mappings.Get().contexts); | 
|  218   ParseEnum<Location>(value, "location", &location_, |  219   ParseEnum<Location>(value, "location", &location_, | 
|  219                       g_mappings.Get().locations); |  220                       g_mappings.Get().locations); | 
|  220   ParseEnum<Platform>(value, "platform", &platform_, |  221   ParseEnum<Platform>(value, "platform", &platform_, | 
|  221                       g_mappings.Get().platforms); |  222                       g_mappings.Get().platforms); | 
|  222   value->GetInteger("min_manifest_version", &min_manifest_version_); |  223   value->GetInteger("min_manifest_version", &min_manifest_version_); | 
|  223   value->GetInteger("max_manifest_version", &max_manifest_version_); |  224   value->GetInteger("max_manifest_version", &max_manifest_version_); | 
|  224   ParseEnum<VersionInfo::Channel>( |  225   ParseEnum<VersionInfo::Channel>( | 
|  225       value, "channel", &channel_, |  226       value, "channel", &channel_, | 
|  226       g_mappings.Get().channels); |  227       g_mappings.Get().channels); | 
 |  228   if (matches_.is_empty() && contexts_.count(WEB_PAGE_CONTEXT) != 0) { | 
 |  229     return name() + ": Allowing web_page contexts requires supplying a value " + | 
 |  230         "for matches."; | 
 |  231   } | 
 |  232   return ""; | 
|  227 } |  233 } | 
|  228  |  234  | 
|  229 Feature::Availability SimpleFeature::IsAvailableToManifest( |  235 Feature::Availability SimpleFeature::IsAvailableToManifest( | 
|  230     const std::string& extension_id, |  236     const std::string& extension_id, | 
|  231     Manifest::Type type, |  237     Manifest::Type type, | 
|  232     Location location, |  238     Location location, | 
|  233     int manifest_version, |  239     int manifest_version, | 
|  234     Platform platform) const { |  240     Platform platform) const { | 
|  235   // Component extensions can access any feature. |  241   // Component extensions can access any feature. | 
|  236   if (location == COMPONENT_LOCATION) |  242   if (location == COMPONENT_LOCATION) | 
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  426   DCHECK(id_hash.length() == base::kSHA1Length); |  432   DCHECK(id_hash.length() == base::kSHA1Length); | 
|  427   const std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(), |  433   const std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(), | 
|  428       id_hash.length()); |  434       id_hash.length()); | 
|  429   if (whitelist_.find(hexencoded_id_hash) != whitelist_.end()) |  435   if (whitelist_.find(hexencoded_id_hash) != whitelist_.end()) | 
|  430     return true; |  436     return true; | 
|  431  |  437  | 
|  432   return false; |  438   return false; | 
|  433 } |  439 } | 
|  434  |  440  | 
|  435 }  // namespace extensions |  441 }  // namespace extensions | 
| OLD | NEW |