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

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

Issue 2241203003: Pass user session type to extension feature checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out some stuff 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/complex_feature.h" 5 #include "extensions/common/features/complex_feature.h"
6 6
7 namespace extensions { 7 namespace extensions {
8 8
9 ComplexFeature::ComplexFeature(std::vector<Feature*>* features) { 9 ComplexFeature::ComplexFeature(std::vector<Feature*>* features) {
10 DCHECK_GT(features->size(), 0UL); 10 DCHECK_GT(features->size(), 0UL);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return availability; 52 return availability;
53 } 53 }
54 // If none of the SimpleFeatures are available, we return the availability 54 // If none of the SimpleFeatures are available, we return the availability
55 // info of the first SimpleFeature that was not available. 55 // info of the first SimpleFeature that was not available.
56 return first_availability; 56 return first_availability;
57 } 57 }
58 58
59 Feature::Availability ComplexFeature::IsAvailableToContext( 59 Feature::Availability ComplexFeature::IsAvailableToContext(
60 const Extension* extension, 60 const Extension* extension,
61 Context context, 61 Context context,
62 SessionType session_type,
62 const GURL& url, 63 const GURL& url,
63 Platform platform) const { 64 Platform platform) const {
64 Feature::Availability first_availability = 65 Feature::Availability first_availability = features_[0]->IsAvailableToContext(
65 features_[0]->IsAvailableToContext(extension, context, url, platform); 66 extension, context, session_type, url, platform);
66 if (first_availability.is_available()) 67 if (first_availability.is_available())
67 return first_availability; 68 return first_availability;
68 69
69 for (FeatureList::const_iterator it = features_.begin() + 1; 70 for (FeatureList::const_iterator it = features_.begin() + 1;
70 it != features_.end(); ++it) { 71 it != features_.end(); ++it) {
71 Availability availability = 72 Availability availability = (*it)->IsAvailableToContext(
72 (*it)->IsAvailableToContext(extension, context, url, platform); 73 extension, context, session_type, url, platform);
73 if (availability.is_available()) 74 if (availability.is_available())
74 return availability; 75 return availability;
75 } 76 }
76 // If none of the SimpleFeatures are available, we return the availability 77 // If none of the SimpleFeatures are available, we return the availability
77 // info of the first SimpleFeature that was not available. 78 // info of the first SimpleFeature that was not available.
78 return first_availability; 79 return first_availability;
79 } 80 }
80 81
81 bool ComplexFeature::IsIdInBlacklist(const std::string& extension_id) const { 82 bool ComplexFeature::IsIdInBlacklist(const std::string& extension_id) const {
82 for (FeatureList::const_iterator it = features_.begin(); 83 for (FeatureList::const_iterator it = features_.begin();
(...skipping 15 matching lines...) Expand all
98 return false; 99 return false;
99 } 100 }
100 101
101 bool ComplexFeature::IsInternal() const { 102 bool ComplexFeature::IsInternal() const {
102 // Constructor verifies that composed features are consistent, thus we can 103 // Constructor verifies that composed features are consistent, thus we can
103 // return just the first feature's value. 104 // return just the first feature's value.
104 return features_[0]->IsInternal(); 105 return features_[0]->IsInternal();
105 } 106 }
106 107
107 } // namespace extensions 108 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698