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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/power_handler.cc

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 web_ui()->RegisterMessageCallback( 73 web_ui()->RegisterMessageCallback(
74 "updatePowerStatus", 74 "updatePowerStatus",
75 base::Bind(&PowerHandler::UpdatePowerStatus, base::Unretained(this))); 75 base::Bind(&PowerHandler::UpdatePowerStatus, base::Unretained(this)));
76 // Callback to set the power source. 76 // Callback to set the power source.
77 web_ui()->RegisterMessageCallback( 77 web_ui()->RegisterMessageCallback(
78 "setPowerSource", 78 "setPowerSource",
79 base::Bind(&PowerHandler::SetPowerSource, base::Unretained(this))); 79 base::Bind(&PowerHandler::SetPowerSource, base::Unretained(this)));
80 } 80 }
81 81
82 void PowerHandler::OnPowerStatusChanged() { 82 void PowerHandler::OnPowerStatusChanged() {
83 web_ui()->CallJavascriptFunction( 83 web_ui()->CallJavascriptFunctionUnsafe(
84 "options.PowerOverlay.setBatteryStatusText", 84 "options.PowerOverlay.setBatteryStatusText",
85 base::StringValue(GetStatusValue())); 85 base::StringValue(GetStatusValue()));
86 UpdatePowerSources(); 86 UpdatePowerSources();
87 } 87 }
88 88
89 base::string16 PowerHandler::GetStatusValue() const { 89 base::string16 PowerHandler::GetStatusValue() const {
90 PowerStatus* status = PowerStatus::Get(); 90 PowerStatus* status = PowerStatus::Get();
91 if (!status->IsBatteryPresent()) 91 if (!status->IsBatteryPresent())
92 return base::string16(); 92 return base::string16();
93 93
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::unique_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()->CallJavascriptFunctionUnsafe(
162 "options.PowerOverlay.setPowerSources", 162 "options.PowerOverlay.setPowerSources", sources_list,
163 sources_list,
164 base::StringValue(status->GetCurrentPowerSourceID()), 163 base::StringValue(status->GetCurrentPowerSourceID()),
165 base::FundamentalValue(status->IsUsbChargerConnected()), 164 base::FundamentalValue(status->IsUsbChargerConnected()),
166 base::FundamentalValue(status->IsBatteryTimeBeingCalculated())); 165 base::FundamentalValue(status->IsBatteryTimeBeingCalculated()));
167 } 166 }
168 167
169 } // namespace options 168 } // namespace options
170 } // namespace chromeos 169 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/pointer_handler.cc ('k') | chrome/browser/ui/webui/options/chromeos/proxy_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698