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

Side by Side Diff: chrome/browser/chromeos/network_list.cc

Issue 2010001: Refactor WifiNetwork, CellularNetwork, and EthernetNetwork into classes to ma... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/chromeos/network_list.h" 5 #include "chrome/browser/chromeos/network_list.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 20 matching lines...) Expand all
31 if (NETWORK_EMPTY == type || id.empty()) return -1; 31 if (NETWORK_EMPTY == type || id.empty()) return -1;
32 std::string network_id = UTF16ToASCII(id); 32 std::string network_id = UTF16ToASCII(id);
33 for (size_t i = 0; i < networks_.size(); i++) { 33 for (size_t i = 0; i < networks_.size(); i++) {
34 if (type == networks_[i].network_type) { 34 if (type == networks_[i].network_type) {
35 switch (type) { 35 switch (type) {
36 case NETWORK_ETHERNET: 36 case NETWORK_ETHERNET:
37 // Assuming that there's only single Ethernet network. 37 // Assuming that there's only single Ethernet network.
38 return i; 38 return i;
39 39
40 case NETWORK_WIFI: 40 case NETWORK_WIFI:
41 if (network_id == networks_[i].wifi_network.ssid) 41 if (network_id == networks_[i].wifi_network.name())
42 return i; 42 return i;
43 break; 43 break;
44 44
45 case NETWORK_CELLULAR: 45 case NETWORK_CELLULAR:
46 if (network_id == networks_[i].cellular_network.name) 46 if (network_id == networks_[i].cellular_network.name())
47 return i; 47 return i;
48 break; 48 break;
49 49
50 default: 50 default:
51 break; 51 break;
52 } 52 }
53 } 53 }
54 } 54 }
55 return -1; 55 return -1;
56 } 56 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 WifiNetwork(), 94 WifiNetwork(),
95 CellularNetwork())); 95 CellularNetwork()));
96 SetNetworksIndices(index++, ethernet_connected, ethernet_connecting); 96 SetNetworksIndices(index++, ethernet_connected, ethernet_connecting);
97 } 97 }
98 98
99 // TODO(nkostylev): Show public WiFi networks first. 99 // TODO(nkostylev): Show public WiFi networks first.
100 WifiNetworkVector wifi = network_lib->wifi_networks(); 100 WifiNetworkVector wifi = network_lib->wifi_networks();
101 for (WifiNetworkVector::const_iterator it = wifi.begin(); 101 for (WifiNetworkVector::const_iterator it = wifi.begin();
102 it != wifi.end(); ++it, ++index) { 102 it != wifi.end(); ++it, ++index) {
103 networks_.push_back(NetworkItem(NETWORK_WIFI, 103 networks_.push_back(NetworkItem(NETWORK_WIFI,
104 ASCIIToUTF16(it->ssid), 104 ASCIIToUTF16(it->name()),
105 *it, 105 *it,
106 CellularNetwork())); 106 CellularNetwork()));
107 if (network_lib->wifi_ssid() == it->ssid) { 107 if (network_lib->wifi_name() == it->name()) {
108 SetNetworksIndices(index, 108 SetNetworksIndices(index,
109 network_lib->wifi_connected(), 109 network_lib->wifi_connected(),
110 network_lib->wifi_connecting()); 110 network_lib->wifi_connecting());
111 } 111 }
112 } 112 }
113 113
114 CellularNetworkVector cellular = network_lib->cellular_networks(); 114 CellularNetworkVector cellular = network_lib->cellular_networks();
115 for (CellularNetworkVector::const_iterator it = cellular.begin(); 115 for (CellularNetworkVector::const_iterator it = cellular.begin();
116 it != cellular.end(); ++it, ++index) { 116 it != cellular.end(); ++it, ++index) {
117 networks_.push_back(NetworkItem(NETWORK_CELLULAR, 117 networks_.push_back(NetworkItem(NETWORK_CELLULAR,
118 ASCIIToUTF16(it->name), 118 ASCIIToUTF16(it->name()),
119 WifiNetwork(), 119 WifiNetwork(),
120 *it)); 120 *it));
121 if (network_lib->cellular_name() == it->name) { 121 if (network_lib->cellular_name() == it->name()) {
122 SetNetworksIndices(index, 122 SetNetworksIndices(index,
123 network_lib->cellular_connected(), 123 network_lib->cellular_connected(),
124 network_lib->cellular_connecting()); 124 network_lib->cellular_connecting());
125 } 125 }
126 } 126 }
127 } 127 }
128 128
129 void NetworkList::SetNetworksIndices(int index, 129 void NetworkList::SetNetworksIndices(int index,
130 bool connected, 130 bool connected,
131 bool connecting) { 131 bool connecting) {
132 if (connected_network_index_ != -1 || 132 if (connected_network_index_ != -1 ||
133 connecting_network_index_ != -1 || 133 connecting_network_index_ != -1 ||
134 index < 0 || index >= static_cast<int>(networks_.size())) 134 index < 0 || index >= static_cast<int>(networks_.size()))
135 return; 135 return;
136 136
137 if (connected) { 137 if (connected) {
138 connected_network_index_ = index; 138 connected_network_index_ = index;
139 } else if (connecting) { 139 } else if (connecting) {
140 connecting_network_index_ = index; 140 connecting_network_index_ = index;
141 } 141 }
142 } 142 }
143 143
144 } // namespace chromeos 144 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/network_screen_browsertest.cc ('k') | chrome/browser/chromeos/options/internet_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698