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