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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/extensions/info_private_api.h" 5 #include "chrome/browser/chromeos/extensions/info_private_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h"
11 #include "base/sys_info.h" 12 #include "base/sys_info.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/app_mode/app_mode_utils.h" 14 #include "chrome/browser/app_mode/app_mode_utils.h"
14 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
15 #include "chrome/browser/chromeos/login/startup_utils.h" 17 #include "chrome/browser/chromeos/login/startup_utils.h"
16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 18 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
17 #include "chrome/browser/chromeos/settings/cros_settings.h" 19 #include "chrome/browser/chromeos/settings/cros_settings.h"
18 #include "chrome/browser/chromeos/system/timezone_util.h" 20 #include "chrome/browser/chromeos/system/timezone_util.h"
19 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
21 #include "chromeos/network/device_state.h" 23 #include "chromeos/network/device_state.h"
22 #include "chromeos/network/network_handler.h" 24 #include "chromeos/network/network_handler.h"
23 #include "chromeos/network/network_state_handler.h" 25 #include "chromeos/network/network_state_handler.h"
24 #include "chromeos/settings/cros_settings_names.h" 26 #include "chromeos/settings/cros_settings_names.h"
25 #include "chromeos/system/statistics_provider.h" 27 #include "chromeos/system/statistics_provider.h"
28 #include "components/arc/arc_bridge_service.h"
26 #include "components/metrics/metrics_service.h" 29 #include "components/metrics/metrics_service.h"
27 #include "components/prefs/pref_service.h" 30 #include "components/prefs/pref_service.h"
28 #include "components/user_manager/user_manager.h" 31 #include "components/user_manager/user_manager.h"
32 #include "extensions/browser/extensions_browser_client.h"
29 #include "extensions/common/error_utils.h" 33 #include "extensions/common/error_utils.h"
30 #include "third_party/cros_system_api/dbus/service_constants.h" 34 #include "third_party/cros_system_api/dbus/service_constants.h"
31 35
32 using chromeos::NetworkHandler; 36 using chromeos::NetworkHandler;
33 37
34 namespace extensions { 38 namespace extensions {
35 39
36 namespace { 40 namespace {
37 41
38 // Key which corresponds to the HWID setting. 42 // Key which corresponds to the HWID setting.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 101
98 // Key which corresponds to the switch access A11Y property in JS. 102 // Key which corresponds to the switch access A11Y property in JS.
99 const char kPropertySwitchAccessEnabled[] = "a11ySwitchAccessEnabled"; 103 const char kPropertySwitchAccessEnabled[] = "a11ySwitchAccessEnabled";
100 104
101 // Key which corresponds to the send-function-keys property in JS. 105 // Key which corresponds to the send-function-keys property in JS.
102 const char kPropertySendFunctionsKeys[] = "sendFunctionKeys"; 106 const char kPropertySendFunctionsKeys[] = "sendFunctionKeys";
103 107
104 // Property not found error message. 108 // Property not found error message.
105 const char kPropertyNotFound[] = "Property '*' does not exist."; 109 const char kPropertyNotFound[] = "Property '*' does not exist.";
106 110
111 // Key which corresponds to the sessionType property in JS.
112 const char kPropertySessionType[] = "sessionType";
113
114 // Key which corresponds to the "kiosk" value of the SessionType enum in JS.
115 const char kSessionTypeKiosk[] = "kiosk";
116
117 // Key which corresponds to the "public session" value of the SessionType enum
118 // in JS.
119 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
120
121 // Key which corresponds to the "normal" value of the SessionType enum in JS.
122 const char kSessionTypeNormal[] = "normal";
123
124 // Key which corresponds to the playStoreStatus property in JS.
125 const char kPropertyPlayStoreStatus[] = "playStoreStatus";
126
127 // Key which corresponds to the "not available" value of the PlayStoreStatus
128 // enum in JS.
129 const char kPlayStoreStatusNotAvailable[] = "not available";
130
131 // Key which corresponds to the "available" value of the PlayStoreStatus enum in
132 // JS.
133 const char kPlayStoreStatusAvailable[] = "available";
134
135 // Key which corresponds to the "enabled" value of the PlayStoreStatus enum in
136 // JS.
137 const char kPlayStoreStatusEnabled[] = "enabled";
138
107 const struct { 139 const struct {
108 const char* api_name; 140 const char* api_name;
109 const char* preference_name; 141 const char* preference_name;
110 } kPreferencesMap[] = { 142 } kPreferencesMap[] = {
111 {kPropertyLargeCursorEnabled, prefs::kAccessibilityLargeCursorEnabled}, 143 {kPropertyLargeCursorEnabled, prefs::kAccessibilityLargeCursorEnabled},
112 {kPropertyStickyKeysEnabled, prefs::kAccessibilityStickyKeysEnabled}, 144 {kPropertyStickyKeysEnabled, prefs::kAccessibilityStickyKeysEnabled},
113 {kPropertySpokenFeedbackEnabled, 145 {kPropertySpokenFeedbackEnabled,
114 prefs::kAccessibilitySpokenFeedbackEnabled}, 146 prefs::kAccessibilitySpokenFeedbackEnabled},
115 {kPropertyHighContrastEnabled, prefs::kAccessibilityHighContrastEnabled}, 147 {kPropertyHighContrastEnabled, prefs::kAccessibilityHighContrastEnabled},
116 {kPropertyScreenMagnifierEnabled, 148 {kPropertyScreenMagnifierEnabled,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 home_provider_id = cellular_device->home_provider_id(); 234 home_provider_id = cellular_device->home_provider_id();
203 return new base::StringValue(home_provider_id); 235 return new base::StringValue(home_provider_id);
204 } else if (property_name == kPropertyInitialLocale) { 236 } else if (property_name == kPropertyInitialLocale) {
205 return new base::StringValue( 237 return new base::StringValue(
206 chromeos::StartupUtils::GetInitialLocale()); 238 chromeos::StartupUtils::GetInitialLocale());
207 } else if (property_name == kPropertyBoard) { 239 } else if (property_name == kPropertyBoard) {
208 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard()); 240 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard());
209 } else if (property_name == kPropertyOwner) { 241 } else if (property_name == kPropertyOwner) {
210 return new base::FundamentalValue( 242 return new base::FundamentalValue(
211 user_manager::UserManager::Get()->IsCurrentUserOwner()); 243 user_manager::UserManager::Get()->IsCurrentUserOwner());
244 } else if (property_name == kPropertySessionType) {
245 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) {
246 return new base::StringValue(kSessionTypeKiosk);
247 } 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
248 return new base::StringValue(kSessionTypePublicSession);
249 } else {
250 return new base::StringValue(kSessionTypeNormal);
251 }
252 } else if (property_name == kPropertyPlayStoreStatus) {
253 if (arc::ArcAuthService::IsAllowedForProfile(
254 Profile::FromBrowserContext(context_))) {
255 return new base::StringValue(kPlayStoreStatusEnabled);
256 } else if (arc::ArcBridgeService::GetAvailable(
257 base::CommandLine::ForCurrentProcess())) {
258 return new base::StringValue(kPlayStoreStatusAvailable);
259 } else {
260 return new base::StringValue(kPlayStoreStatusNotAvailable);
261 }
212 } else if (property_name == kPropertyClientId) { 262 } else if (property_name == kPropertyClientId) {
213 return new base::StringValue(GetClientId()); 263 return new base::StringValue(GetClientId());
214 } else if (property_name == kPropertyTimezone) { 264 } else if (property_name == kPropertyTimezone) {
215 return chromeos::CrosSettings::Get()->GetPref( 265 return chromeos::CrosSettings::Get()->GetPref(
216 chromeos::kSystemTimezone)->DeepCopy(); 266 chromeos::kSystemTimezone)->DeepCopy();
217 } else if (property_name == kPropertySupportedTimezones) { 267 } else if (property_name == kPropertySupportedTimezones) {
218 std::unique_ptr<base::ListValue> values = 268 std::unique_ptr<base::ListValue> values =
219 chromeos::system::GetTimezoneList(); 269 chromeos::system::GetTimezoneList();
220 return values.release(); 270 return values.release();
221 } else { 271 } else {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 param_value); 306 param_value);
257 } else { 307 } else {
258 return RespondNow(Error(kPropertyNotFound, param_name)); 308 return RespondNow(Error(kPropertyNotFound, param_name));
259 } 309 }
260 } 310 }
261 311
262 return RespondNow(NoArguments()); 312 return RespondNow(NoArguments());
263 } 313 }
264 314
265 } // namespace extensions 315 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698