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

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

Issue 2116293003: extensions: Generate hash of extension ID at a higher level Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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::unique_ptr<FeatureList> features) { 9 ComplexFeature::ComplexFeature(std::unique_ptr<FeatureList> features) {
10 DCHECK_GT(features->size(), 0UL); 10 DCHECK_GT(features->size(), 0UL);
(...skipping 14 matching lines...) Expand all
25 "no_parent across all sub features."; 25 "no_parent across all sub features.";
26 } 26 }
27 #endif 27 #endif
28 } 28 }
29 29
30 ComplexFeature::~ComplexFeature() { 30 ComplexFeature::~ComplexFeature() {
31 } 31 }
32 32
33 Feature::Availability ComplexFeature::IsAvailableToManifest( 33 Feature::Availability ComplexFeature::IsAvailableToManifest(
34 const std::string& extension_id, 34 const std::string& extension_id,
35 const std::string& hashed_id,
35 Manifest::Type type, 36 Manifest::Type type,
36 Manifest::Location location, 37 Manifest::Location location,
37 int manifest_version, 38 int manifest_version,
38 Platform platform) const { 39 Platform platform) const {
39 Feature::Availability first_availability = 40 Feature::Availability first_availability =
40 features_[0]->IsAvailableToManifest( 41 features_[0]->IsAvailableToManifest(extension_id, hashed_id, type,
41 extension_id, type, location, manifest_version, platform); 42 location, manifest_version, platform);
42 if (first_availability.is_available()) 43 if (first_availability.is_available())
43 return first_availability; 44 return first_availability;
44 45
45 for (FeatureList::const_iterator it = features_.begin() + 1; 46 for (FeatureList::const_iterator it = features_.begin() + 1;
46 it != features_.end(); ++it) { 47 it != features_.end(); ++it) {
47 Availability availability = (*it)->IsAvailableToManifest( 48 Availability availability = (*it)->IsAvailableToManifest(
48 extension_id, type, location, manifest_version, platform); 49 extension_id, hashed_id, type, location, manifest_version, platform);
49 if (availability.is_available()) 50 if (availability.is_available())
50 return availability; 51 return availability;
51 } 52 }
52 // If none of the SimpleFeatures are available, we return the availability 53 // If none of the SimpleFeatures are available, we return the availability
53 // info of the first SimpleFeature that was not available. 54 // info of the first SimpleFeature that was not available.
54 return first_availability; 55 return first_availability;
55 } 56 }
56 57
57 Feature::Availability ComplexFeature::IsAvailableToContext( 58 Feature::Availability ComplexFeature::IsAvailableToContext(
58 const Extension* extension, 59 const Extension* extension,
(...skipping 10 matching lines...) Expand all
69 Availability availability = 70 Availability availability =
70 (*it)->IsAvailableToContext(extension, context, url, platform); 71 (*it)->IsAvailableToContext(extension, context, url, platform);
71 if (availability.is_available()) 72 if (availability.is_available())
72 return availability; 73 return availability;
73 } 74 }
74 // If none of the SimpleFeatures are available, we return the availability 75 // If none of the SimpleFeatures are available, we return the availability
75 // info of the first SimpleFeature that was not available. 76 // info of the first SimpleFeature that was not available.
76 return first_availability; 77 return first_availability;
77 } 78 }
78 79
79 bool ComplexFeature::IsIdInBlacklist(const std::string& extension_id) const { 80 bool ComplexFeature::IsIdInBlacklist(const std::string& extension_id,
81 const std::string& hashed_id) const {
80 for (FeatureList::const_iterator it = features_.begin(); 82 for (FeatureList::const_iterator it = features_.begin();
81 it != features_.end(); 83 it != features_.end();
82 ++it) { 84 ++it) {
83 if ((*it)->IsIdInBlacklist(extension_id)) 85 if ((*it)->IsIdInBlacklist(extension_id, hashed_id))
84 return true; 86 return true;
85 } 87 }
86 return false; 88 return false;
87 } 89 }
88 90
89 bool ComplexFeature::IsIdInWhitelist(const std::string& extension_id) const { 91 bool ComplexFeature::IsIdInWhitelist(const std::string& extension_id,
92 const std::string& hashed_id) const {
90 for (FeatureList::const_iterator it = features_.begin(); 93 for (FeatureList::const_iterator it = features_.begin();
91 it != features_.end(); 94 it != features_.end();
92 ++it) { 95 ++it) {
93 if ((*it)->IsIdInWhitelist(extension_id)) 96 if ((*it)->IsIdInWhitelist(extension_id, hashed_id))
94 return true; 97 return true;
95 } 98 }
96 return false; 99 return false;
97 } 100 }
98 101
99 bool ComplexFeature::IsInternal() const { 102 bool ComplexFeature::IsInternal() const {
100 // Constructor verifies that composed features are consistent, thus we can 103 // Constructor verifies that composed features are consistent, thus we can
101 // return just the first feature's value. 104 // return just the first feature's value.
102 return features_[0]->IsInternal(); 105 return features_[0]->IsInternal();
103 } 106 }
104 107
105 std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result, 108 std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result,
106 Manifest::Type type, 109 Manifest::Type type,
107 const GURL& url, 110 const GURL& url,
108 Context context) const { 111 Context context) const {
109 if (result == IS_AVAILABLE) 112 if (result == IS_AVAILABLE)
110 return std::string(); 113 return std::string();
111 114
112 // TODO(justinlin): Form some kind of combined availabilities/messages from 115 // TODO(justinlin): Form some kind of combined availabilities/messages from
113 // SimpleFeatures. 116 // SimpleFeatures.
114 return features_[0]->GetAvailabilityMessage(result, type, url, context); 117 return features_[0]->GetAvailabilityMessage(result, type, url, context);
115 } 118 }
116 119
117 } // namespace extensions 120 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/features/complex_feature.h ('k') | extensions/common/features/complex_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698