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/common/features/simple_feature.h" | 5 #include "extensions/common/features/simple_feature.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 std::map<std::string, Feature::Context> contexts; | 303 std::map<std::string, Feature::Context> contexts; |
304 std::map<std::string, SimpleFeature::Location> locations; | 304 std::map<std::string, SimpleFeature::Location> locations; |
305 std::map<std::string, Feature::Platform> platforms; | 305 std::map<std::string, Feature::Platform> platforms; |
306 std::map<std::string, version_info::Channel> channels; | 306 std::map<std::string, version_info::Channel> channels; |
307 }; | 307 }; |
308 | 308 |
309 SimpleFeature::SimpleFeature() | 309 SimpleFeature::SimpleFeature() |
310 : location_(UNSPECIFIED_LOCATION), | 310 : location_(UNSPECIFIED_LOCATION), |
311 min_manifest_version_(0), | 311 min_manifest_version_(0), |
312 max_manifest_version_(0), | 312 max_manifest_version_(0), |
313 component_extensions_auto_granted_(true) {} | 313 component_extensions_auto_granted_(true), |
| 314 is_internal_(false) {} |
314 | 315 |
315 SimpleFeature::~SimpleFeature() {} | 316 SimpleFeature::~SimpleFeature() {} |
316 | 317 |
317 std::string SimpleFeature::Parse(const base::DictionaryValue* dictionary) { | 318 std::string SimpleFeature::Parse(const base::DictionaryValue* dictionary) { |
318 static base::LazyInstance<SimpleFeature::Mappings> mappings = | 319 static base::LazyInstance<SimpleFeature::Mappings> mappings = |
319 LAZY_INSTANCE_INITIALIZER; | 320 LAZY_INSTANCE_INITIALIZER; |
320 | 321 |
321 no_parent_ = false; | 322 no_parent_ = false; |
322 for (base::DictionaryValue::Iterator it(*dictionary); | 323 for (base::DictionaryValue::Iterator it(*dictionary); |
323 !it.IsAtEnd(); | 324 !it.IsAtEnd(); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 577 |
577 Feature::Availability SimpleFeature::CreateAvailability( | 578 Feature::Availability SimpleFeature::CreateAvailability( |
578 AvailabilityResult result, | 579 AvailabilityResult result, |
579 version_info::Channel channel) const { | 580 version_info::Channel channel) const { |
580 return Availability( | 581 return Availability( |
581 result, GetAvailabilityMessage(result, Manifest::TYPE_UNKNOWN, GURL(), | 582 result, GetAvailabilityMessage(result, Manifest::TYPE_UNKNOWN, GURL(), |
582 UNSPECIFIED_CONTEXT, channel)); | 583 UNSPECIFIED_CONTEXT, channel)); |
583 } | 584 } |
584 | 585 |
585 bool SimpleFeature::IsInternal() const { | 586 bool SimpleFeature::IsInternal() const { |
586 return false; | 587 return is_internal_; |
587 } | 588 } |
588 | 589 |
589 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const { | 590 bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const { |
590 return IsIdInList(extension_id, blacklist_); | 591 return IsIdInList(extension_id, blacklist_); |
591 } | 592 } |
592 | 593 |
593 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { | 594 bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const { |
594 return IsIdInList(extension_id, whitelist_); | 595 return IsIdInList(extension_id, whitelist_); |
595 } | 596 } |
596 | 597 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 // static | 653 // static |
653 bool SimpleFeature::IsValidExtensionId(const std::string& extension_id) { | 654 bool SimpleFeature::IsValidExtensionId(const std::string& extension_id) { |
654 // Belt-and-suspenders philosophy here. We should be pretty confident by this | 655 // Belt-and-suspenders philosophy here. We should be pretty confident by this |
655 // point that we've validated the extension ID format, but in case something | 656 // point that we've validated the extension ID format, but in case something |
656 // slips through, we avoid a class of attack where creative ID manipulation | 657 // slips through, we avoid a class of attack where creative ID manipulation |
657 // leads to hash collisions. | 658 // leads to hash collisions. |
658 // 128 bits / 4 = 32 mpdecimal characters | 659 // 128 bits / 4 = 32 mpdecimal characters |
659 return (extension_id.length() == 32); | 660 return (extension_id.length() == 32); |
660 } | 661 } |
661 | 662 |
| 663 void SimpleFeature::set_matches(const std::vector<std::string>& matches) { |
| 664 matches_.ClearPatterns(); |
| 665 for (const std::string& pattern : matches) |
| 666 matches_.AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern)); |
| 667 } |
| 668 |
662 } // namespace extensions | 669 } // namespace extensions |
OLD | NEW |