OLD | NEW |
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 <memory> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
| 12 #include <utility> |
11 | 13 |
12 #include "base/bind.h" | 14 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
14 #include "base/location.h" | 16 #include "base/location.h" |
15 #include "base/logging.h" | 17 #include "base/logging.h" |
16 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" |
17 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
19 #include "base/values.h" | 22 #include "base/values.h" |
20 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
22 #include "chrome/grit/browser_resources.h" | 25 #include "chrome/grit/browser_resources.h" |
23 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
24 #include "chromeos/network/device_state.h" | 27 #include "chromeos/network/device_state.h" |
25 #include "chromeos/network/network_device_handler.h" | 28 #include "chromeos/network/network_device_handler.h" |
26 #include "chromeos/network/network_event_log.h" | 29 #include "chromeos/network/network_event_log.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 const DeviceState::CellularScanResults& scan_results = | 185 const DeviceState::CellularScanResults& scan_results = |
183 cellular->scan_results(); | 186 cellular->scan_results(); |
184 std::set<std::string> network_ids; | 187 std::set<std::string> network_ids; |
185 for (DeviceState::CellularScanResults::const_iterator it = | 188 for (DeviceState::CellularScanResults::const_iterator it = |
186 scan_results.begin(); it != scan_results.end(); ++it) { | 189 scan_results.begin(); it != scan_results.end(); ++it) { |
187 // We need to remove duplicates from the list because same network with | 190 // We need to remove duplicates from the list because same network with |
188 // different technologies are listed multiple times. But ModemManager | 191 // different technologies are listed multiple times. But ModemManager |
189 // Register API doesn't allow technology to be specified so just show unique | 192 // Register API doesn't allow technology to be specified so just show unique |
190 // network in UI. | 193 // network in UI. |
191 if (network_ids.insert(it->network_id).second) { | 194 if (network_ids.insert(it->network_id).second) { |
192 base::DictionaryValue* network = new base::DictionaryValue(); | 195 auto network = base::MakeUnique<base::DictionaryValue>(); |
193 network->SetString(kNetworkIdProperty, it->network_id); | 196 network->SetString(kNetworkIdProperty, it->network_id); |
194 if (!it->long_name.empty()) | 197 if (!it->long_name.empty()) |
195 network->SetString(kOperatorNameProperty, it->long_name); | 198 network->SetString(kOperatorNameProperty, it->long_name); |
196 else if (!it->short_name.empty()) | 199 else if (!it->short_name.empty()) |
197 network->SetString(kOperatorNameProperty, it->short_name); | 200 network->SetString(kOperatorNameProperty, it->short_name); |
198 else | 201 else |
199 network->SetString(kOperatorNameProperty, it->network_id); | 202 network->SetString(kOperatorNameProperty, it->network_id); |
200 network->SetString(kStatusProperty, it->status); | 203 network->SetString(kStatusProperty, it->status); |
201 network->SetString(kTechnologyProperty, it->technology); | 204 network->SetString(kTechnologyProperty, it->technology); |
202 networks_list_.Append(network); | 205 networks_list_.Append(std::move(network)); |
203 } | 206 } |
204 } | 207 } |
205 if (is_page_ready_) { | 208 if (is_page_ready_) { |
206 web_ui()->CallJavascriptFunctionUnsafe(kJsApiShowNetworks, networks_list_); | 209 web_ui()->CallJavascriptFunctionUnsafe(kJsApiShowNetworks, networks_list_); |
207 networks_list_.Clear(); | 210 networks_list_.Clear(); |
208 has_pending_results_ = false; | 211 has_pending_results_ = false; |
209 } else { | 212 } else { |
210 has_pending_results_ = true; | 213 has_pending_results_ = true; |
211 } | 214 } |
212 } | 215 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 : WebUIController(web_ui) { | 270 : WebUIController(web_ui) { |
268 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); | 271 ChooseMobileNetworkHandler* handler = new ChooseMobileNetworkHandler(); |
269 web_ui->AddMessageHandler(handler); | 272 web_ui->AddMessageHandler(handler); |
270 // Set up the "chrome://choose-mobile-network" source. | 273 // Set up the "chrome://choose-mobile-network" source. |
271 Profile* profile = Profile::FromWebUI(web_ui); | 274 Profile* profile = Profile::FromWebUI(web_ui); |
272 content::WebUIDataSource::Add( | 275 content::WebUIDataSource::Add( |
273 profile, CreateChooseMobileNetworkUIHTMLSource()); | 276 profile, CreateChooseMobileNetworkUIHTMLSource()); |
274 } | 277 } |
275 | 278 |
276 } // namespace chromeos | 279 } // namespace chromeos |
OLD | NEW |