OLD | NEW |
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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 12 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chromeos/login/startup_utils.h" | 13 #include "chrome/browser/chromeos/login/startup_utils.h" |
12 #include "chrome/browser/chromeos/login/users/user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 15 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
13 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
14 #include "chrome/browser/chromeos/system/timezone_util.h" | 17 #include "chrome/browser/chromeos/system/timezone_util.h" |
| 18 #include "chrome/browser/metrics/metrics_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
17 #include "chromeos/network/device_state.h" | 21 #include "chromeos/network/device_state.h" |
18 #include "chromeos/network/network_handler.h" | 22 #include "chromeos/network/network_handler.h" |
19 #include "chromeos/network/network_state_handler.h" | 23 #include "chromeos/network/network_state_handler.h" |
20 #include "chromeos/settings/cros_settings_names.h" | 24 #include "chromeos/settings/cros_settings_names.h" |
21 #include "chromeos/system/statistics_provider.h" | 25 #include "chromeos/system/statistics_provider.h" |
22 #include "extensions/common/error_utils.h" | 26 #include "extensions/common/error_utils.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 27 #include "third_party/cros_system_api/dbus/service_constants.h" |
24 | 28 |
(...skipping 11 matching lines...) Expand all Loading... |
36 | 40 |
37 // Key which corresponds to the home provider property. | 41 // Key which corresponds to the home provider property. |
38 const char kPropertyHomeProvider[] = "homeProvider"; | 42 const char kPropertyHomeProvider[] = "homeProvider"; |
39 | 43 |
40 // Key which corresponds to the initial_locale property. | 44 // Key which corresponds to the initial_locale property. |
41 const char kPropertyInitialLocale[] = "initialLocale"; | 45 const char kPropertyInitialLocale[] = "initialLocale"; |
42 | 46 |
43 // Key which corresponds to the board property in JS. | 47 // Key which corresponds to the board property in JS. |
44 const char kPropertyBoard[] = "board"; | 48 const char kPropertyBoard[] = "board"; |
45 | 49 |
46 // Key which corresponds to the board property in JS. | 50 // Key which corresponds to the isOwner property in JS. |
47 const char kPropertyOwner[] = "isOwner"; | 51 const char kPropertyOwner[] = "isOwner"; |
48 | 52 |
| 53 // Key which corresponds to the clientId property in JS. |
| 54 const char kPropertyClientId[] = "clientId"; |
| 55 |
49 // Key which corresponds to the timezone property in JS. | 56 // Key which corresponds to the timezone property in JS. |
50 const char kPropertyTimezone[] = "timezone"; | 57 const char kPropertyTimezone[] = "timezone"; |
51 | 58 |
52 // Key which corresponds to the timezone property in JS. | 59 // Key which corresponds to the timezone property in JS. |
53 const char kPropertySupportedTimezones[] = "supportedTimezones"; | 60 const char kPropertySupportedTimezones[] = "supportedTimezones"; |
54 | 61 |
55 // Key which corresponds to the large cursor A11Y property in JS. | 62 // Key which corresponds to the large cursor A11Y property in JS. |
56 const char kPropertyLargeCursorEnabled[] = "a11yLargeCursorEnabled"; | 63 const char kPropertyLargeCursorEnabled[] = "a11yLargeCursorEnabled"; |
57 | 64 |
58 // Key which corresponds to the sticky keys A11Y property in JS. | 65 // Key which corresponds to the sticky keys A11Y property in JS. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 for (size_t i = 0; | 103 for (size_t i = 0; |
97 i < (sizeof(kPreferencesMap)/sizeof(*kPreferencesMap)); | 104 i < (sizeof(kPreferencesMap)/sizeof(*kPreferencesMap)); |
98 i++) { | 105 i++) { |
99 if (strcmp(kPreferencesMap[i].api_name, api_name) == 0) | 106 if (strcmp(kPreferencesMap[i].api_name, api_name) == 0) |
100 return kPreferencesMap[i].preference_name; | 107 return kPreferencesMap[i].preference_name; |
101 } | 108 } |
102 | 109 |
103 return NULL; | 110 return NULL; |
104 } | 111 } |
105 | 112 |
| 113 bool IsEnterpriseKiosk() { |
| 114 if (!chrome::IsRunningInForcedAppMode()) |
| 115 return false; |
| 116 |
| 117 policy::BrowserPolicyConnectorChromeOS* connector = |
| 118 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 119 return connector->IsEnterpriseManaged(); |
| 120 } |
| 121 |
| 122 std::string GetClientId() { |
| 123 return IsEnterpriseKiosk() |
| 124 ? g_browser_process->metrics_service()->GetClientId() |
| 125 : std::string(); |
| 126 } |
| 127 |
106 } // namespace | 128 } // namespace |
107 | 129 |
108 ChromeosInfoPrivateGetFunction::ChromeosInfoPrivateGetFunction() { | 130 ChromeosInfoPrivateGetFunction::ChromeosInfoPrivateGetFunction() { |
109 } | 131 } |
110 | 132 |
111 ChromeosInfoPrivateGetFunction::~ChromeosInfoPrivateGetFunction() { | 133 ChromeosInfoPrivateGetFunction::~ChromeosInfoPrivateGetFunction() { |
112 } | 134 } |
113 | 135 |
114 bool ChromeosInfoPrivateGetFunction::RunAsync() { | 136 bool ChromeosInfoPrivateGetFunction::RunAsync() { |
115 base::ListValue* list = NULL; | 137 base::ListValue* list = NULL; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 home_provider_id = cellular_device->home_provider_id(); | 173 home_provider_id = cellular_device->home_provider_id(); |
152 return new base::StringValue(home_provider_id); | 174 return new base::StringValue(home_provider_id); |
153 } else if (property_name == kPropertyInitialLocale) { | 175 } else if (property_name == kPropertyInitialLocale) { |
154 return new base::StringValue( | 176 return new base::StringValue( |
155 chromeos::StartupUtils::GetInitialLocale()); | 177 chromeos::StartupUtils::GetInitialLocale()); |
156 } else if (property_name == kPropertyBoard) { | 178 } else if (property_name == kPropertyBoard) { |
157 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard()); | 179 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard()); |
158 } else if (property_name == kPropertyOwner) { | 180 } else if (property_name == kPropertyOwner) { |
159 return base::Value::CreateBooleanValue( | 181 return base::Value::CreateBooleanValue( |
160 chromeos::UserManager::Get()->IsCurrentUserOwner()); | 182 chromeos::UserManager::Get()->IsCurrentUserOwner()); |
| 183 } else if (property_name == kPropertyClientId) { |
| 184 return base::Value::CreateStringValue(GetClientId()); |
161 } else if (property_name == kPropertyTimezone) { | 185 } else if (property_name == kPropertyTimezone) { |
162 return chromeos::CrosSettings::Get()->GetPref( | 186 return chromeos::CrosSettings::Get()->GetPref( |
163 chromeos::kSystemTimezone)->DeepCopy(); | 187 chromeos::kSystemTimezone)->DeepCopy(); |
164 } else if (property_name == kPropertySupportedTimezones) { | 188 } else if (property_name == kPropertySupportedTimezones) { |
165 scoped_ptr<base::ListValue> values = chromeos::system::GetTimezoneList(); | 189 scoped_ptr<base::ListValue> values = chromeos::system::GetTimezoneList(); |
166 return values.release(); | 190 return values.release(); |
167 } else { | 191 } else { |
168 const char* pref_name = | 192 const char* pref_name = |
169 GetBoolPrefNameForApiProperty(property_name.c_str()); | 193 GetBoolPrefNameForApiProperty(property_name.c_str()); |
170 if (pref_name) { | 194 if (pref_name) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } else { | 227 } else { |
204 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); | 228 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); |
205 return false; | 229 return false; |
206 } | 230 } |
207 } | 231 } |
208 | 232 |
209 return true; | 233 return true; |
210 } | 234 } |
211 | 235 |
212 } // namespace extensions | 236 } // namespace extensions |
OLD | NEW |