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