| 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 #include "extensions/common/features/simple_feature.h" | 5 #include "extensions/common/features/simple_feature.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 extension_types["shared_module"] = Manifest::TYPE_SHARED_MODULE; | 52 extension_types["shared_module"] = Manifest::TYPE_SHARED_MODULE; |
| 53 | 53 |
| 54 contexts["blessed_extension"] = Feature::BLESSED_EXTENSION_CONTEXT; | 54 contexts["blessed_extension"] = Feature::BLESSED_EXTENSION_CONTEXT; |
| 55 contexts["unblessed_extension"] = Feature::UNBLESSED_EXTENSION_CONTEXT; | 55 contexts["unblessed_extension"] = Feature::UNBLESSED_EXTENSION_CONTEXT; |
| 56 contexts["content_script"] = Feature::CONTENT_SCRIPT_CONTEXT; | 56 contexts["content_script"] = Feature::CONTENT_SCRIPT_CONTEXT; |
| 57 contexts["web_page"] = Feature::WEB_PAGE_CONTEXT; | 57 contexts["web_page"] = Feature::WEB_PAGE_CONTEXT; |
| 58 contexts["blessed_web_page"] = Feature::BLESSED_WEB_PAGE_CONTEXT; | 58 contexts["blessed_web_page"] = Feature::BLESSED_WEB_PAGE_CONTEXT; |
| 59 contexts["webui"] = Feature::WEBUI_CONTEXT; | 59 contexts["webui"] = Feature::WEBUI_CONTEXT; |
| 60 | 60 |
| 61 locations["component"] = SimpleFeature::COMPONENT_LOCATION; | 61 locations["component"] = SimpleFeature::COMPONENT_LOCATION; |
| 62 locations["external_component"] = |
| 63 SimpleFeature::EXTERNAL_COMPONENT_LOCATION; |
| 62 locations["policy"] = SimpleFeature::POLICY_LOCATION; | 64 locations["policy"] = SimpleFeature::POLICY_LOCATION; |
| 63 | 65 |
| 64 platforms["chromeos"] = Feature::CHROMEOS_PLATFORM; | 66 platforms["chromeos"] = Feature::CHROMEOS_PLATFORM; |
| 65 platforms["linux"] = Feature::LINUX_PLATFORM; | 67 platforms["linux"] = Feature::LINUX_PLATFORM; |
| 66 platforms["mac"] = Feature::MACOSX_PLATFORM; | 68 platforms["mac"] = Feature::MACOSX_PLATFORM; |
| 67 platforms["win"] = Feature::WIN_PLATFORM; | 69 platforms["win"] = Feature::WIN_PLATFORM; |
| 68 } | 70 } |
| 69 | 71 |
| 70 std::map<std::string, Manifest::Type> extension_types; | 72 std::map<std::string, Manifest::Type> extension_types; |
| 71 std::map<std::string, Feature::Context> contexts; | 73 std::map<std::string, Feature::Context> contexts; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 565 |
| 564 return false; | 566 return false; |
| 565 } | 567 } |
| 566 | 568 |
| 567 bool SimpleFeature::MatchesManifestLocation( | 569 bool SimpleFeature::MatchesManifestLocation( |
| 568 Manifest::Location manifest_location) const { | 570 Manifest::Location manifest_location) const { |
| 569 switch (location_) { | 571 switch (location_) { |
| 570 case SimpleFeature::UNSPECIFIED_LOCATION: | 572 case SimpleFeature::UNSPECIFIED_LOCATION: |
| 571 return true; | 573 return true; |
| 572 case SimpleFeature::COMPONENT_LOCATION: | 574 case SimpleFeature::COMPONENT_LOCATION: |
| 573 // TODO(kalman/asargent): Should this include EXTERNAL_COMPONENT too? | |
| 574 return manifest_location == Manifest::COMPONENT; | 575 return manifest_location == Manifest::COMPONENT; |
| 576 case SimpleFeature::EXTERNAL_COMPONENT_LOCATION: |
| 577 return manifest_location == Manifest::EXTERNAL_COMPONENT; |
| 575 case SimpleFeature::POLICY_LOCATION: | 578 case SimpleFeature::POLICY_LOCATION: |
| 576 return manifest_location == Manifest::EXTERNAL_POLICY || | 579 return manifest_location == Manifest::EXTERNAL_POLICY || |
| 577 manifest_location == Manifest::EXTERNAL_POLICY_DOWNLOAD; | 580 manifest_location == Manifest::EXTERNAL_POLICY_DOWNLOAD; |
| 578 } | 581 } |
| 579 NOTREACHED(); | 582 NOTREACHED(); |
| 580 return false; | 583 return false; |
| 581 } | 584 } |
| 582 | 585 |
| 583 Feature::Availability SimpleFeature::CheckDependencies( | 586 Feature::Availability SimpleFeature::CheckDependencies( |
| 584 const base::Callback<Availability(const Feature*)>& checker) const { | 587 const base::Callback<Availability(const Feature*)>& checker) const { |
| 585 for (std::set<std::string>::const_iterator it = dependencies_.begin(); | 588 for (std::set<std::string>::const_iterator it = dependencies_.begin(); |
| 586 it != dependencies_.end(); | 589 it != dependencies_.end(); |
| 587 ++it) { | 590 ++it) { |
| 588 Feature* dependency = | 591 Feature* dependency = |
| 589 ExtensionAPI::GetSharedInstance()->GetFeatureDependency(*it); | 592 ExtensionAPI::GetSharedInstance()->GetFeatureDependency(*it); |
| 590 if (!dependency) | 593 if (!dependency) |
| 591 return CreateAvailability(NOT_PRESENT); | 594 return CreateAvailability(NOT_PRESENT); |
| 592 Availability dependency_availability = checker.Run(dependency); | 595 Availability dependency_availability = checker.Run(dependency); |
| 593 if (!dependency_availability.is_available()) | 596 if (!dependency_availability.is_available()) |
| 594 return dependency_availability; | 597 return dependency_availability; |
| 595 } | 598 } |
| 596 return CreateAvailability(IS_AVAILABLE); | 599 return CreateAvailability(IS_AVAILABLE); |
| 597 } | 600 } |
| 598 | 601 |
| 599 } // namespace extensions | 602 } // namespace extensions |
| OLD | NEW |