OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/webui/options/chromeos/power_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/power_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return; | 143 return; |
144 } | 144 } |
145 PowerStatus::Get()->SetPowerSource(id); | 145 PowerStatus::Get()->SetPowerSource(id); |
146 } | 146 } |
147 | 147 |
148 void PowerHandler::UpdatePowerSources() { | 148 void PowerHandler::UpdatePowerSources() { |
149 PowerStatus* status = PowerStatus::Get(); | 149 PowerStatus* status = PowerStatus::Get(); |
150 | 150 |
151 base::ListValue sources_list; | 151 base::ListValue sources_list; |
152 for (const auto& source : status->GetPowerSources()) { | 152 for (const auto& source : status->GetPowerSources()) { |
153 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 153 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
154 dict->SetString("id", source.id); | 154 dict->SetString("id", source.id); |
155 dict->SetInteger("type", source.type); | 155 dict->SetInteger("type", source.type); |
156 dict->SetString("description", | 156 dict->SetString("description", |
157 l10n_util::GetStringUTF16(source.description_id)); | 157 l10n_util::GetStringUTF16(source.description_id)); |
158 sources_list.Append(dict.release()); | 158 sources_list.Append(dict.release()); |
159 } | 159 } |
160 | 160 |
161 web_ui()->CallJavascriptFunction( | 161 web_ui()->CallJavascriptFunction( |
162 "options.PowerOverlay.setPowerSources", | 162 "options.PowerOverlay.setPowerSources", |
163 sources_list, | 163 sources_list, |
164 base::StringValue(status->GetCurrentPowerSourceID()), | 164 base::StringValue(status->GetCurrentPowerSourceID()), |
165 base::FundamentalValue(status->IsUsbChargerConnected()), | 165 base::FundamentalValue(status->IsUsbChargerConnected()), |
166 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); | 166 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); |
167 } | 167 } |
168 | 168 |
169 } // namespace options | 169 } // namespace options |
170 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |