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/status/network_menu.h" | 5 #include "chrome/browser/chromeos/status/network_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 if (wifi->favorite()) { | 139 if (wifi->favorite()) { |
140 info->passphrase = wifi->passphrase(); | 140 info->passphrase = wifi->passphrase(); |
141 info->need_passphrase = false; | 141 info->need_passphrase = false; |
142 } | 142 } |
143 } else { | 143 } else { |
144 info->need_passphrase = false; | 144 info->need_passphrase = false; |
145 } | 145 } |
146 info->ip_address = wifi->ip_address(); | 146 info->ip_address = wifi->ip_address(); |
147 info->remembered = wifi->favorite(); | 147 info->remembered = wifi->favorite(); |
| 148 info->auto_connect = info->remembered ? wifi->auto_connect() : true; |
148 } else { | 149 } else { |
149 res = false; // Network not found, hide entry. | 150 res = false; // Network not found, hide entry. |
150 } | 151 } |
151 } else if (flags & FLAG_CELLULAR) { | 152 } else if (flags & FLAG_CELLULAR) { |
152 CellularNetwork* cellular = cros->FindCellularNetworkByPath( | 153 CellularNetwork* cellular = cros->FindCellularNetworkByPath( |
153 menu_items_[index].wireless_path); | 154 menu_items_[index].wireless_path); |
154 if (cellular) { | 155 if (cellular) { |
155 info->network_type = kNetworkTypeCellular; | 156 info->network_type = kNetworkTypeCellular; |
156 if (cros->cellular_network() && cellular->service_path() == | 157 if (cros->cellular_network() && cellular->service_path() == |
157 cros->cellular_network()->service_path()) { | 158 cros->cellular_network()->service_path()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 info->remembered = true; | 194 info->remembered = true; |
194 } else { | 195 } else { |
195 // Not a network, e.g options, separator. | 196 // Not a network, e.g options, separator. |
196 } | 197 } |
197 return res; | 198 return res; |
198 } | 199 } |
199 | 200 |
200 bool NetworkMenu::ConnectToNetworkAt(int index, | 201 bool NetworkMenu::ConnectToNetworkAt(int index, |
201 const std::string& passphrase, | 202 const std::string& passphrase, |
202 const std::string& ssid, | 203 const std::string& ssid, |
203 int remember) const { | 204 int auto_connect) const { |
204 int flags = menu_items_[index].flags; | 205 int flags = menu_items_[index].flags; |
205 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 206 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
206 if (flags & FLAG_WIFI) { | 207 if (flags & FLAG_WIFI) { |
207 WifiNetwork* wifi = cros->FindWifiNetworkByPath( | 208 WifiNetwork* wifi = cros->FindWifiNetworkByPath( |
208 menu_items_[index].wireless_path); | 209 menu_items_[index].wireless_path); |
209 if (wifi) { | 210 if (wifi) { |
210 // Connect or reconnect. | 211 // Connect or reconnect. |
211 if (remember >= 0) | 212 if (auto_connect >= 0) |
212 wifi->set_favorite(remember ? true : false); | 213 wifi->set_auto_connect(auto_connect ? true : false); |
213 if (cros->wifi_network() && | 214 if (cros->wifi_network() && |
214 wifi->service_path() == cros->wifi_network()->service_path()) { | 215 wifi->service_path() == cros->wifi_network()->service_path()) { |
215 // Show the config settings for the active network. | 216 // Show the config settings for the active network. |
216 ShowWifi(wifi, false); | 217 ShowWifi(wifi, false); |
217 return true; | 218 return true; |
218 } | 219 } |
219 bool connected = false; | 220 bool connected = false; |
220 if (wifi->encrypted()) { | 221 if (wifi->encrypted()) { |
221 if (wifi->IsCertificateLoaded()) { | 222 if (wifi->IsCertificateLoaded()) { |
222 connected = cros->ConnectToWifiNetwork( | 223 connected = cros->ConnectToWifiNetwork( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 273 } |
273 } | 274 } |
274 } else { | 275 } else { |
275 // If we are attempting to connect to a network that no longer exists, | 276 // If we are attempting to connect to a network that no longer exists, |
276 // display a notification. | 277 // display a notification. |
277 // TODO(stevenjb): Show notification. | 278 // TODO(stevenjb): Show notification. |
278 } | 279 } |
279 } else if (flags & FLAG_OTHER_NETWORK) { | 280 } else if (flags & FLAG_OTHER_NETWORK) { |
280 bool connected = false; | 281 bool connected = false; |
281 if (MenuUI::IsEnabled()) { | 282 if (MenuUI::IsEnabled()) { |
282 bool favorite = remember == 0 ? false : true; // default is true | 283 // default is true |
| 284 bool auto_connect_bool = auto_connect == 0 ? false : true; |
283 connected = cros->ConnectToWifiNetwork( | 285 connected = cros->ConnectToWifiNetwork( |
284 passphrase.empty() ? SECURITY_NONE : SECURITY_UNKNOWN, | 286 passphrase.empty() ? SECURITY_NONE : SECURITY_UNKNOWN, |
285 ssid, passphrase, std::string(), std::string(), favorite); | 287 ssid, passphrase, std::string(), std::string(), auto_connect_bool); |
286 } | 288 } |
287 if (!connected) { | 289 if (!connected) { |
288 ShowOther(); | 290 ShowOther(); |
289 } | 291 } |
290 } | 292 } |
291 return true; | 293 return true; |
292 } | 294 } |
293 | 295 |
294 //////////////////////////////////////////////////////////////////////////////// | 296 //////////////////////////////////////////////////////////////////////////////// |
295 // NetworkMenu, menus::MenuModel implementation: | 297 // NetworkMenu, menus::MenuModel implementation: |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 chromeos::TYPE_WIFI); | 809 chromeos::TYPE_WIFI); |
808 browser->ShowOptionsTab(page); | 810 browser->ShowOptionsTab(page); |
809 } | 811 } |
810 } else { | 812 } else { |
811 const bool kFocusLogin = true; | 813 const bool kFocusLogin = true; |
812 ShowNetworkConfigView(new NetworkConfigView(), kFocusLogin); | 814 ShowNetworkConfigView(new NetworkConfigView(), kFocusLogin); |
813 } | 815 } |
814 } | 816 } |
815 | 817 |
816 } // namespace chromeos | 818 } // namespace chromeos |
OLD | NEW |