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

Side by Side Diff: extensions/common/extension_api.h

Issue 2241203003: Pass user session type to extension feature checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out some stuff Created 4 years, 4 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_EXTENSION_API_H_ 5 #ifndef EXTENSIONS_COMMON_EXTENSION_API_H_
6 #define EXTENSIONS_COMMON_EXTENSION_API_H_ 6 #define EXTENSIONS_COMMON_EXTENSION_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // Depending on the configuration of |api| (in _api_features.json), either 88 // Depending on the configuration of |api| (in _api_features.json), either
89 // |extension| or |url| (or both) may determine its availability, but this is 89 // |extension| or |url| (or both) may determine its availability, but this is
90 // up to the configuration of the individual feature. 90 // up to the configuration of the individual feature.
91 // 91 //
92 // TODO(kalman): This is just an unnecessary combination of finding a Feature 92 // TODO(kalman): This is just an unnecessary combination of finding a Feature
93 // then calling Feature::IsAvailableToContext(..) on it. Just provide that 93 // then calling Feature::IsAvailableToContext(..) on it. Just provide that
94 // FindFeature function and let callers compose if they want. 94 // FindFeature function and let callers compose if they want.
95 Feature::Availability IsAvailable(const std::string& api_full_name, 95 Feature::Availability IsAvailable(const std::string& api_full_name,
96 const Extension* extension, 96 const Extension* extension,
97 Feature::Context context, 97 Feature::Context context,
98 Feature::SessionType session_type,
Devlin 2016/08/17 17:07:35 The session type can't really change, right? Why
tbarzic 2016/08/17 19:49:01 It can change from UNSPECIFIED when a user logs in
98 const GURL& url); 99 const GURL& url);
99 100
100 // Determines whether an API, or any parts of that API, are available in 101 // Determines whether an API, or any parts of that API, are available in
101 // |context|. 102 // |context|.
102 bool IsAnyFeatureAvailableToContext(const Feature& api, 103 bool IsAnyFeatureAvailableToContext(const Feature& api,
103 const Extension* extension, 104 const Extension* extension,
104 Feature::Context context, 105 Feature::Context context,
106 Feature::SessionType session_type,
105 const GURL& url); 107 const GURL& url);
106 108
107 // Returns true if |name| is available to WebUI contexts on |url|. 109 // Returns true if |name| is available to WebUI contexts on |url|.
108 bool IsAvailableToWebUI(const std::string& name, const GURL& url); 110 bool IsAvailableToWebUI(const std::string& name,
111 Feature::SessionType session_type,
112 const GURL& url);
109 113
110 // Gets the schema for the extension API with namespace |full_name|. 114 // Gets the schema for the extension API with namespace |full_name|.
111 // Ownership remains with this object. 115 // Ownership remains with this object.
112 const base::DictionaryValue* GetSchema(const std::string& full_name); 116 const base::DictionaryValue* GetSchema(const std::string& full_name);
113 117
114 // Splits a full name from the extension API into its API and child name 118 // Splits a full name from the extension API into its API and child name
115 // parts. Some examples: 119 // parts. Some examples:
116 // 120 //
117 // "bookmarks.create" -> ("bookmarks", "create") 121 // "bookmarks.create" -> ("bookmarks", "create")
118 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp") 122 // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp")
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // FeatureProviders used for resolving dependencies. 156 // FeatureProviders used for resolving dependencies.
153 typedef std::map<std::string, const FeatureProvider*> FeatureProviderMap; 157 typedef std::map<std::string, const FeatureProvider*> FeatureProviderMap;
154 FeatureProviderMap dependency_providers_; 158 FeatureProviderMap dependency_providers_;
155 159
156 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI); 160 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI);
157 }; 161 };
158 162
159 } // namespace extensions 163 } // namespace extensions
160 164
161 #endif // EXTENSIONS_COMMON_EXTENSION_API_H_ 165 #endif // EXTENSIONS_COMMON_EXTENSION_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698