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

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

Issue 377753003: Remove GetContexts() from the public interface of extensions::Feature. It was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/features/complex_feature.h ('k') | extensions/common/features/feature.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/complex_feature.h" 5 #include "extensions/common/features/complex_feature.h"
6 6
7 namespace extensions { 7 namespace extensions {
8 8
9 ComplexFeature::ComplexFeature(scoped_ptr<FeatureList> features) { 9 ComplexFeature::ComplexFeature(scoped_ptr<FeatureList> features) {
10 DCHECK_GT(features->size(), 0UL); 10 DCHECK_GT(features->size(), 0UL);
11 features_.swap(*features); 11 features_.swap(*features);
12 no_parent_ = features_[0]->no_parent(); 12 no_parent_ = features_[0]->no_parent();
13 13
14 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 14 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
15 // Verify GetContexts, IsInternal, & IsBlockedInServiceWorker are consistent 15 // Verify IsInternal and IsBlockedInServiceWorker are consistent across all
16 // across all features. 16 // features.
17 std::set<Feature::Context>* first_contexts = features_[0]->GetContexts();
18 bool first_is_internal = features_[0]->IsInternal(); 17 bool first_is_internal = features_[0]->IsInternal();
19 bool first_blocked_in_service_worker = 18 bool first_blocked_in_service_worker =
20 features_[0]->IsBlockedInServiceWorker(); 19 features_[0]->IsBlockedInServiceWorker();
21 for (FeatureList::const_iterator it = features_.begin() + 1; 20 for (FeatureList::const_iterator it = features_.begin() + 1;
22 it != features_.end(); 21 it != features_.end();
23 ++it) { 22 ++it) {
24 DCHECK(*first_contexts == *(*it)->GetContexts())
25 << "Complex feature must have consistent values of "
26 "contexts across all sub features.";
27 DCHECK(first_is_internal == (*it)->IsInternal()) 23 DCHECK(first_is_internal == (*it)->IsInternal())
28 << "Complex feature must have consistent values of " 24 << "Complex feature must have consistent values of "
29 "internal across all sub features."; 25 "internal across all sub features.";
30 DCHECK(first_blocked_in_service_worker == (*it)->IsBlockedInServiceWorker()) 26 DCHECK(first_blocked_in_service_worker == (*it)->IsBlockedInServiceWorker())
31 << "Complex feature must have consistent values of " 27 << "Complex feature must have consistent values of "
32 "blocked_in_service_worker across all sub features."; 28 "blocked_in_service_worker across all sub features.";
33 DCHECK(no_parent_ == (*it)->no_parent()) 29 DCHECK(no_parent_ == (*it)->no_parent())
34 << "Complex feature must have consistent values of " 30 << "Complex feature must have consistent values of "
35 "no_parent across all sub features."; 31 "no_parent across all sub features.";
36 } 32 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 101 }
106 return false; 102 return false;
107 } 103 }
108 104
109 bool ComplexFeature::IsBlockedInServiceWorker() const { 105 bool ComplexFeature::IsBlockedInServiceWorker() const {
110 // Constructor verifies that composed features are consistent, thus we can 106 // Constructor verifies that composed features are consistent, thus we can
111 // return just the first feature's value. 107 // return just the first feature's value.
112 return features_[0]->IsBlockedInServiceWorker(); 108 return features_[0]->IsBlockedInServiceWorker();
113 } 109 }
114 110
115 std::set<Feature::Context>* ComplexFeature::GetContexts() {
116 // TODO(justinlin): Current use cases for ComplexFeatures are simple (e.g.
117 // allow API in dev channel for everyone but stable channel for a whitelist),
118 // but if they get more complicated, we need to return some meaningful context
119 // set. Either that or remove this method from the Feature interface.
120 return features_[0]->GetContexts();
121 }
122
123 bool ComplexFeature::IsInternal() const { 111 bool ComplexFeature::IsInternal() const {
124 // TODO(justinlin): Same as the above TODO. 112 // Constructor verifies that composed features are consistent, thus we can
113 // return just the first feature's value.
125 return features_[0]->IsInternal(); 114 return features_[0]->IsInternal();
126 } 115 }
127 116
128 std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result, 117 std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result,
129 Manifest::Type type, 118 Manifest::Type type,
130 const GURL& url, 119 const GURL& url,
131 Context context) const { 120 Context context) const {
132 if (result == IS_AVAILABLE) 121 if (result == IS_AVAILABLE)
133 return std::string(); 122 return std::string();
134 123
135 // TODO(justinlin): Form some kind of combined availabilities/messages from 124 // TODO(justinlin): Form some kind of combined availabilities/messages from
136 // SimpleFeatures. 125 // SimpleFeatures.
137 return features_[0]->GetAvailabilityMessage(result, type, url, context); 126 return features_[0]->GetAvailabilityMessage(result, type, url, context);
138 } 127 }
139 128
140 } // namespace extensions 129 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/complex_feature.h ('k') | extensions/common/features/feature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698