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 #ifndef EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 5 #ifndef EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 6 #define EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // supported in feature files. These should only be used in this class and in | 92 // supported in feature files. These should only be used in this class and in |
93 // generated files. | 93 // generated files. |
94 enum Location { | 94 enum Location { |
95 UNSPECIFIED_LOCATION, | 95 UNSPECIFIED_LOCATION, |
96 COMPONENT_LOCATION, | 96 COMPONENT_LOCATION, |
97 EXTERNAL_COMPONENT_LOCATION, | 97 EXTERNAL_COMPONENT_LOCATION, |
98 POLICY_LOCATION, | 98 POLICY_LOCATION, |
99 }; | 99 }; |
100 | 100 |
101 // Setters used by generated code to create the feature. | 101 // Setters used by generated code to create the feature. |
102 void set_blacklist(const std::vector<std::string>& blacklist) { | 102 // NOTE: These setters use rvalue references deliberately. These should only |
103 blacklist_ = blacklist; | 103 // ever be used by generated code, and we ensure that in each call, the new |
104 } | 104 // value is constructed in-place. This allows us to avoid a copy when we |
| 105 // assign it to the value in this class, and results in noticable improvements |
| 106 // in both speed and binary size. |
| 107 void set_blacklist(std::vector<std::string>&& blacklist); |
105 void set_channel(version_info::Channel channel) { | 108 void set_channel(version_info::Channel channel) { |
106 channel_.reset(new version_info::Channel(channel)); | 109 channel_.reset(new version_info::Channel(channel)); |
107 } | 110 } |
108 void set_command_line_switch(const std::string& command_line_switch) { | 111 void set_command_line_switch(std::string&& command_line_switch); |
109 command_line_switch_ = command_line_switch; | |
110 } | |
111 void set_component_extensions_auto_granted(bool granted) { | 112 void set_component_extensions_auto_granted(bool granted) { |
112 component_extensions_auto_granted_ = granted; | 113 component_extensions_auto_granted_ = granted; |
113 } | 114 } |
114 void set_contexts(const std::vector<Context>& contexts) { | 115 void set_contexts(std::vector<Context>&& contexts); |
115 contexts_ = contexts; | 116 void set_dependencies(std::vector<std::string>&& dependencies); |
116 } | 117 void set_extension_types(std::vector<Manifest::Type>&& types); |
117 void set_dependencies(const std::vector<std::string>& dependencies) { | |
118 dependencies_ = dependencies; | |
119 } | |
120 void set_extension_types(const std::vector<Manifest::Type> types) { | |
121 extension_types_ = types; | |
122 } | |
123 void set_internal(bool is_internal) { is_internal_ = is_internal; } | 118 void set_internal(bool is_internal) { is_internal_ = is_internal; } |
124 void set_location(Location location) { location_ = location; } | 119 void set_location(Location location) { location_ = location; } |
| 120 // set_matches() is an exception to pass-by-value since we construct an |
| 121 // URLPatternSet from the vector of strings. |
| 122 // TODO(devlin): Pass in an URLPatternSet directly. |
125 void set_matches(const std::vector<std::string>& matches); | 123 void set_matches(const std::vector<std::string>& matches); |
126 void set_max_manifest_version(int max_manifest_version) { | 124 void set_max_manifest_version(int max_manifest_version) { |
127 max_manifest_version_ = max_manifest_version; | 125 max_manifest_version_ = max_manifest_version; |
128 } | 126 } |
129 void set_min_manifest_version(int min_manifest_version) { | 127 void set_min_manifest_version(int min_manifest_version) { |
130 min_manifest_version_ = min_manifest_version; | 128 min_manifest_version_ = min_manifest_version; |
131 } | 129 } |
132 void set_platforms(const std::vector<Platform>& platforms) { | 130 void set_platforms(std::vector<Platform>&& platforms); |
133 platforms_ = platforms; | 131 void set_whitelist(std::vector<std::string>&& whitelist); |
134 } | |
135 void set_whitelist(const std::vector<std::string>& whitelist) { | |
136 whitelist_ = whitelist; | |
137 } | |
138 | 132 |
139 protected: | 133 protected: |
140 // Accessors used by subclasses in feature verification. | 134 // Accessors used by subclasses in feature verification. |
141 const std::vector<std::string>& blacklist() const { return blacklist_; } | 135 const std::vector<std::string>& blacklist() const { return blacklist_; } |
142 const std::vector<std::string>& whitelist() const { return whitelist_; } | 136 const std::vector<std::string>& whitelist() const { return whitelist_; } |
143 const std::vector<Manifest::Type>& extension_types() const { | 137 const std::vector<Manifest::Type>& extension_types() const { |
144 return extension_types_; | 138 return extension_types_; |
145 } | 139 } |
146 const std::vector<Platform>& platforms() const { return platforms_; } | 140 const std::vector<Platform>& platforms() const { return platforms_; } |
147 const std::vector<Context>& contexts() const { return contexts_; } | 141 const std::vector<Context>& contexts() const { return contexts_; } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 bool is_internal_; | 231 bool is_internal_; |
238 std::string command_line_switch_; | 232 std::string command_line_switch_; |
239 std::unique_ptr<version_info::Channel> channel_; | 233 std::unique_ptr<version_info::Channel> channel_; |
240 | 234 |
241 DISALLOW_COPY_AND_ASSIGN(SimpleFeature); | 235 DISALLOW_COPY_AND_ASSIGN(SimpleFeature); |
242 }; | 236 }; |
243 | 237 |
244 } // namespace extensions | 238 } // namespace extensions |
245 | 239 |
246 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ | 240 #endif // EXTENSIONS_COMMON_FEATURES_SIMPLE_FEATURE_H_ |
OLD | NEW |