network_screen.h revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
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 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/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/network_list.h" 20#include "chrome/browser/chromeos/options/network_config_view.h" 21 22class WizardScreenDelegate; 23 24namespace chromeos { 25 26class HelpAppLauncher; 27class NetworkSelectionView; 28 29class NetworkScreen : public ViewScreen<NetworkSelectionView>, 30 public MessageBubbleDelegate, 31 public NetworkScreenDelegate { 32 public: 33 explicit NetworkScreen(WizardScreenDelegate* delegate); 34 virtual ~NetworkScreen(); 35 36 // NetworkScreenDelegate implementation: 37 virtual void ClearErrors(); 38 virtual bool is_error_shown() { return bubble_ != NULL; } 39 virtual LanguageSwitchMenu* language_switch_menu() { 40 return &language_switch_menu_; 41 } 42 virtual KeyboardSwitchMenu* keyboard_switch_menu() { 43 return &keyboard_switch_menu_; 44 } 45 virtual gfx::Size size() const { return GetScreenSize(); } 46 47 // views::ButtonListener implementation: 48 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 49 50 // NetworkLibrary::NetworkManagerObserver implementation: 51 virtual void OnNetworkManagerChanged(NetworkLibrary* network_lib); 52 53 protected: 54 // Subscribes NetworkScreen to the network change notification, 55 // forces refresh of current network state. 56 void Refresh(); 57 58 private: 59 FRIEND_TEST(NetworkScreenTest, Timeout); 60 61 // ViewScreen implementation: 62 virtual void CreateView(); 63 virtual NetworkSelectionView* AllocateView(); 64 65 // Overridden from views::InfoBubbleDelegate. 66 virtual void InfoBubbleClosing(InfoBubble* info_bubble, 67 bool closed_by_escape) { bubble_ = NULL; } 68 virtual bool CloseOnEscape() { return true; } 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