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/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/startup_utils.h" | 9 #include "chrome/browser/chromeos/login/startup_utils.h" |
10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 } // namespace | 52 } // namespace |
53 | 53 |
54 ChromeosInfoPrivateGetFunction::ChromeosInfoPrivateGetFunction() { | 54 ChromeosInfoPrivateGetFunction::ChromeosInfoPrivateGetFunction() { |
55 } | 55 } |
56 | 56 |
57 ChromeosInfoPrivateGetFunction::~ChromeosInfoPrivateGetFunction() { | 57 ChromeosInfoPrivateGetFunction::~ChromeosInfoPrivateGetFunction() { |
58 } | 58 } |
59 | 59 |
60 bool ChromeosInfoPrivateGetFunction::RunImpl() { | 60 bool ChromeosInfoPrivateGetFunction::RunImpl() { |
61 ListValue* list = NULL; | 61 base::ListValue* list = NULL; |
62 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); | 62 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); |
63 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 63 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
64 for (size_t i = 0; i < list->GetSize(); ++i) { | 64 for (size_t i = 0; i < list->GetSize(); ++i) { |
65 std::string property_name; | 65 std::string property_name; |
66 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); | 66 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); |
67 Value* value = GetValue(property_name); | 67 base::Value* value = GetValue(property_name); |
68 if (value) | 68 if (value) |
69 result->Set(property_name, value); | 69 result->Set(property_name, value); |
70 } | 70 } |
71 SetResult(result.release()); | 71 SetResult(result.release()); |
72 SendResponse(true); | 72 SendResponse(true); |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 base::Value* ChromeosInfoPrivateGetFunction::GetValue( | 76 base::Value* ChromeosInfoPrivateGetFunction::GetValue( |
77 const std::string& property_name) { | 77 const std::string& property_name) { |
(...skipping 10 matching lines...) Expand all Loading... |
88 std::string home_provider_id; | 88 std::string home_provider_id; |
89 if (cellular_device) | 89 if (cellular_device) |
90 home_provider_id = cellular_device->home_provider_id(); | 90 home_provider_id = cellular_device->home_provider_id(); |
91 return new base::StringValue(home_provider_id); | 91 return new base::StringValue(home_provider_id); |
92 } else if (property_name == kPropertyInitialLocale) { | 92 } else if (property_name == kPropertyInitialLocale) { |
93 return new base::StringValue( | 93 return new base::StringValue( |
94 chromeos::StartupUtils::GetInitialLocale()); | 94 chromeos::StartupUtils::GetInitialLocale()); |
95 } else if (property_name == kPropertyBoard) { | 95 } else if (property_name == kPropertyBoard) { |
96 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard()); | 96 return new base::StringValue(base::SysInfo::GetLsbReleaseBoard()); |
97 } else if (property_name == kPropertyOwner) { | 97 } else if (property_name == kPropertyOwner) { |
98 return Value::CreateBooleanValue( | 98 return base::Value::CreateBooleanValue( |
99 chromeos::UserManager::Get()->IsCurrentUserOwner()); | 99 chromeos::UserManager::Get()->IsCurrentUserOwner()); |
100 } else if (property_name == kPropertyTimezone) { | 100 } else if (property_name == kPropertyTimezone) { |
101 return chromeos::CrosSettings::Get()->GetPref( | 101 return chromeos::CrosSettings::Get()->GetPref( |
102 chromeos::kSystemTimezone)->DeepCopy(); | 102 chromeos::kSystemTimezone)->DeepCopy(); |
103 } else if (property_name == kPropertySupportedTimezones) { | 103 } else if (property_name == kPropertySupportedTimezones) { |
104 scoped_ptr<base::ListValue> values = chromeos::system::GetTimezoneList(); | 104 scoped_ptr<base::ListValue> values = chromeos::system::GetTimezoneList(); |
105 return values.release(); | 105 return values.release(); |
106 } | 106 } |
107 | 107 |
108 DLOG(ERROR) << "Unknown property request: " << property_name; | 108 DLOG(ERROR) << "Unknown property request: " << property_name; |
(...skipping 17 matching lines...) Expand all Loading... |
126 base::StringValue(param_value)); | 126 base::StringValue(param_value)); |
127 } else { | 127 } else { |
128 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); | 128 error_ = ErrorUtils::FormatErrorMessage(kPropertyNotFound, param_name); |
129 return false; | 129 return false; |
130 } | 130 } |
131 | 131 |
132 return true; | 132 return true; |
133 } | 133 } |
134 | 134 |
135 } // namespace extensions | 135 } // namespace extensions |
OLD | NEW |