| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |