| 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/chromeos/network_login_observer.h" | 5 #include "chrome/browser/chromeos/network_login_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 7 #include "chrome/browser/chromeos/cros/network_library.h" | 8 #include "chrome/browser/chromeos/cros/network_library.h" |
| 8 #include "chrome/browser/chromeos/options/network_config_view.h" | 9 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 10 #include "chromeos/network/network_state_handler.h" |
| 9 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 10 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 11 | 13 |
| 12 namespace chromeos { | 14 namespace chromeos { |
| 13 | 15 |
| 14 NetworkLoginObserver::NetworkLoginObserver() { | 16 NetworkLoginObserver::NetworkLoginObserver() { |
| 17 CrosLibrary::Get()->GetCertLibrary()->AddObserver(this); |
| 15 } | 18 } |
| 16 | 19 |
| 17 NetworkLoginObserver::~NetworkLoginObserver() { | 20 NetworkLoginObserver::~NetworkLoginObserver() { |
| 21 CrosLibrary::Get()->GetCertLibrary()->RemoveObserver(this); |
| 18 } | 22 } |
| 19 | 23 |
| 20 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { | 24 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { |
| 21 // Check to see if we have any newly failed wifi network. | 25 // Check to see if we have any newly failed wifi network. |
| 22 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 26 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| 23 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); | 27 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); |
| 24 it != wifi_networks.end(); it++) { | 28 it != wifi_networks.end(); it++) { |
| 25 WifiNetwork* wifi = *it; | 29 WifiNetwork* wifi = *it; |
| 26 if (wifi->notify_failure()) { | 30 if (wifi->notify_failure()) { |
| 27 // Display login dialog again for bad_passphrase and bad_wepkey errors. | 31 // Display login dialog again for bad_passphrase and bad_wepkey errors. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 << ", added: " << vpn->added(); | 77 << ", added: " << vpn->added(); |
| 74 // Display login dialog for any error or newly added network. | 78 // Display login dialog for any error or newly added network. |
| 75 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { | 79 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { |
| 76 NetworkConfigView::Show(vpn, NULL); | 80 NetworkConfigView::Show(vpn, NULL); |
| 77 return; // Only support one failure per notification. | 81 return; // Only support one failure per notification. |
| 78 } | 82 } |
| 79 } | 83 } |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 | 86 |
| 87 void NetworkLoginObserver::OnCertificatesLoaded(bool initial_load) { |
| 88 // Once certificates have loaded, connect to the "best" available network. |
| 89 NetworkStateHandler::Get()->ConnectToBestWifiNetwork(); |
| 90 } |
| 91 |
| 83 } // namespace chromeos | 92 } // namespace chromeos |
| OLD | NEW |