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 <utility> |
| 8 |
7 #include "ash/resources/grit/ash_resources.h" | 9 #include "ash/resources/grit/ash_resources.h" |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
10 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 14 #include "base/values.h" |
13 #include "chrome/browser/ui/ash/ash_util.h" | 15 #include "chrome/browser/ui/ash/ash_util.h" |
14 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
16 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void PowerHandler::UpdatePowerSources() { | 153 void PowerHandler::UpdatePowerSources() { |
152 PowerStatus* status = PowerStatus::Get(); | 154 PowerStatus* status = PowerStatus::Get(); |
153 | 155 |
154 base::ListValue sources_list; | 156 base::ListValue sources_list; |
155 for (const auto& source : status->GetPowerSources()) { | 157 for (const auto& source : status->GetPowerSources()) { |
156 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 158 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
157 dict->SetString("id", source.id); | 159 dict->SetString("id", source.id); |
158 dict->SetInteger("type", source.type); | 160 dict->SetInteger("type", source.type); |
159 dict->SetString("description", | 161 dict->SetString("description", |
160 l10n_util::GetStringUTF16(source.description_id)); | 162 l10n_util::GetStringUTF16(source.description_id)); |
161 sources_list.Append(dict.release()); | 163 sources_list.Append(std::move(dict)); |
162 } | 164 } |
163 | 165 |
164 web_ui()->CallJavascriptFunctionUnsafe( | 166 web_ui()->CallJavascriptFunctionUnsafe( |
165 "options.PowerOverlay.setPowerSources", sources_list, | 167 "options.PowerOverlay.setPowerSources", sources_list, |
166 base::StringValue(status->GetCurrentPowerSourceID()), | 168 base::StringValue(status->GetCurrentPowerSourceID()), |
167 base::FundamentalValue(status->IsUsbChargerConnected()), | 169 base::FundamentalValue(status->IsUsbChargerConnected()), |
168 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); | 170 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); |
169 } | 171 } |
170 | 172 |
171 } // namespace options | 173 } // namespace options |
172 } // namespace chromeos | 174 } // namespace chromeos |
OLD | NEW |