| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_info_private_api_chromeos.h" | 5 #include "chrome/browser/extensions/extension_info_private_api_chromeos.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 #include "chrome/browser/chromeos/cros/network_library.h" | 9 #include "chrome/browser/chromeos/cros/network_library.h" |
| 10 #include "chrome/browser/chromeos/login/wizard_controller.h" | 10 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 ListValue* list = NULL; | 39 ListValue* list = NULL; |
| 40 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); | 40 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); |
| 41 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 41 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
| 42 for (size_t i = 0; i < list->GetSize(); ++i) { | 42 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 43 std::string property_name; | 43 std::string property_name; |
| 44 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); | 44 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); |
| 45 std::string value; | 45 std::string value; |
| 46 if (GetValue(property_name, &value)) | 46 if (GetValue(property_name, &value)) |
| 47 result->Set(property_name, Value::CreateStringValue(value)); | 47 result->Set(property_name, Value::CreateStringValue(value)); |
| 48 } | 48 } |
| 49 result_.reset(result.release()); | 49 SetResult(result.release()); |
| 50 SendResponse(true); | 50 SendResponse(true); |
| 51 return true; | 51 return true; |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool GetChromeosInfoFunction::GetValue(const std::string& property_name, | 54 bool GetChromeosInfoFunction::GetValue(const std::string& property_name, |
| 55 std::string* value) { | 55 std::string* value) { |
| 56 value->clear(); | 56 value->clear(); |
| 57 if (property_name == kPropertyHWID) { | 57 if (property_name == kPropertyHWID) { |
| 58 chromeos::system::StatisticsProvider* provider = | 58 chromeos::system::StatisticsProvider* provider = |
| 59 chromeos::system::StatisticsProvider::GetInstance(); | 59 chromeos::system::StatisticsProvider::GetInstance(); |
| 60 provider->GetMachineStatistic(kHardwareClass, value); | 60 provider->GetMachineStatistic(kHardwareClass, value); |
| 61 } else if (property_name == kPropertyHomeProvider) { | 61 } else if (property_name == kPropertyHomeProvider) { |
| 62 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); | 62 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); |
| 63 (*value) = netlib->GetCellularHomeCarrierId(); | 63 (*value) = netlib->GetCellularHomeCarrierId(); |
| 64 } else if (property_name == kPropertyInitialLocale) { | 64 } else if (property_name == kPropertyInitialLocale) { |
| 65 *value = chromeos::WizardController::GetInitialLocale(); | 65 *value = chromeos::WizardController::GetInitialLocale(); |
| 66 } else { | 66 } else { |
| 67 LOG(ERROR) << "Unknown property request: " << property_name; | 67 LOG(ERROR) << "Unknown property request: " << property_name; |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| OLD | NEW |