Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: extensions/common/features/simple_feature.cc

Issue 2186893002: Reduce size of generated extension FeatureProviders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_.assign(blacklist.begin(), blacklist.end());
672 } 673 }
673 674
674 void SimpleFeature::set_command_line_switch(std::string&& command_line_switch) { 675 void SimpleFeature::set_command_line_switch(
675 command_line_switch_ = command_line_switch; 676 base::StringPiece command_line_switch) {
677 command_line_switch_ = command_line_switch.as_string();
676 } 678 }
677 679
678 void SimpleFeature::set_contexts(std::vector<Context>&& contexts) { 680 void SimpleFeature::set_contexts(std::initializer_list<Context> contexts) {
679 contexts_ = contexts; 681 contexts_ = contexts;
680 } 682 }
681 683
682 void SimpleFeature::set_dependencies(std::vector<std::string>&& dependencies) { 684 void SimpleFeature::set_dependencies(
683 dependencies_ = dependencies; 685 std::initializer_list<const char* const> dependencies) {
686 dependencies_.assign(dependencies.begin(), dependencies.end());
684 } 687 }
685 688
686 void SimpleFeature::set_extension_types(std::vector<Manifest::Type>&& types) { 689 void SimpleFeature::set_extension_types(
690 std::initializer_list<Manifest::Type> types) {
687 extension_types_ = types; 691 extension_types_ = types;
688 } 692 }
689 693
690 void SimpleFeature::set_matches(const std::vector<std::string>& matches) { 694 void SimpleFeature::set_matches(
695 std::initializer_list<const char* const> matches) {
691 matches_.ClearPatterns(); 696 matches_.ClearPatterns();
692 for (const std::string& pattern : matches) 697 for (const auto* pattern : matches)
693 matches_.AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern)); 698 matches_.AddPattern(URLPattern(URLPattern::SCHEME_ALL, pattern));
694 } 699 }
695 700
696 void SimpleFeature::set_platforms(std::vector<Platform>&& platforms) { 701 void SimpleFeature::set_platforms(std::initializer_list<Platform> platforms) {
697 platforms_ = platforms; 702 platforms_ = platforms;
698 } 703 }
699 704
700 void SimpleFeature::set_whitelist(std::vector<std::string>&& whitelist) { 705 void SimpleFeature::set_whitelist(
701 whitelist_ = whitelist; 706 std::initializer_list<const char* const> whitelist) {
707 whitelist_.assign(whitelist.begin(), whitelist.end());
702 } 708 }
703 709
704 } // namespace extensions 710 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | tools/json_schema_compiler/feature_compiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698