OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "chrome/browser/chromeos/cros/network_library.h" | 12 #include "chrome/browser/chromeos/cros/network_library.h" |
13 #include "chrome/browser/chromeos/login/network_screen_delegate.h" | 13 #include "chrome/browser/chromeos/login/network_screen_delegate.h" |
14 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 14 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
15 #include "chrome/browser/chromeos/login/view_screen.h" | 15 #include "chrome/browser/chromeos/login/view_screen.h" |
16 #include "chrome/browser/chromeos/network_list.h" | 16 #include "chrome/browser/chromeos/network_list.h" |
17 #include "chrome/browser/chromeos/options/network_config_view.h" | 17 #include "chrome/browser/chromeos/options/network_config_view.h" |
18 | 18 |
19 class WizardScreenDelegate; | 19 class WizardScreenDelegate; |
20 | 20 |
21 namespace chromeos { | 21 namespace chromeos { |
22 | 22 |
23 class NetworkSelectionView; | 23 class NetworkSelectionView; |
24 | 24 |
25 class NetworkScreen : public ViewScreen<NetworkSelectionView>, | 25 class NetworkScreen : public ViewScreen<NetworkSelectionView>, |
26 public NetworkScreenDelegate, | 26 public NetworkScreenDelegate { |
27 public NetworkConfigView::Delegate { | |
28 public: | 27 public: |
29 NetworkScreen(WizardScreenDelegate* delegate, bool is_out_of_box); | 28 explicit NetworkScreen(WizardScreenDelegate* delegate); |
30 virtual ~NetworkScreen(); | 29 virtual ~NetworkScreen(); |
31 | 30 |
32 // NetworkScreenDelegate implementation: | 31 // NetworkScreenDelegate implementation: |
33 virtual LanguageSwitchMenu* language_switch_menu() { | 32 virtual LanguageSwitchMenu* language_switch_menu() { |
34 return &language_switch_menu_; | 33 return &language_switch_menu_; |
35 } | 34 } |
36 | 35 |
37 // ComboboxModel implementation: | |
38 virtual int GetItemCount(); | |
39 virtual string16 GetItemAt(int index); | |
40 | |
41 // views::Combobox::Listener implementation: | |
42 virtual void ItemChanged(views::Combobox* sender, | |
43 int prev_index, | |
44 int new_index); | |
45 | |
46 // views::ButtonListener implementation: | 36 // views::ButtonListener implementation: |
47 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 37 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
48 | 38 |
49 // NetworkLibrary::Observer implementation: | 39 // NetworkLibrary::Observer implementation: |
50 virtual void NetworkChanged(NetworkLibrary* network_lib); | 40 virtual void NetworkChanged(NetworkLibrary* network_lib); |
51 | 41 |
52 // NetworkConfigView::Delegate implementation: | |
53 virtual void OnDialogAccepted(); | |
54 virtual void OnDialogCancelled(); | |
55 | |
56 protected: | 42 protected: |
57 // Subscribes NetworkScreen to the network change notification, | 43 // Subscribes NetworkScreen to the network change notification, |
58 // forces refresh of current network state. | 44 // forces refresh of current network state. |
59 void Refresh(); | 45 void Refresh(); |
60 | 46 |
61 private: | 47 private: |
62 // ViewScreen implementation: | 48 // ViewScreen implementation: |
63 virtual void CreateView(); | 49 virtual void CreateView(); |
64 virtual NetworkSelectionView* AllocateView(); | 50 virtual NetworkSelectionView* AllocateView(); |
65 | 51 |
66 // Connects to network if needed and updates screen state. | |
67 void ConnectToNetwork(NetworkList::NetworkType type, const string16& id); | |
68 | |
69 // Enables WiFi device. | |
70 void EnableWiFi(); | |
71 | |
72 // Subscribes to network change notifications. | 52 // Subscribes to network change notifications. |
73 void SubscribeNetworkNotification(); | 53 void SubscribeNetworkNotification(); |
74 | 54 |
75 // Unsubscribes from network change notifications. | 55 // Unsubscribes from network change notifications. |
76 void UnsubscribeNetworkNotification(); | 56 void UnsubscribeNetworkNotification(); |
77 | 57 |
78 // Returns currently selected network in the combobox. | |
79 NetworkList::NetworkItem* GetSelectedNetwork(); | |
80 | |
81 // Notifies wizard on successful connection. | 58 // Notifies wizard on successful connection. |
82 void NotifyOnConnection(); | 59 void NotifyOnConnection(); |
83 | 60 |
84 // Called by |connection_timer_| when connection to the network timed out. | 61 // Called by |connection_timer_| when connection to the network timed out. |
85 void OnConnectionTimeout(); | 62 void OnConnectionTimeout(); |
86 | 63 |
87 // Opens password dialog for the encrypted networks. | 64 // Update UI based on current network status. |
88 void OpenPasswordDialog(WifiNetwork network); | 65 void UpdateStatus(NetworkLibrary* network); |
89 | |
90 // Selects network by type and id. | |
91 void SelectNetwork(NetworkList::NetworkType type, | |
92 const string16& id); | |
93 | |
94 // Switches connecting status based on |is_waiting_for_connect_|. | |
95 void ShowConnectingStatus(); | |
96 | 66 |
97 // Stops waiting for network to connect. | 67 // Stops waiting for network to connect. |
98 // If |show_combobox| is false, spinner is left on screen. Used on exit. | 68 void StopWaitingForConnection(const string16& network_id); |
99 void StopWaitingForConnection(bool show_combobox); | |
100 | 69 |
101 // Starts waiting for network connection. Shows spinner. | 70 // Starts waiting for network connection. Shows spinner. |
102 void WaitForConnection(const NetworkList::NetworkItem* network); | 71 void WaitForConnection(const string16& network_id); |
103 | 72 |
104 // True if subscribed to network change notification. | 73 // True if subscribed to network change notification. |
105 bool is_network_subscribed_; | 74 bool is_network_subscribed_; |
106 | 75 |
107 // Networks model, contains current state of available networks. | 76 // ID of the the network that we are waiting for. |
108 NetworkList networks_; | 77 string16 network_id_; |
109 | 78 |
110 // True if WiFi is currently disabled. | 79 // True if user pressed continue button so we should proceed with OOBE |
111 bool wifi_disabled_; | 80 // as soon as we are connected. |
112 | |
113 // True if full OOBE flow should be shown. | |
114 bool is_out_of_box_; | |
115 | |
116 // True if we're waiting for the selected network being connected. | |
117 bool is_waiting_for_connect_; | |
118 | |
119 // True if "Continue" button was pressed. | |
120 // Set only when there's a network selected. | |
121 bool continue_pressed_; | 81 bool continue_pressed_; |
122 | 82 |
123 // True if Ethernet was already preselected in combobox. | |
124 bool ethernet_preselected_; | |
125 | |
126 // Timer for connection timeout. | 83 // Timer for connection timeout. |
127 base::OneShotTimer<NetworkScreen> connection_timer_; | 84 base::OneShotTimer<NetworkScreen> connection_timer_; |
128 | 85 |
129 // Network which we're connecting to. | |
130 NetworkList::NetworkItem connecting_network_; | |
131 | |
132 ScopedRunnableMethodFactory<NetworkScreen> task_factory_; | |
133 LanguageSwitchMenu language_switch_menu_; | 86 LanguageSwitchMenu language_switch_menu_; |
134 | 87 |
135 DISALLOW_COPY_AND_ASSIGN(NetworkScreen); | 88 DISALLOW_COPY_AND_ASSIGN(NetworkScreen); |
136 }; | 89 }; |
137 | 90 |
138 } // namespace chromeos | 91 } // namespace chromeos |
139 | 92 |
140 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_ | 93 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_ |
OLD | NEW |