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

Unified Diff: chrome/browser/chromeos/extensions/info_private_api.cc

Issue 2314313002: Add sessionType and playStoreStatus to chromeosInfoPrivate. (Closed)
Patch Set: Created 4 years, 3 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: chrome/browser/chromeos/extensions/info_private_api.cc
diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc
index 36350e709e3bdc43a2766d89766793032f56ec6f..7f701dfa44c100e73d3d39d7023b42f695859bd5 100644
--- a/chrome/browser/chromeos/extensions/info_private_api.cc
+++ b/chrome/browser/chromeos/extensions/info_private_api.cc
@@ -8,10 +8,12 @@
#include <utility>
+#include "base/command_line.h"
#include "base/sys_info.h"
#include "base/values.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/arc/arc_auth_service.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
@@ -23,9 +25,11 @@
#include "chromeos/network/network_state_handler.h"
#include "chromeos/settings/cros_settings_names.h"
#include "chromeos/system/statistics_provider.h"
+#include "components/arc/arc_bridge_service.h"
#include "components/metrics/metrics_service.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
+#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/error_utils.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -104,6 +108,34 @@ const char kPropertySendFunctionsKeys[] = "sendFunctionKeys";
// Property not found error message.
const char kPropertyNotFound[] = "Property '*' does not exist.";
+// Key which corresponds to the sessionType property in JS.
+const char kPropertySessionType[] = "sessionType";
+
+// Key which corresponds to the "kiosk" value of the SessionType enum in JS.
+const char kSessionTypeKiosk[] = "kiosk";
+
+// Key which corresponds to the "public session" value of the SessionType enum
+// in JS.
+const char kSessionTypePublicSession[] = "public session";
Devlin 2016/09/06 23:04:53 Why not use the generated conversion functions?
Rahul Chaturvedi 2016/09/06 23:19:35 Which generated conversion functions?
Devlin 2016/09/07 16:12:28 We generate conversions from enums to strings, e.g
Rahul Chaturvedi 2016/09/07 20:13:23 I understand that - but where do I find the conver
Devlin 2016/09/07 20:23:27 /sigh...it looks like we aren't compiling this API
+
+// Key which corresponds to the "normal" value of the SessionType enum in JS.
+const char kSessionTypeNormal[] = "normal";
+
+// Key which corresponds to the playStoreStatus property in JS.
+const char kPropertyPlayStoreStatus[] = "playStoreStatus";
+
+// Key which corresponds to the "not available" value of the PlayStoreStatus
+// enum in JS.
+const char kPlayStoreStatusNotAvailable[] = "not available";
+
+// Key which corresponds to the "available" value of the PlayStoreStatus enum in
+// JS.
+const char kPlayStoreStatusAvailable[] = "available";
+
+// Key which corresponds to the "enabled" value of the PlayStoreStatus enum in
+// JS.
+const char kPlayStoreStatusEnabled[] = "enabled";
+
const struct {
const char* api_name;
const char* preference_name;
@@ -209,6 +241,24 @@ base::Value* ChromeosInfoPrivateGetFunction::GetValue(
} else if (property_name == kPropertyOwner) {
return new base::FundamentalValue(
user_manager::UserManager::Get()->IsCurrentUserOwner());
+ } else if (property_name == kPropertySessionType) {
+ if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) {
+ return new base::StringValue(kSessionTypeKiosk);
+ } else if (ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount()) {
Devlin 2016/09/06 23:04:53 no else after return. Ideally, that'd go for this
Rahul Chaturvedi 2016/09/06 23:19:35 I was trying to stick to the style in the file. If
+ return new base::StringValue(kSessionTypePublicSession);
+ } else {
+ return new base::StringValue(kSessionTypeNormal);
+ }
+ } else if (property_name == kPropertyPlayStoreStatus) {
+ if (arc::ArcAuthService::IsAllowedForProfile(
+ Profile::FromBrowserContext(context_))) {
+ return new base::StringValue(kPlayStoreStatusEnabled);
+ } else if (arc::ArcBridgeService::GetAvailable(
+ base::CommandLine::ForCurrentProcess())) {
+ return new base::StringValue(kPlayStoreStatusAvailable);
+ } else {
+ return new base::StringValue(kPlayStoreStatusNotAvailable);
+ }
} else if (property_name == kPropertyClientId) {
return new base::StringValue(GetClientId());
} else if (property_name == kPropertyTimezone) {

Powered by Google App Engine
This is Rietveld 408576698