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

Side by Side Diff: chrome/common/extensions/features/simple_feature.h

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
OLDNEW
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 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_
6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/chrome_version_info.h" 12 #include "chrome/common/chrome_version_info.h"
13 #include "chrome/common/extensions/extension.h" 13 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/features/feature.h" 14 #include "chrome/common/extensions/features/feature.h"
15 #include "chrome/common/extensions/manifest.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 class ComplexFeature; 19 class ComplexFeature;
19 20
20 class SimpleFeature : public Feature { 21 class SimpleFeature : public Feature {
21 public: 22 public:
22 SimpleFeature(); 23 SimpleFeature();
23 SimpleFeature(const SimpleFeature& other); 24 SimpleFeature(const SimpleFeature& other);
24 virtual ~SimpleFeature(); 25 virtual ~SimpleFeature();
25 26
26 std::set<std::string>* whitelist() { return &whitelist_; } 27 std::set<std::string>* whitelist() { return &whitelist_; }
27 std::set<Extension::Type>* extension_types() { return &extension_types_; } 28 std::set<Manifest::Type>* extension_types() { return &extension_types_; }
28 29
29 // Parses the JSON representation of a feature into the fields of this object. 30 // Parses the JSON representation of a feature into the fields of this object.
30 // Unspecified values in the JSON are not modified in the object. This allows 31 // Unspecified values in the JSON are not modified in the object. This allows
31 // us to implement inheritance by parsing one value after another. 32 // us to implement inheritance by parsing one value after another.
32 void Parse(const DictionaryValue* value); 33 void Parse(const DictionaryValue* value);
33 34
34 // Returns true if the feature contains the same values as another. 35 // Returns true if the feature contains the same values as another.
35 bool Equals(const SimpleFeature& other) const; 36 bool Equals(const SimpleFeature& other) const;
36 37
37 Location location() const { return location_; } 38 Location location() const { return location_; }
(...skipping 12 matching lines...) Expand all
50 max_manifest_version_ = max_manifest_version; 51 max_manifest_version_ = max_manifest_version;
51 } 52 }
52 53
53 Availability IsAvailableToContext(const Extension* extension, 54 Availability IsAvailableToContext(const Extension* extension,
54 Context context) const { 55 Context context) const {
55 return IsAvailableToContext(extension, context, GetCurrentPlatform()); 56 return IsAvailableToContext(extension, context, GetCurrentPlatform());
56 } 57 }
57 58
58 // extension::Feature: 59 // extension::Feature:
59 virtual Availability IsAvailableToManifest(const std::string& extension_id, 60 virtual Availability IsAvailableToManifest(const std::string& extension_id,
60 Extension::Type type, 61 Manifest::Type type,
61 Location location, 62 Location location,
62 int manifest_version, 63 int manifest_version,
63 Platform platform) const OVERRIDE; 64 Platform platform) const OVERRIDE;
64 65
65 virtual Availability IsAvailableToContext(const Extension* extension, 66 virtual Availability IsAvailableToContext(const Extension* extension,
66 Context context, 67 Context context,
67 Platform platform) const OVERRIDE; 68 Platform platform) const OVERRIDE;
68 69
69 virtual std::string GetAvailabilityMessage( 70 virtual std::string GetAvailabilityMessage(
70 AvailabilityResult result, Extension::Type type) const OVERRIDE; 71 AvailabilityResult result, Manifest::Type type) const OVERRIDE;
71 72
72 virtual std::set<Context>* GetContexts() OVERRIDE; 73 virtual std::set<Context>* GetContexts() OVERRIDE;
73 74
74 protected: 75 protected:
75 Availability CreateAvailability(AvailabilityResult result) const; 76 Availability CreateAvailability(AvailabilityResult result) const;
76 Availability CreateAvailability(AvailabilityResult result, 77 Availability CreateAvailability(AvailabilityResult result,
77 Extension::Type type) const; 78 Manifest::Type type) const;
78 79
79 private: 80 private:
80 // For clarity and consistency, we handle the default value of each of these 81 // For clarity and consistency, we handle the default value of each of these
81 // members the same way: it matches everything. It is up to the higher level 82 // members the same way: it matches everything. It is up to the higher level
82 // code that reads Features out of static data to validate that data and set 83 // code that reads Features out of static data to validate that data and set
83 // sensible defaults. 84 // sensible defaults.
84 std::set<std::string> whitelist_; 85 std::set<std::string> whitelist_;
85 std::set<Extension::Type> extension_types_; 86 std::set<Manifest::Type> extension_types_;
86 std::set<Context> contexts_; 87 std::set<Context> contexts_;
87 Location location_; // we only care about component/not-component now 88 Location location_; // we only care about component/not-component now
88 Platform platform_; // we only care about chromeos/not-chromeos now 89 Platform platform_; // we only care about chromeos/not-chromeos now
89 int min_manifest_version_; 90 int min_manifest_version_;
90 int max_manifest_version_; 91 int max_manifest_version_;
91 chrome::VersionInfo::Channel channel_; 92 chrome::VersionInfo::Channel channel_;
92 93
93 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context); 94 FRIEND_TEST_ALL_PREFIXES(ExtensionSimpleFeatureTest, Context);
94 }; 95 };
95 96
96 } // namespace extensions 97 } // namespace extensions
97 98
98 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_ 99 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_SIMPLE_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698