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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 // static | 660 // static |
661 bool SimpleFeature::IsValidExtensionId(const std::string& extension_id) { | 661 bool SimpleFeature::IsValidExtensionId(const std::string& extension_id) { |
662 // Belt-and-suspenders philosophy here. We should be pretty confident by this | 662 // Belt-and-suspenders philosophy here. We should be pretty confident by this |
663 // point that we've validated the extension ID format, but in case something | 663 // point that we've validated the extension ID format, but in case something |
664 // slips through, we avoid a class of attack where creative ID manipulation | 664 // slips through, we avoid a class of attack where creative ID manipulation |
665 // leads to hash collisions. | 665 // leads to hash collisions. |
666 // 128 bits / 4 = 32 mpdecimal characters | 666 // 128 bits / 4 = 32 mpdecimal characters |
667 return (extension_id.length() == 32); | 667 return (extension_id.length() == 32); |
668 } | 668 } |
669 | 669 |
670 void SimpleFeature::set_blacklist(std::vector<std::string>&& blacklist) { | 670 void SimpleFeature::set_blacklist( |
671 blacklist_ = blacklist; | 671 std::initializer_list<const char* const> blacklist) { |
672 blacklist_.clear(); | |
Devlin
2016/07/27 15:36:49
These should only be called at feature constructio
dcheng
2016/07/27 16:07:47
The size impact of this is pretty negligible, mayb
| |
673 for (const auto* entry : blacklist) | |
674 blacklist_.push_back(entry); | |
672 } | 675 } |
673 | 676 |
674 void SimpleFeature::set_command_line_switch(std::string&& command_line_switch) { | 677 void SimpleFeature::set_command_line_switch(std::string&& command_line_switch) { |
675 command_line_switch_ = command_line_switch; | 678 command_line_switch_ = command_line_switch; |
676 } | 679 } |
677 | 680 |
678 void SimpleFeature::set_contexts(std::vector<Context>&& contexts) { | 681 void SimpleFeature::set_contexts(std::initializer_list<Context> contexts) { |
679 contexts_ = contexts; | 682 contexts_ = contexts; |
680 } | 683 } |
681 | 684 |
682 void SimpleFeature::set_dependencies(std::vector<std::string>&& dependencies) { | 685 void SimpleFeature::set_dependencies( |
683 dependencies_ = dependencies; | 686 std::initializer_list<const char* const> dependencies) { |
687 dependencies_.clear(); | |
688 for (const auto* entry : dependencies) | |
689 dependencies_.push_back(entry); | |
684 } | 690 } |
685 | 691 |
686 void SimpleFeature::set_extension_types(std::vector<Manifest::Type>&& types) { | 692 void SimpleFeature::set_extension_types( |
693 std::initializer_list<Manifest::Type> types) { | |
687 extension_types_ = types; | 694 extension_types_ = types; |
688 } | 695 } |
689 | 696 |
690 void SimpleFeature::set_matches(const std::vector<std::string>& matches) { | 697 void SimpleFeature::set_matches( |
698 std::initializer_list<const char* const> matches) { | |
691 matches_.ClearPatterns(); | 699 matches_.ClearPatterns(); |
692 for (const std::string& pattern : matches) | 700 for (const auto* pattern : matches) |
693 matches_.AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern)); | 701 matches_.AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern)); |
694 } | 702 } |
695 | 703 |
696 void SimpleFeature::set_platforms(std::vector<Platform>&& platforms) { | 704 void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) { |
697 platforms_ = platforms; | 705 platforms_ = platforms; |
698 } | 706 } |
699 | 707 |
700 void SimpleFeature::set_whitelist(std::vector<std::string>&& whitelist) { | 708 void SimpleFeature::set_whitelist( |
701 whitelist_ = whitelist; | 709 std::initializer_list<const char* const> whitelist) { |
710 whitelist_.clear(); | |
711 for (const auto* entry : whitelist) | |
712 whitelist_.push_back(entry); | |
702 } | 713 } |
703 | 714 |
704 } // namespace extensions | 715 } // namespace extensions |
OLD | NEW |