network_selection_view.h revision 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801
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_SELECTION_VIEW_H_ 6#define CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SELECTION_VIEW_H_ 7#pragma once 8 9#include "base/scoped_ptr.h" 10#include "base/string16.h" 11#include "chrome/browser/chromeos/login/login_html_dialog.h" 12#include "chrome/browser/chromeos/views/dropdown_button.h" 13#include "views/controls/link.h" 14#include "views/view.h" 15#include "views/widget/widget_gtk.h" 16#include "views/window/window_delegate.h" 17 18namespace gfx { 19class Size; 20} // namespace gfx 21 22namespace views { 23class Combobox; 24class GridLayout; 25class Label; 26class NativeButton; 27class Throbber; 28} // namespace views 29 30namespace chromeos { 31 32class NetworkDropdownButton; 33class NetworkScreenDelegate; 34class ScreenObserver; 35 36// View for the network selection/initial welcome screen. 37class NetworkSelectionView : public views::View, 38 public views::LinkController, 39 public LoginHtmlDialog::Delegate { 40 public: 41 explicit NetworkSelectionView(NetworkScreenDelegate* delegate); 42 virtual ~NetworkSelectionView(); 43 44 // Initialize view layout. 45 void Init(); 46 47 // Update strings from the resources. Executed on language change. 48 void UpdateLocalizedStrings(); 49 50 // Returns top level native window for the view. 51 gfx::NativeWindow GetNativeWindow() const; 52 53 // Returns network control view. 54 views::View* GetNetworkControlView() const; 55 56 // Shows network connecting status or network selection otherwise. 57 void ShowConnectingStatus(bool connecting, const string16& network_id); 58 59 // Returns true if only throbber is visible, the view is in waiting status. 60 bool IsConnecting() const; 61 62 // Sets whether continue control is enabled. 63 void EnableContinue(bool enabled); 64 65 // Returns whether continue button is enabled. 66 bool IsContinueEnabled() const; 67 68 // views::LinkController implementation. 69 virtual void LinkActivated(views::Link* source, int); 70 71 // Returns true if any dialog box is currently open? 72 bool is_dialog_open() const { 73 return proxy_settings_dialog_.get() && proxy_settings_dialog_->is_open(); 74 } 75 76 protected: 77 // Overridden from views::View. 78 virtual bool OnKeyPressed(const views::KeyEvent& e); 79 virtual void OnLocaleChanged(); 80 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) { 81 return true; 82 } 83 84 // LoginHtmlDialog::Delegate implementation: 85 virtual void OnDialogClosed() {} 86 87 private: 88 // Add screen controls to the contents layout specified. 89 // Based on state (connecting to the network or not) 90 // different controls are added. 91 void AddControlsToLayout(views::GridLayout* contents_layout); 92 93 // Initializes grid layout of the screen. Called on language change too. 94 void InitLayout(); 95 96 // Delete and recreate native controls that 97 // fail to update preferred size after string update. 98 void RecreateNativeControls(); 99 100 // Updates text on label with currently connecting network. 101 void UpdateConnectingNetworkLabel(); 102 103 // View that defines FillLayout for the whole screen (contents & title). 104 views::View* entire_screen_view_; 105 106 // View that contains screen contents (except title). 107 views::View* contents_view_; 108 109 // Screen controls. 110 DropDownButton* languages_menubutton_; 111 DropDownButton* keyboards_menubutton_; 112 views::Label* welcome_label_; 113 views::Label* select_language_label_; 114 views::Label* select_keyboard_label_; 115 views::Label* select_network_label_; 116 views::Label* connecting_network_label_; 117 NetworkDropdownButton* network_dropdown_; 118 views::NativeButton* continue_button_; 119 views::Throbber* throbber_; 120 views::Link* proxy_settings_link_; 121 bool show_keyboard_button_; 122 123 // NetworkScreen delegate. 124 NetworkScreenDelegate* delegate_; 125 126 // Id of the network that is in process of connecting. 127 string16 network_id_; 128 129 // Dialog used for to launch proxy settings. 130 scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_; 131 132 DISALLOW_COPY_AND_ASSIGN(NetworkSelectionView); 133}; 134 135} // namespace chromeos 136 137#endif // CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SELECTION_VIEW_H_ 138