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

Side by Side Diff: chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.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 (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/ui/webui/chromeos/choose_mobile_network_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 networks_list_.Clear(); 168 networks_list_.Clear();
169 if (!cellular) { 169 if (!cellular) {
170 LOG(WARNING) << "Cellular device with path '" << device_path_ 170 LOG(WARNING) << "Cellular device with path '" << device_path_
171 << "' disappeared."; 171 << "' disappeared.";
172 return; 172 return;
173 } 173 }
174 if (cellular->scanning()) { 174 if (cellular->scanning()) {
175 NET_LOG_EVENT("ChooseMobileNetwork", "Device is scanning for networks."); 175 NET_LOG_EVENT("ChooseMobileNetwork", "Device is scanning for networks.");
176 scanning_ = true; 176 scanning_ = true;
177 if (is_page_ready_) 177 if (is_page_ready_)
178 web_ui()->CallJavascriptFunction(kJsApiShowScanning); 178 web_ui()->CallJavascriptFunctionUnsafe(kJsApiShowScanning);
179 return; 179 return;
180 } 180 }
181 scanning_ = false; 181 scanning_ = false;
182 const DeviceState::CellularScanResults& scan_results = 182 const DeviceState::CellularScanResults& scan_results =
183 cellular->scan_results(); 183 cellular->scan_results();
184 std::set<std::string> network_ids; 184 std::set<std::string> network_ids;
185 for (DeviceState::CellularScanResults::const_iterator it = 185 for (DeviceState::CellularScanResults::const_iterator it =
186 scan_results.begin(); it != scan_results.end(); ++it) { 186 scan_results.begin(); it != scan_results.end(); ++it) {
187 // We need to remove duplicates from the list because same network with 187 // We need to remove duplicates from the list because same network with
188 // different technologies are listed multiple times. But ModemManager 188 // different technologies are listed multiple times. But ModemManager
189 // Register API doesn't allow technology to be specified so just show unique 189 // Register API doesn't allow technology to be specified so just show unique
190 // network in UI. 190 // network in UI.
191 if (network_ids.insert(it->network_id).second) { 191 if (network_ids.insert(it->network_id).second) {
192 base::DictionaryValue* network = new base::DictionaryValue(); 192 base::DictionaryValue* network = new base::DictionaryValue();
193 network->SetString(kNetworkIdProperty, it->network_id); 193 network->SetString(kNetworkIdProperty, it->network_id);
194 if (!it->long_name.empty()) 194 if (!it->long_name.empty())
195 network->SetString(kOperatorNameProperty, it->long_name); 195 network->SetString(kOperatorNameProperty, it->long_name);
196 else if (!it->short_name.empty()) 196 else if (!it->short_name.empty())
197 network->SetString(kOperatorNameProperty, it->short_name); 197 network->SetString(kOperatorNameProperty, it->short_name);
198 else 198 else
199 network->SetString(kOperatorNameProperty, it->network_id); 199 network->SetString(kOperatorNameProperty, it->network_id);
200 network->SetString(kStatusProperty, it->status); 200 network->SetString(kStatusProperty, it->status);
201 network->SetString(kTechnologyProperty, it->technology); 201 network->SetString(kTechnologyProperty, it->technology);
202 networks_list_.Append(network); 202 networks_list_.Append(network);
203 } 203 }
204 } 204 }
205 if (is_page_ready_) { 205 if (is_page_ready_) {
206 web_ui()->CallJavascriptFunction(kJsApiShowNetworks, networks_list_); 206 web_ui()->CallJavascriptFunctionUnsafe(kJsApiShowNetworks, networks_list_);
207 networks_list_.Clear(); 207 networks_list_.Clear();
208 has_pending_results_ = false; 208 has_pending_results_ = false;
209 } else { 209 } else {
210 has_pending_results_ = true; 210 has_pending_results_ = true;
211 } 211 }
212 } 212 }
213 213
214 void ChooseMobileNetworkHandler::HandleCancel(const base::ListValue* args) { 214 void ChooseMobileNetworkHandler::HandleCancel(const base::ListValue* args) {
215 const size_t kConnectParamCount = 0; 215 const size_t kConnectParamCount = 0;
216 if (args->GetSize() != kConnectParamCount) { 216 if (args->GetSize() != kConnectParamCount) {
(...skipping 28 matching lines...) Expand all
245 } 245 }
246 246
247 void ChooseMobileNetworkHandler::HandlePageReady(const base::ListValue* args) { 247 void ChooseMobileNetworkHandler::HandlePageReady(const base::ListValue* args) {
248 const size_t kConnectParamCount = 0; 248 const size_t kConnectParamCount = 0;
249 if (args->GetSize() != kConnectParamCount) { 249 if (args->GetSize() != kConnectParamCount) {
250 NOTREACHED(); 250 NOTREACHED();
251 return; 251 return;
252 } 252 }
253 253
254 if (has_pending_results_) { 254 if (has_pending_results_) {
255 web_ui()->CallJavascriptFunction(kJsApiShowNetworks, networks_list_); 255 web_ui()->CallJavascriptFunctionUnsafe(kJsApiShowNetworks, networks_list_);
256 networks_list_.Clear(); 256 networks_list_.Clear();
257 has_pending_results_ = false; 257 has_pending_results_ = false;
258 } else if (scanning_) { 258 } else if (scanning_) {
259 web_ui()->CallJavascriptFunction(kJsApiShowScanning); 259 web_ui()->CallJavascriptFunctionUnsafe(kJsApiShowScanning);
260 } 260 }
261 is_page_ready_ = true; 261 is_page_ready_ = true;
262 } 262 }
263 263
264 } // namespace 264 } // namespace
265 265
266 ChooseMobileNetworkUI::ChooseMobileNetworkUI(content::WebUI* web_ui) 266 ChooseMobileNetworkUI::ChooseMobileNetworkUI(content::WebUI* web_ui)
267 : WebUIController(web_ui) { 267 : WebUIController(web_ui) {
268 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); 268 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler();
269 web_ui->AddMessageHandler(handler); 269 web_ui->AddMessageHandler(handler);
270 // Set up the "chrome://choose-mobile-network" source. 270 // Set up the "chrome://choose-mobile-network" source.
271 Profile* profile = Profile::FromWebUI(web_ui); 271 Profile* profile = Profile::FromWebUI(web_ui);
272 content::WebUIDataSource::Add( 272 content::WebUIDataSource::Add(
273 profile, CreateChooseMobileNetworkUIHTMLSource()); 273 profile, CreateChooseMobileNetworkUIHTMLSource());
274 } 274 }
275 275
276 } // namespace chromeos 276 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/certificate_viewer_webui.cc ('k') | chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698