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

Unified Diff: extensions/common/features/simple_feature.cc

Issue 2601803003: Introduce kiosk.autolaunched feature session type (Closed)
Patch Set: . Created 3 years, 11 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
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | extensions/common/features/simple_feature_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/simple_feature.cc
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc
index b30ba4f8e4d7f6953fcee849cf54131fba3d545a..d901cd9a70cb765eb6e0abd76ff46fab218bc7c5 100644
--- a/extensions/common/features/simple_feature.cc
+++ b/extensions/common/features/simple_feature.cc
@@ -134,6 +134,8 @@ std::string GetDisplayName(FeatureSessionType session_type) {
return "unknown";
case FeatureSessionType::KIOSK:
return "kiosk app";
+ case FeatureSessionType::AUTOLAUNCHED_KIOSK:
+ return "auto-launched kiosk app";
case FeatureSessionType::REGULAR:
return "regular user";
}
@@ -259,11 +261,9 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
if (channel_ && *channel_ < GetCurrentChannel())
return CreateAvailability(UNSUPPORTED_CHANNEL, *channel_);
- FeatureSessionType session = GetCurrentFeatureSessionType();
- if (!session_types_.empty() &&
- !base::ContainsValue(session_types_, session)) {
- return CreateAvailability(INVALID_SESSION_TYPE, session);
- }
+ const FeatureSessionType session_type = GetCurrentFeatureSessionType();
+ if (!MatchesSessionTypes(session_type))
+ return CreateAvailability(INVALID_SESSION_TYPE, session_type);
return CheckDependencies(base::Bind(&IsAvailableToManifestForBind,
extension_id,
@@ -303,10 +303,9 @@ Feature::Availability SimpleFeature::IsAvailableToContext(
return CreateAvailability(INVALID_URL, url);
}
- FeatureSessionType session = GetCurrentFeatureSessionType();
- if (!session_types_.empty() &&
- !base::ContainsValue(session_types_, session)) {
- return CreateAvailability(INVALID_SESSION_TYPE, session);
+ const FeatureSessionType session_type = GetCurrentFeatureSessionType();
+ if (!MatchesSessionTypes(session_type)) {
+ return CreateAvailability(INVALID_SESSION_TYPE, session_type);
}
// TODO(kalman): Assert that if the context was a webpage or WebUI context
@@ -497,6 +496,20 @@ bool SimpleFeature::MatchesManifestLocation(
return false;
}
+bool SimpleFeature::MatchesSessionTypes(FeatureSessionType session_type) const {
+ if (session_types_.empty())
+ return true;
+
+ if (base::ContainsValue(session_types_, session_type))
+ return true;
+
+ // AUTOLAUNCHED_KIOSK session type is subset of KIOSK - accept auto-lauched
+ // kiosk session if kiosk session is allowed. This is the only exception to
+ // rejecting session type that is not present in |session_types_|
+ return session_type == FeatureSessionType::AUTOLAUNCHED_KIOSK &&
+ base::ContainsValue(session_types_, FeatureSessionType::KIOSK);
+}
+
Feature::Availability SimpleFeature::CheckDependencies(
const base::Callback<Availability(const Feature*)>& checker) const {
for (const auto& dep_name : dependencies_) {
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | extensions/common/features/simple_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698