| 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/network_library.h" | 7 #include "chrome/browser/chromeos/cros/network_library.h" |
| 8 #include "chrome/browser/chromeos/options/network_config_view.h" | 8 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 9 #include "chromeos/network/network_state_handler.h" | 9 #include "chromeos/network/network_state_handler.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| 11 #include "ui/views/widget/widget_delegate.h" | 11 #include "ui/views/widget/widget_delegate.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 NetworkLoginObserver::NetworkLoginObserver() { | 15 NetworkLoginObserver::NetworkLoginObserver() { |
| 16 // NetworkHandler does not get initialized in many unit tests even though | |
| 17 // NetworkLibrary which owns this class does. TODO(stevenjb): Eliminate | |
| 18 // this class along with NetworkLibrary, crbug.com/154852. | |
| 19 if (NetworkHandler::IsInitialized()) | |
| 20 NetworkHandler::Get()->cert_loader()->AddObserver(this); | |
| 21 } | 16 } |
| 22 | 17 |
| 23 NetworkLoginObserver::~NetworkLoginObserver() { | 18 NetworkLoginObserver::~NetworkLoginObserver() { |
| 24 if (NetworkHandler::IsInitialized()) | |
| 25 NetworkHandler::Get()->cert_loader()->RemoveObserver(this); | |
| 26 } | 19 } |
| 27 | 20 |
| 28 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { | 21 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { |
| 29 // Check to see if we have any newly failed wifi network. | 22 // Check to see if we have any newly failed wifi network. |
| 30 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 23 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| 31 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); | 24 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); |
| 32 it != wifi_networks.end(); it++) { | 25 it != wifi_networks.end(); it++) { |
| 33 WifiNetwork* wifi = *it; | 26 WifiNetwork* wifi = *it; |
| 34 if (wifi->notify_failure()) { | 27 if (wifi->notify_failure()) { |
| 35 // Display login dialog again for bad_passphrase and bad_wepkey errors. | 28 // Display login dialog again for bad_passphrase and bad_wepkey errors. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 << ", added: " << vpn->added(); | 74 << ", added: " << vpn->added(); |
| 82 // Display login dialog for any error or newly added network. | 75 // Display login dialog for any error or newly added network. |
| 83 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { | 76 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { |
| 84 NetworkConfigView::Show(vpn, NULL); | 77 NetworkConfigView::Show(vpn, NULL); |
| 85 return; // Only support one failure per notification. | 78 return; // Only support one failure per notification. |
| 86 } | 79 } |
| 87 } | 80 } |
| 88 } | 81 } |
| 89 } | 82 } |
| 90 | 83 |
| 91 void NetworkLoginObserver::OnCertificatesLoaded( | |
| 92 const net::CertificateList& cert_list, | |
| 93 bool initial_load) { | |
| 94 if (initial_load) { | |
| 95 // Once certificates have loaded, connect to the "best" available network. | |
| 96 NetworkHandler::Get()->network_state_handler()->ConnectToBestWifiNetwork(); | |
| 97 } | |
| 98 } | |
| 99 | |
| 100 } // namespace chromeos | 84 } // namespace chromeos |
| OLD | NEW |