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/cros_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 "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(NetworkLibrary* netlib) { | 15 NetworkLoginObserver::NetworkLoginObserver(NetworkLibrary* netlib) { |
16 netlib->AddNetworkManagerObserver(this); | 16 netlib->AddNetworkManagerObserver(this); |
17 } | 17 } |
18 | 18 |
19 NetworkLoginObserver::~NetworkLoginObserver() { | 19 NetworkLoginObserver::~NetworkLoginObserver() { |
20 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); | 20 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); |
21 } | 21 } |
22 | 22 |
23 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { | 23 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { |
| 24 // Check to see if we have any newly failed wifi network. |
24 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 25 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
25 const VirtualNetworkVector& virtual_networks = cros->virtual_networks(); | |
26 | |
27 // Check to see if we have any newly failed wifi network. | |
28 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); | 26 for (WifiNetworkVector::const_iterator it = wifi_networks.begin(); |
29 it != wifi_networks.end(); it++) { | 27 it != wifi_networks.end(); it++) { |
30 WifiNetwork* wifi = *it; | 28 WifiNetwork* wifi = *it; |
31 if (wifi->notify_failure()) { | 29 if (wifi->notify_failure()) { |
32 // Display login dialog again for bad_passphrase and bad_wepkey errors. | 30 // Display login dialog again for bad_passphrase and bad_wepkey errors. |
33 // Always re-display for user initiated connections that fail. | 31 // Always re-display for user initiated connections that fail. |
34 // Always re-display the login dialog for encrypted networks that were | 32 // Always re-display the login dialog for encrypted networks that were |
35 // added and failed to connect for any reason. | 33 // added and failed to connect for any reason. |
36 VLOG(1) << "NotifyFailure: " << wifi->name() | 34 VLOG(1) << "NotifyFailure: " << wifi->name() |
37 << ", error: " << wifi->error() | 35 << ", error: " << wifi->error() |
38 << ", added: " << wifi->added(); | 36 << ", added: " << wifi->added(); |
39 if (wifi->error() == ERROR_BAD_PASSPHRASE || | 37 if (wifi->error() == ERROR_BAD_PASSPHRASE || |
40 wifi->error() == ERROR_BAD_WEPKEY || | 38 wifi->error() == ERROR_BAD_WEPKEY || |
41 wifi->connection_started() || | 39 wifi->connection_started() || |
42 (wifi->encrypted() && wifi->added())) { | 40 (wifi->encrypted() && wifi->added())) { |
43 NetworkConfigView::Show(wifi, NULL); | 41 NetworkConfigView::Show(wifi, NULL); |
44 return; // Only support one failure per notification. | 42 return; // Only support one failure per notification. |
45 } | 43 } |
46 } | 44 } |
47 } | 45 } |
| 46 // Check to see if we have any newly failed wimax network. |
| 47 const WimaxNetworkVector& wimax_networks = cros->wimax_networks(); |
| 48 for (WimaxNetworkVector::const_iterator it = wimax_networks.begin(); |
| 49 it != wimax_networks.end(); it++) { |
| 50 WimaxNetwork* wimax = *it; |
| 51 if (wimax->notify_failure()) { |
| 52 // Display login dialog again for bad_passphrase and bad_wepkey errors. |
| 53 // Always re-display for user initiated connections that fail. |
| 54 // Always re-display the login dialog for encrypted networks that were |
| 55 // added and failed to connect for any reason. |
| 56 VLOG(1) << "NotifyFailure: " << wimax->name() |
| 57 << ", error: " << wimax->error() |
| 58 << ", added: " << wimax->added(); |
| 59 if (wimax->error() == ERROR_BAD_PASSPHRASE || |
| 60 wimax->error() == ERROR_BAD_WEPKEY || |
| 61 wimax->connection_started() || |
| 62 (wimax->passphrase_required() && wimax->added())) { |
| 63 NetworkConfigView::Show(wimax, NULL); |
| 64 return; // Only support one failure per notification. |
| 65 } |
| 66 } |
| 67 } |
48 // Check to see if we have any newly failed virtual network. | 68 // Check to see if we have any newly failed virtual network. |
| 69 const VirtualNetworkVector& virtual_networks = cros->virtual_networks(); |
49 for (VirtualNetworkVector::const_iterator it = virtual_networks.begin(); | 70 for (VirtualNetworkVector::const_iterator it = virtual_networks.begin(); |
50 it != virtual_networks.end(); it++) { | 71 it != virtual_networks.end(); it++) { |
51 VirtualNetwork* vpn = *it; | 72 VirtualNetwork* vpn = *it; |
52 if (vpn->notify_failure()) { | 73 if (vpn->notify_failure()) { |
53 VLOG(1) << "NotifyFailure: " << vpn->name() | 74 VLOG(1) << "NotifyFailure: " << vpn->name() |
54 << ", error: " << vpn->error() | 75 << ", error: " << vpn->error() |
55 << ", added: " << vpn->added(); | 76 << ", added: " << vpn->added(); |
56 // Display login dialog for any error or newly added network. | 77 // Display login dialog for any error or newly added network. |
57 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { | 78 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { |
58 NetworkConfigView::Show(vpn, NULL); | 79 NetworkConfigView::Show(vpn, NULL); |
59 return; // Only support one failure per notification. | 80 return; // Only support one failure per notification. |
60 } | 81 } |
61 } | 82 } |
62 } | 83 } |
63 } | 84 } |
64 | 85 |
65 } // namespace chromeos | 86 } // namespace chromeos |
OLD | NEW |