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

Unified Diff: extensions/common/extension_api.cc

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 side-by-side diff with in-line comments
Download patch
Index: extensions/common/extension_api.cc
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc
index 8430a2fb117dead341b92dc8d8790f75196aeffc..a8ff7221c609cd8aa08c15d0ead193c343052b89 100644
--- a/extensions/common/extension_api.cc
+++ b/extensions/common/extension_api.cc
@@ -265,14 +265,17 @@ void ExtensionAPI::RegisterDependencyProvider(const std::string& name,
dependency_providers_[name] = provider;
}
-bool ExtensionAPI::IsAnyFeatureAvailableToContext(const Feature& api,
- const Extension* extension,
- Feature::Context context,
- const GURL& url) {
+bool ExtensionAPI::IsAnyFeatureAvailableToContext(
+ const Feature& api,
+ const Extension* extension,
+ Feature::Context context,
+ Feature::SessionType session_type,
+ const GURL& url) {
FeatureProviderMap::iterator provider = dependency_providers_.find("api");
CHECK(provider != dependency_providers_.end());
- if (api.IsAvailableToContext(extension, context, url).is_available())
+ if (api.IsAvailableToContext(extension, context, session_type, url)
+ .is_available())
return true;
// Check to see if there are any parts of this API that are allowed in this
@@ -281,27 +284,33 @@ bool ExtensionAPI::IsAnyFeatureAvailableToContext(const Feature& api,
for (std::vector<Feature*>::const_iterator it = features.begin();
it != features.end();
++it) {
- if ((*it)->IsAvailableToContext(extension, context, url).is_available())
+ if ((*it)
+ ->IsAvailableToContext(extension, context, session_type, url)
+ .is_available())
return true;
}
return false;
}
-Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url) {
+Feature::Availability ExtensionAPI::IsAvailable(
+ const std::string& full_name,
+ const Extension* extension,
+ Feature::Context context,
+ Feature::SessionType session_type,
+ const GURL& url) {
Feature* feature = GetFeatureDependency(full_name);
if (!feature) {
return Feature::Availability(Feature::NOT_PRESENT,
std::string("Unknown feature: ") + full_name);
}
- return feature->IsAvailableToContext(extension, context, url);
+ return feature->IsAvailableToContext(extension, context, session_type, url);
}
bool ExtensionAPI::IsAvailableToWebUI(const std::string& name,
+ Feature::SessionType session_type,
const GURL& url) {
- return IsAvailable(name, NULL, Feature::WEBUI_CONTEXT, url).is_available();
+ return IsAvailable(name, NULL, Feature::WEBUI_CONTEXT, session_type, url)
+ .is_available();
}
const base::DictionaryValue* ExtensionAPI::GetSchema(

Powered by Google App Engine
This is Rietveld 408576698