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

Side by Side Diff: extensions/common/features/feature_provider.h

Issue 1835863002: Added check for behavior feature existense (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make Get*Feature return |nullptr| instead crash if feature is missing Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_ 5 #ifndef EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_
6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_ 6 #define EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 21 matching lines...) Expand all
32 32
33 // Directly access the common FeatureProvider types. 33 // Directly access the common FeatureProvider types.
34 // Each is equivalent to GetByName('featuretype'). 34 // Each is equivalent to GetByName('featuretype').
35 static const FeatureProvider* GetAPIFeatures(); 35 static const FeatureProvider* GetAPIFeatures();
36 static const FeatureProvider* GetManifestFeatures(); 36 static const FeatureProvider* GetManifestFeatures();
37 static const FeatureProvider* GetPermissionFeatures(); 37 static const FeatureProvider* GetPermissionFeatures();
38 static const FeatureProvider* GetBehaviorFeatures(); 38 static const FeatureProvider* GetBehaviorFeatures();
39 39
40 // Directly get Features from the common FeatureProvider types. 40 // Directly get Features from the common FeatureProvider types.
41 // Each is equivalent to GetByName('featuretype')->GetFeature(name). 41 // Each is equivalent to GetByName('featuretype')->GetFeature(name).
42 // NOTE: These functions may return |nullptr| in case corresponding JSON file
43 // got corrupted.
42 static const Feature* GetAPIFeature(const std::string& name); 44 static const Feature* GetAPIFeature(const std::string& name);
43 static const Feature* GetManifestFeature(const std::string& name); 45 static const Feature* GetManifestFeature(const std::string& name);
44 static const Feature* GetPermissionFeature(const std::string& name); 46 static const Feature* GetPermissionFeature(const std::string& name);
45 static const Feature* GetBehaviorFeature(const std::string& name); 47 static const Feature* GetBehaviorFeature(const std::string& name);
46 48
47 // 49 //
48 // Instance methods. 50 // Instance methods.
49 // 51 //
50 52
51 // Returns the feature with the specified name. 53 // Returns the feature with the specified name.
52 virtual Feature* GetFeature(const std::string& name) const = 0; 54 virtual Feature* GetFeature(const std::string& name) const = 0;
53 55
54 // Returns the parent feature of |feature|, or NULL if there isn't one. 56 // Returns the parent feature of |feature|, or NULL if there isn't one.
55 virtual Feature* GetParent(Feature* feature) const = 0; 57 virtual Feature* GetParent(Feature* feature) const = 0;
56 58
57 // Returns the features inside the |parent| namespace, recursively. 59 // Returns the features inside the |parent| namespace, recursively.
58 virtual std::vector<Feature*> GetChildren(const Feature& parent) const = 0; 60 virtual std::vector<Feature*> GetChildren(const Feature& parent) const = 0;
59 61
60 // Returns a map containing all features described by this instance. 62 // Returns a map containing all features described by this instance.
61 virtual const FeatureMap& GetAllFeatures() const = 0; 63 virtual const FeatureMap& GetAllFeatures() const = 0;
62 }; 64 };
63 65
64 } // namespace extensions 66 } // namespace extensions
65 67
66 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_ 68 #endif // EXTENSIONS_COMMON_FEATURES_FEATURE_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698