| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/features/complex_feature.h" | 5 #include "chrome/common/extensions/features/complex_feature.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/features/simple_feature.h" | 7 #include "chrome/common/extensions/features/simple_feature.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 extension_id, type, location, manifest_version, platform); | 31 extension_id, type, location, manifest_version, platform); |
| 32 if (availability.is_available()) | 32 if (availability.is_available()) |
| 33 return availability; | 33 return availability; |
| 34 } | 34 } |
| 35 // If none of the SimpleFeatures are available, we return the availability | 35 // If none of the SimpleFeatures are available, we return the availability |
| 36 // info of the first SimpleFeature that was not available. | 36 // info of the first SimpleFeature that was not available. |
| 37 return first_availability; | 37 return first_availability; |
| 38 } | 38 } |
| 39 | 39 |
| 40 Feature::Availability ComplexFeature::IsAvailableToContext( | 40 Feature::Availability ComplexFeature::IsAvailableToContext( |
| 41 const Extension* extension, Context context, Platform platform) const { | 41 const Extension* extension, |
| 42 Context context, |
| 43 const GURL& url, |
| 44 Platform platform) const { |
| 42 Feature::Availability first_availability = | 45 Feature::Availability first_availability = |
| 43 features_[0]->IsAvailableToContext(extension, context, platform); | 46 features_[0]->IsAvailableToContext(extension, context, url, platform); |
| 44 if (first_availability.is_available()) | 47 if (first_availability.is_available()) |
| 45 return first_availability; | 48 return first_availability; |
| 46 | 49 |
| 47 for (FeatureList::const_iterator it = features_.begin() + 1; | 50 for (FeatureList::const_iterator it = features_.begin() + 1; |
| 48 it != features_.end(); ++it) { | 51 it != features_.end(); ++it) { |
| 49 Availability availability = | 52 Availability availability = |
| 50 (*it)->IsAvailableToContext(extension, context, platform); | 53 (*it)->IsAvailableToContext(extension, context, url, platform); |
| 51 if (availability.is_available()) | 54 if (availability.is_available()) |
| 52 return availability; | 55 return availability; |
| 53 } | 56 } |
| 54 // If none of the SimpleFeatures are available, we return the availability | 57 // If none of the SimpleFeatures are available, we return the availability |
| 55 // info of the first SimpleFeature that was not available. | 58 // info of the first SimpleFeature that was not available. |
| 56 return first_availability; | 59 return first_availability; |
| 57 } | 60 } |
| 58 | 61 |
| 59 std::set<Feature::Context>* ComplexFeature::GetContexts() { | 62 std::set<Feature::Context>* ComplexFeature::GetContexts() { |
| 60 // TODO(justinlin): Current use cases for ComplexFeatures are simple (e.g. | 63 // TODO(justinlin): Current use cases for ComplexFeatures are simple (e.g. |
| 61 // allow API in dev channel for everyone but stable channel for a whitelist), | 64 // allow API in dev channel for everyone but stable channel for a whitelist), |
| 62 // but if they get more complicated, we need to return some meaningful context | 65 // but if they get more complicated, we need to return some meaningful context |
| 63 // set. Either that or remove this method from the Feature interface. | 66 // set. Either that or remove this method from the Feature interface. |
| 64 return features_[0]->GetContexts(); | 67 return features_[0]->GetContexts(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result, | 70 std::string ComplexFeature::GetAvailabilityMessage(AvailabilityResult result, |
| 68 Manifest::Type type) const { | 71 Manifest::Type type) const { |
| 69 if (result == IS_AVAILABLE) | 72 if (result == IS_AVAILABLE) |
| 70 return ""; | 73 return ""; |
| 71 | 74 |
| 72 // TODO(justinlin): Form some kind of combined availabilities/messages from | 75 // TODO(justinlin): Form some kind of combined availabilities/messages from |
| 73 // SimpleFeatures. | 76 // SimpleFeatures. |
| 74 return features_[0]->GetAvailabilityMessage(result, type); | 77 return features_[0]->GetAvailabilityMessage(result, type); |
| 75 } | 78 } |
| 76 | 79 |
| 77 } // namespace extensions | 80 } // namespace extensions |
| OLD | NEW |