| 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/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/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 const char kPropertyReleaseBoard[] = "CHROMEOS_RELEASE_BOARD"; | 34 const char kPropertyReleaseBoard[] = "CHROMEOS_RELEASE_BOARD"; |
| 35 | 35 |
| 36 // Key which corresponds to the board property in JS. | 36 // Key which corresponds to the board property in JS. |
| 37 const char kPropertyBoard[] = "board"; | 37 const char kPropertyBoard[] = "board"; |
| 38 | 38 |
| 39 // Key which corresponds to the board property in JS. | 39 // Key which corresponds to the board property in JS. |
| 40 const char kPropertyOwner[] = "isOwner"; | 40 const char kPropertyOwner[] = "isOwner"; |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 GetChromeosInfoFunction::GetChromeosInfoFunction() { | 44 ChromeosInfoPrivateGetFunction::ChromeosInfoPrivateGetFunction() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 GetChromeosInfoFunction::~GetChromeosInfoFunction() { | 47 ChromeosInfoPrivateGetFunction::~ChromeosInfoPrivateGetFunction() { |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool GetChromeosInfoFunction::RunImpl() { | 50 bool ChromeosInfoPrivateGetFunction::RunImpl() { |
| 51 ListValue* list = NULL; | 51 ListValue* list = NULL; |
| 52 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); | 52 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); |
| 53 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 53 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
| 54 for (size_t i = 0; i < list->GetSize(); ++i) { | 54 for (size_t i = 0; i < list->GetSize(); ++i) { |
| 55 std::string property_name; | 55 std::string property_name; |
| 56 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); | 56 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); |
| 57 Value* value = GetValue(property_name); | 57 Value* value = GetValue(property_name); |
| 58 if (value) | 58 if (value) |
| 59 result->Set(property_name, value); | 59 result->Set(property_name, value); |
| 60 } | 60 } |
| 61 SetResult(result.release()); | 61 SetResult(result.release()); |
| 62 SendResponse(true); | 62 SendResponse(true); |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 base::Value* GetChromeosInfoFunction::GetValue( | 66 base::Value* ChromeosInfoPrivateGetFunction::GetValue( |
| 67 const std::string& property_name) { | 67 const std::string& property_name) { |
| 68 if (property_name == kPropertyHWID) { | 68 if (property_name == kPropertyHWID) { |
| 69 std::string hwid; | 69 std::string hwid; |
| 70 chromeos::system::StatisticsProvider* provider = | 70 chromeos::system::StatisticsProvider* provider = |
| 71 chromeos::system::StatisticsProvider::GetInstance(); | 71 chromeos::system::StatisticsProvider::GetInstance(); |
| 72 provider->GetMachineStatistic(kHardwareClass, &hwid); | 72 provider->GetMachineStatistic(kHardwareClass, &hwid); |
| 73 return new base::StringValue(hwid); | 73 return new base::StringValue(hwid); |
| 74 } else if (property_name == kPropertyHomeProvider) { | 74 } else if (property_name == kPropertyHomeProvider) { |
| 75 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); | 75 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); |
| 76 return new base::StringValue(netlib->GetCellularHomeCarrierId()); | 76 return new base::StringValue(netlib->GetCellularHomeCarrierId()); |
| 77 } else if (property_name == kPropertyInitialLocale) { | 77 } else if (property_name == kPropertyInitialLocale) { |
| 78 return new base::StringValue( | 78 return new base::StringValue( |
| 79 chromeos::WizardController::GetInitialLocale()); | 79 chromeos::WizardController::GetInitialLocale()); |
| 80 } else if (property_name == kPropertyBoard) { | 80 } else if (property_name == kPropertyBoard) { |
| 81 std::string board; | 81 std::string board; |
| 82 chromeos::system::StatisticsProvider* provider = | 82 chromeos::system::StatisticsProvider* provider = |
| 83 chromeos::system::StatisticsProvider::GetInstance(); | 83 chromeos::system::StatisticsProvider::GetInstance(); |
| 84 provider->GetMachineStatistic(kPropertyReleaseBoard, &board); | 84 provider->GetMachineStatistic(kPropertyReleaseBoard, &board); |
| 85 return new base::StringValue(board); | 85 return new base::StringValue(board); |
| 86 } else if (property_name == kPropertyOwner) { | 86 } else if (property_name == kPropertyOwner) { |
| 87 return Value::CreateBooleanValue( | 87 return Value::CreateBooleanValue( |
| 88 chromeos::UserManager::Get()->IsCurrentUserOwner()); | 88 chromeos::UserManager::Get()->IsCurrentUserOwner()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 DLOG(ERROR) << "Unknown property request: " << property_name; | 91 DLOG(ERROR) << "Unknown property request: " << property_name; |
| 92 return NULL; | 92 return NULL; |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace extensions | 95 } // namespace extensions |
| OLD | NEW |