| 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/dbus/dbus_thread_manager.h" |
| 11 #include "chromeos/dbus/shill_manager_client.h" |
| 9 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 10 #include "ui/views/widget/widget_delegate.h" | 13 #include "ui/views/widget/widget_delegate.h" |
| 11 | 14 |
| 12 namespace chromeos { | 15 namespace chromeos { |
| 13 | 16 |
| 17 namespace { |
| 18 |
| 19 void ShillErrorCallback(const std::string& error_name, |
| 20 const std::string& error_message) { |
| 21 LOG(ERROR) << "Shill Error calling ConnectToBestServices: " |
| 22 << error_name << " : " << error_message; |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 14 NetworkLoginObserver::NetworkLoginObserver() { | 27 NetworkLoginObserver::NetworkLoginObserver() { |
| 28 if (CrosLibrary::Get()->GetCertLibrary()->CertificatesLoaded()) |
| 29 OnCertificatesLoaded(true); |
| 30 else |
| 31 CrosLibrary::Get()->GetCertLibrary()->AddObserver(this); |
| 15 } | 32 } |
| 16 | 33 |
| 17 NetworkLoginObserver::~NetworkLoginObserver() { | 34 NetworkLoginObserver::~NetworkLoginObserver() { |
| 35 CrosLibrary::Get()->GetCertLibrary()->RemoveObserver(this); |
| 18 } | 36 } |
| 19 | 37 |
| 20 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { | 38 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { |
| 21 // Check to see if we have any newly failed wifi network. | 39 // Check to see if we have any newly failed wifi network. |
| 22 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 40 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| 23 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); | 41 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); |
| 24 it != wifi_networks.end(); it++) { | 42 it != wifi_networks.end(); it++) { |
| 25 WifiNetwork* wifi = *it; | 43 WifiNetwork* wifi = *it; |
| 26 if (wifi->notify_failure()) { | 44 if (wifi->notify_failure()) { |
| 27 // Display login dialog again for bad_passphrase and bad_wepkey errors. | 45 // 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(); | 91 << ", added: " << vpn->added(); |
| 74 // Display login dialog for any error or newly added network. | 92 // Display login dialog for any error or newly added network. |
| 75 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { | 93 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { |
| 76 NetworkConfigView::Show(vpn, NULL); | 94 NetworkConfigView::Show(vpn, NULL); |
| 77 return; // Only support one failure per notification. | 95 return; // Only support one failure per notification. |
| 78 } | 96 } |
| 79 } | 97 } |
| 80 } | 98 } |
| 81 } | 99 } |
| 82 | 100 |
| 101 void NetworkLoginObserver::OnCertificatesLoaded(bool initial_load) { |
| 102 // Once certificates have loaded, signal Shill connect to the "best" |
| 103 // available network. |
| 104 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices( |
| 105 base::Bind(&base::DoNothing), base::Bind(&ShillErrorCallback)); |
| 106 } |
| 107 |
| 83 } // namespace chromeos | 108 } // namespace chromeos |
| OLD | NEW |