Chromium Code Reviews| 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/cert_library.h" |
| 8 #include "chrome/browser/chromeos/cros/network_library.h" | 8 #include "chrome/browser/chromeos/cros/network_library.h" |
| 9 #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" | 10 #include "chromeos/network/network_state_handler.h" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 | 15 |
| 16 NetworkLoginObserver::NetworkLoginObserver() { | 16 NetworkLoginObserver::NetworkLoginObserver() { |
| 17 CrosLibrary::Get()->GetCertLibrary()->AddObserver(this); | 17 if (CertLibrary::IsInitialized()) |
| 18 CertLibrary::Get()->AddObserver(this); | |
| 18 } | 19 } |
| 19 | 20 |
| 20 NetworkLoginObserver::~NetworkLoginObserver() { | 21 NetworkLoginObserver::~NetworkLoginObserver() { |
| 21 CrosLibrary::Get()->GetCertLibrary()->RemoveObserver(this); | 22 if (CertLibrary::IsInitialized()) |
|
Ryan Sleevi
2013/05/01 18:16:18
What happens if the CertLibrary is initialized aft
stevenjb
2013/05/01 20:47:59
NetworkLoginObserver is owned by NetworkLibrary wh
| |
| 23 CertLibrary::Get()->RemoveObserver(this); | |
| 22 } | 24 } |
| 23 | 25 |
| 24 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { | 26 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { |
| 25 // Check to see if we have any newly failed wifi network. | 27 // Check to see if we have any newly failed wifi network. |
| 26 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 28 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| 27 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); | 29 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); |
| 28 it != wifi_networks.end(); it++) { | 30 it != wifi_networks.end(); it++) { |
| 29 WifiNetwork* wifi = *it; | 31 WifiNetwork* wifi = *it; |
| 30 if (wifi->notify_failure()) { | 32 if (wifi->notify_failure()) { |
| 31 // Display login dialog again for bad_passphrase and bad_wepkey errors. | 33 // Display login dialog again for bad_passphrase and bad_wepkey errors. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 } | 87 } |
| 86 | 88 |
| 87 void NetworkLoginObserver::OnCertificatesLoaded(bool initial_load) { | 89 void NetworkLoginObserver::OnCertificatesLoaded(bool initial_load) { |
| 88 if (initial_load) { | 90 if (initial_load) { |
| 89 // Once certificates have loaded, connect to the "best" available network. | 91 // Once certificates have loaded, connect to the "best" available network. |
| 90 NetworkStateHandler::Get()->ConnectToBestWifiNetwork(); | 92 NetworkStateHandler::Get()->ConnectToBestWifiNetwork(); |
| 91 } | 93 } |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace chromeos | 96 } // namespace chromeos |
| OLD | NEW |