network_selection_view.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
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_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 "views/controls/button/menu_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 protected: 72 // Overridden from views::View. 73 virtual void OnLocaleChanged(); 74 virtual void ViewHierarchyChanged(bool is_add, 75 views::View* parent, 76 views::View* child); 77 78 // LoginHtmlDialog::Delegate implementation: 79 virtual void OnDialogClosed() {} 80 81 private: 82 // Add screen controls to the contents layout specified. 83 // Based on state (connecting to the network or not) 84 // different controls are added. 85 void AddControlsToLayout(const gfx::Size& size, 86 views::GridLayout* contents_layout); 87 88 // Initializes grid layout of the screen. Called on language change too. 89 void InitLayout(); 90 91 // Delete and recreate native controls that 92 // fail to update preferred size after string update. 93 void RecreateNativeControls(); 94 95 // Updates text on label with currently connecting network. 96 void UpdateConnectingNetworkLabel(); 97 98 // View that contains defines screen contents. 99 views::View* contents_view_; 100 101 // Screen controls. 102 views::MenuButton* languages_menubutton_; 103 views::Label* welcome_label_; 104 views::Label* select_language_label_; 105 views::Label* select_network_label_; 106 views::Label* connecting_network_label_; 107 NetworkDropdownButton* network_dropdown_; 108 views::NativeButton* continue_button_; 109 views::Throbber* throbber_; 110 views::Link* proxy_settings_link_; 111 112 // NetworkScreen delegate. 113 NetworkScreenDelegate* delegate_; 114 115 // Id of the network that is in process of connecting. 116 string16 network_id_; 117 118 // Dialog used for to launch proxy settings. 119 scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_; 120 121 DISALLOW_COPY_AND_ASSIGN(NetworkSelectionView); 122}; 123 124} // namespace chromeos 125 126#endif // CHROME_BROWSER_CHROMEOS_LOGIN_NETWORK_SELECTION_VIEW_H_ 127