• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_
7 #pragma once
8 
9 #include "base/memory/ref_counted.h"
10 #include "base/string16.h"
11 #include "base/task.h"
12 #include "base/timer.h"
13 #include "chrome/browser/chromeos/cros/network_library.h"
14 #include "chrome/browser/chromeos/login/keyboard_switch_menu.h"
15 #include "chrome/browser/chromeos/login/language_switch_menu.h"
16 #include "chrome/browser/chromeos/login/message_bubble.h"
17 #include "chrome/browser/chromeos/login/network_screen_delegate.h"
18 #include "chrome/browser/chromeos/login/view_screen.h"
19 #include "chrome/browser/chromeos/options/network_config_view.h"
20 
21 class WizardScreenDelegate;
22 
23 namespace chromeos {
24 
25 class HelpAppLauncher;
26 class NetworkSelectionView;
27 
28 class NetworkScreen : public ViewScreen<NetworkSelectionView>,
29                       public MessageBubbleDelegate,
30                       public NetworkScreenDelegate {
31  public:
32   explicit NetworkScreen(WizardScreenDelegate* delegate);
33   virtual ~NetworkScreen();
34 
35   // NetworkScreenDelegate implementation:
36   virtual void ClearErrors();
is_error_shown()37   virtual bool is_error_shown() { return bubble_ != NULL; }
language_switch_menu()38   virtual LanguageSwitchMenu* language_switch_menu() {
39     return &language_switch_menu_;
40   }
keyboard_switch_menu()41   virtual KeyboardSwitchMenu* keyboard_switch_menu() {
42     return &keyboard_switch_menu_;
43   }
size()44   virtual gfx::Size size() const { return GetScreenSize(); }
45 
46   // views::ButtonListener implementation:
47   virtual void ButtonPressed(views::Button* sender, const views::Event& event);
48 
49   // NetworkLibrary::NetworkManagerObserver implementation:
50   virtual void OnNetworkManagerChanged(NetworkLibrary* network_lib);
51 
52  protected:
53   // Subscribes NetworkScreen to the network change notification,
54   // forces refresh of current network state.
55   void Refresh();
56 
57  private:
58   FRIEND_TEST(NetworkScreenTest, Timeout);
59 
60   // ViewScreen implementation:
61   virtual void CreateView();
62   virtual NetworkSelectionView* AllocateView();
63 
64   // Overridden from views::BubbleDelegate.
BubbleClosing(Bubble * bubble,bool closed_by_escape)65   virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) {
66     bubble_ = NULL;
67   }
CloseOnEscape()68   virtual bool CloseOnEscape() { return true; }
FadeInOnShow()69   virtual bool FadeInOnShow() { return false; }
70   virtual void OnHelpLinkActivated();
71 
72   // Subscribes to network change notifications.
73   void SubscribeNetworkNotification();
74 
75   // Unsubscribes from network change notifications.
76   void UnsubscribeNetworkNotification();
77 
78   // Notifies wizard on successful connection.
79   void NotifyOnConnection();
80 
81   // Called by |connection_timer_| when connection to the network timed out.
82   void OnConnectionTimeout();
83 
84   // Update UI based on current network status.
85   void UpdateStatus(NetworkLibrary* network);
86 
87   // Stops waiting for network to connect.
88   void StopWaitingForConnection(const string16& network_id);
89 
90   // Starts waiting for network connection. Shows spinner.
91   void WaitForConnection(const string16& network_id);
92 
93   // True if subscribed to network change notification.
94   bool is_network_subscribed_;
95 
96   // ID of the the network that we are waiting for.
97   string16 network_id_;
98 
99   // True if user pressed continue button so we should proceed with OOBE
100   // as soon as we are connected.
101   bool continue_pressed_;
102 
103   // Timer for connection timeout.
104   base::OneShotTimer<NetworkScreen> connection_timer_;
105 
106   LanguageSwitchMenu language_switch_menu_;
107   KeyboardSwitchMenu keyboard_switch_menu_;
108 
109   // Pointer to shown message bubble. We don't need to delete it because
110   // it will be deleted on bubble closing.
111   MessageBubble* bubble_;
112 
113   // Help application used for help dialogs.
114   scoped_refptr<HelpAppLauncher> help_app_;
115 
116   DISALLOW_COPY_AND_ASSIGN(NetworkScreen);
117 };
118 
119 }  // namespace chromeos
120 
121 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SCREEN_H_
122