| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 base::Value* ChromeosInfoPrivateGetFunction::GetValue( | 221 base::Value* ChromeosInfoPrivateGetFunction::GetValue( |
| 222 const std::string& property_name) { | 222 const std::string& property_name) { |
| 223 if (property_name == kPropertyHWID) { | 223 if (property_name == kPropertyHWID) { |
| 224 std::string hwid; | 224 std::string hwid; |
| 225 chromeos::system::StatisticsProvider* provider = | 225 chromeos::system::StatisticsProvider* provider = |
| 226 chromeos::system::StatisticsProvider::GetInstance(); | 226 chromeos::system::StatisticsProvider::GetInstance(); |
| 227 provider->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid); | 227 provider->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid); |
| 228 return new base::StringValue(hwid); | 228 return new base::Value(hwid); |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (property_name == kPropertyCustomizationID) { | 231 if (property_name == kPropertyCustomizationID) { |
| 232 std::string customization_id; | 232 std::string customization_id; |
| 233 chromeos::system::StatisticsProvider* provider = | 233 chromeos::system::StatisticsProvider* provider = |
| 234 chromeos::system::StatisticsProvider::GetInstance(); | 234 chromeos::system::StatisticsProvider::GetInstance(); |
| 235 provider->GetMachineStatistic(chromeos::system::kCustomizationIdKey, | 235 provider->GetMachineStatistic(chromeos::system::kCustomizationIdKey, |
| 236 &customization_id); | 236 &customization_id); |
| 237 return new base::StringValue(customization_id); | 237 return new base::Value(customization_id); |
| 238 } | 238 } |
| 239 | 239 |
| 240 if (property_name == kPropertyHomeProvider) { | 240 if (property_name == kPropertyHomeProvider) { |
| 241 const chromeos::DeviceState* cellular_device = | 241 const chromeos::DeviceState* cellular_device = |
| 242 NetworkHandler::Get()->network_state_handler()->GetDeviceStateByType( | 242 NetworkHandler::Get()->network_state_handler()->GetDeviceStateByType( |
| 243 chromeos::NetworkTypePattern::Cellular()); | 243 chromeos::NetworkTypePattern::Cellular()); |
| 244 std::string home_provider_id; | 244 std::string home_provider_id; |
| 245 if (cellular_device) | 245 if (cellular_device) |
| 246 home_provider_id = cellular_device->home_provider_id(); | 246 home_provider_id = cellular_device->home_provider_id(); |
| 247 return new base::StringValue(home_provider_id); | 247 return new base::Value(home_provider_id); |
| 248 } | 248 } |
| 249 | 249 |
| 250 if (property_name == kPropertyInitialLocale) { | 250 if (property_name == kPropertyInitialLocale) { |
| 251 return new base::StringValue( | 251 return new base::Value(chromeos::StartupUtils::GetInitialLocale()); |
| 252 chromeos::StartupUtils::GetInitialLocale()); | |
| 253 } | 252 } |
| 254 | 253 |
| 255 if (property_name == kPropertyBoard) { | 254 if (property_name == kPropertyBoard) { |
| 256 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard()); | 255 return new base::Value(base::SysInfo::GetLsbReleaseBoard()); |
| 257 } | 256 } |
| 258 | 257 |
| 259 if (property_name == kPropertyOwner) { | 258 if (property_name == kPropertyOwner) { |
| 260 return new base::Value( | 259 return new base::Value( |
| 261 user_manager::UserManager::Get()->IsCurrentUserOwner()); | 260 user_manager::UserManager::Get()->IsCurrentUserOwner()); |
| 262 } | 261 } |
| 263 | 262 |
| 264 if (property_name == kPropertySessionType) { | 263 if (property_name == kPropertySessionType) { |
| 265 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) | 264 if (ExtensionsBrowserClient::Get()->IsRunningInForcedAppMode()) |
| 266 return new base::StringValue(kSessionTypeKiosk); | 265 return new base::Value(kSessionTypeKiosk); |
| 267 if (ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount()) | 266 if (ExtensionsBrowserClient::Get()->IsLoggedInAsPublicAccount()) |
| 268 return new base::StringValue(kSessionTypePublicSession); | 267 return new base::Value(kSessionTypePublicSession); |
| 269 return new base::StringValue(kSessionTypeNormal); | 268 return new base::Value(kSessionTypeNormal); |
| 270 } | 269 } |
| 271 | 270 |
| 272 if (property_name == kPropertyPlayStoreStatus) { | 271 if (property_name == kPropertyPlayStoreStatus) { |
| 273 if (arc::IsArcAllowedForProfile(Profile::FromBrowserContext(context_))) | 272 if (arc::IsArcAllowedForProfile(Profile::FromBrowserContext(context_))) |
| 274 return new base::StringValue(kPlayStoreStatusEnabled); | 273 return new base::Value(kPlayStoreStatusEnabled); |
| 275 if (arc::IsArcAvailable()) | 274 if (arc::IsArcAvailable()) |
| 276 return new base::StringValue(kPlayStoreStatusAvailable); | 275 return new base::Value(kPlayStoreStatusAvailable); |
| 277 return new base::StringValue(kPlayStoreStatusNotAvailable); | 276 return new base::Value(kPlayStoreStatusNotAvailable); |
| 278 } | 277 } |
| 279 | 278 |
| 280 if (property_name == kPropertyManagedDeviceStatus) { | 279 if (property_name == kPropertyManagedDeviceStatus) { |
| 281 policy::BrowserPolicyConnectorChromeOS* connector = | 280 policy::BrowserPolicyConnectorChromeOS* connector = |
| 282 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 281 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 283 if (connector->IsEnterpriseManaged()) { | 282 if (connector->IsEnterpriseManaged()) { |
| 284 return new base::StringValue(kManagedDeviceStatusManaged); | 283 return new base::Value(kManagedDeviceStatusManaged); |
| 285 } | 284 } |
| 286 return new base::StringValue(kManagedDeviceStatusNotManaged); | 285 return new base::Value(kManagedDeviceStatusNotManaged); |
| 287 } | 286 } |
| 288 | 287 |
| 289 if (property_name == kPropertyClientId) { | 288 if (property_name == kPropertyClientId) { |
| 290 return new base::StringValue(GetClientId()); | 289 return new base::Value(GetClientId()); |
| 291 } | 290 } |
| 292 | 291 |
| 293 if (property_name == kPropertyTimezone) { | 292 if (property_name == kPropertyTimezone) { |
| 294 return chromeos::CrosSettings::Get()->GetPref( | 293 return chromeos::CrosSettings::Get()->GetPref( |
| 295 chromeos::kSystemTimezone)->DeepCopy(); | 294 chromeos::kSystemTimezone)->DeepCopy(); |
| 296 } | 295 } |
| 297 | 296 |
| 298 if (property_name == kPropertySupportedTimezones) { | 297 if (property_name == kPropertySupportedTimezones) { |
| 299 std::unique_ptr<base::ListValue> values = | 298 std::unique_ptr<base::ListValue> values = |
| 300 chromeos::system::GetTimezoneList(); | 299 chromeos::system::GetTimezoneList(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 318 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { | 317 ChromeosInfoPrivateSetFunction::~ChromeosInfoPrivateSetFunction() { |
| 319 } | 318 } |
| 320 | 319 |
| 321 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { | 320 ExtensionFunction::ResponseAction ChromeosInfoPrivateSetFunction::Run() { |
| 322 std::string param_name; | 321 std::string param_name; |
| 323 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); | 322 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, ¶m_name)); |
| 324 if (param_name == kPropertyTimezone) { | 323 if (param_name == kPropertyTimezone) { |
| 325 std::string param_value; | 324 std::string param_value; |
| 326 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); | 325 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, ¶m_value)); |
| 327 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, | 326 chromeos::CrosSettings::Get()->Set(chromeos::kSystemTimezone, |
| 328 base::StringValue(param_value)); | 327 base::Value(param_value)); |
| 329 } else { | 328 } else { |
| 330 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); | 329 const char* pref_name = GetBoolPrefNameForApiProperty(param_name.c_str()); |
| 331 if (pref_name) { | 330 if (pref_name) { |
| 332 bool param_value; | 331 bool param_value; |
| 333 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); | 332 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, ¶m_value)); |
| 334 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( | 333 Profile::FromBrowserContext(context_)->GetPrefs()->SetBoolean( |
| 335 pref_name, | 334 pref_name, |
| 336 param_value); | 335 param_value); |
| 337 } else { | 336 } else { |
| 338 return RespondNow(Error(kPropertyNotFound, param_name)); | 337 return RespondNow(Error(kPropertyNotFound, param_name)); |
| 339 } | 338 } |
| 340 } | 339 } |
| 341 | 340 |
| 342 return RespondNow(NoArguments()); | 341 return RespondNow(NoArguments()); |
| 343 } | 342 } |
| 344 | 343 |
| 345 } // namespace extensions | 344 } // namespace extensions |
| OLD | NEW |