Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/device_power_handler.cc

Issue 2886083002: MD Settings: Use FireWebUIListener() helper wherever possible. (Closed)
Patch Set: Fixed typo Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/settings/chromeos/device_power_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/device_power_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/resources/grit/ash_resources.h" 10 #include "ash/resources/grit/ash_resources.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 status_text = l10n_util::GetStringFUTF16(IDS_OPTIONS_BATTERY_STATUS_SHORT, 108 status_text = l10n_util::GetStringFUTF16(IDS_OPTIONS_BATTERY_STATUS_SHORT,
109 base::IntToString16(percent)); 109 base::IntToString16(percent));
110 } 110 }
111 111
112 base::DictionaryValue battery_dict; 112 base::DictionaryValue battery_dict;
113 battery_dict.SetBoolean("charging", charging); 113 battery_dict.SetBoolean("charging", charging);
114 battery_dict.SetBoolean("calculating", calculating); 114 battery_dict.SetBoolean("calculating", calculating);
115 battery_dict.SetInteger("percent", percent); 115 battery_dict.SetInteger("percent", percent);
116 battery_dict.SetString("statusText", status_text); 116 battery_dict.SetString("statusText", status_text);
117 117
118 CallJavascriptFunction("cr.webUIListenerCallback", 118 FireWebUIListener("battery-status-changed", battery_dict);
119 base::Value("battery-status-changed"), battery_dict);
120 } 119 }
121 120
122 void PowerHandler::SendPowerSources() { 121 void PowerHandler::SendPowerSources() {
123 base::ListValue sources_list; 122 base::ListValue sources_list;
124 for (const auto& source : power_status_->GetPowerSources()) { 123 for (const auto& source : power_status_->GetPowerSources()) {
125 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 124 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
126 dict->SetString("id", source.id); 125 dict->SetString("id", source.id);
127 dict->SetInteger("type", source.type); 126 dict->SetInteger("type", source.type);
128 dict->SetString("description", 127 dict->SetString("description",
129 l10n_util::GetStringUTF16(source.description_id)); 128 l10n_util::GetStringUTF16(source.description_id));
130 sources_list.Append(std::move(dict)); 129 sources_list.Append(std::move(dict));
131 } 130 }
132 131
133 CallJavascriptFunction("cr.webUIListenerCallback", 132 FireWebUIListener("power-sources-changed", sources_list,
134 base::Value("power-sources-changed"), sources_list, 133 base::Value(power_status_->GetCurrentPowerSourceID()),
135 base::Value(power_status_->GetCurrentPowerSourceID()), 134 base::Value(power_status_->IsUsbChargerConnected()));
136 base::Value(power_status_->IsUsbChargerConnected()));
137 } 135 }
138 136
139 } // namespace settings 137 } // namespace settings
140 } // namespace chromeos 138 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698