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

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

Issue 2601803003: Introduce kiosk.autolaunched feature session type (Closed)
Patch Set: . Created 4 years 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/features/simple_feature.cc
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc
index b30ba4f8e4d7f6953fcee849cf54131fba3d545a..44fcb4b43563c854e99e87505520277bddb30b56 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);
- }
+ 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);
+ 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,21 @@ 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)) {
+ // AUTOLAUNCHED_KIOSK session type is subset of KIOSK - accept auto-lauched
+ // kiosk session if kiosk session is allowed. This is only exception to
+ // rejecting session type that is not present in |session_types_|
+ return session_type == FeatureSessionType::AUTOLAUNCHED_KIOSK &&
Devlin 2016/12/29 17:15:37 I kind of wonder if this is better done at compile
tbarzic 2016/12/29 20:29:58 Yeah, that would work,too. I find this approach sl
+ base::ContainsValue(session_types_, FeatureSessionType::KIOSK);
+ }
+
+ return true;
+}
+
Feature::Availability SimpleFeature::CheckDependencies(
const base::Callback<Availability(const Feature*)>& checker) const {
for (const auto& dep_name : dependencies_) {

Powered by Google App Engine
This is Rietveld 408576698