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