Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/browser/chromeos/login/new_user_view.h

Issue 8436002: [cros] Remove Views implementation for login/OOBE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_NEW_USER_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/memory/weak_ptr.h"
12 #include "base/task.h"
13 #include "chrome/browser/chromeos/login/helper.h"
14 #include "chrome/browser/chromeos/login/language_switch_menu.h"
15 #include "chrome/browser/chromeos/login/user_input.h"
16 #include "views/accelerator.h"
17 #include "views/controls/button/button.h"
18 #include "views/controls/link_listener.h"
19 #include "views/controls/textfield/textfield_controller.h"
20 #include "views/view.h"
21
22 namespace views {
23 class Label;
24 class MenuButton;
25 class NativeTextButton;
26 } // namespace views
27
28 namespace chromeos {
29
30 // View that is used for new user login. It asks for username and password,
31 // allows to specify language preferences or initiate new account creation.
32 class NewUserView : public ThrobberHostView,
33 public UserInput,
34 public views::TextfieldController,
35 public views::LinkListener,
36 public views::ButtonListener {
37 public:
38 // Delegate class to get notifications from the view.
39 class Delegate {
40 public:
41 virtual ~Delegate() {}
42
43 // User provided |username|, |password| and initiated login.
44 virtual void OnLogin(const std::string& username,
45 const std::string& password) = 0;
46
47 // Initiates incognito login.
48 virtual void OnLoginAsGuest() = 0;
49
50 // User initiated new account creation.
51 virtual void OnCreateAccount() = 0;
52
53 // User requested enterprise enrollment.
54 virtual void OnStartEnterpriseEnrollment() = 0;
55
56 // User started typing so clear all error messages.
57 virtual void ClearErrors() = 0;
58
59 // User tries to navigate away from NewUserView pod.
60 virtual void NavigateAway() = 0;
61 };
62
63 NewUserView(Delegate* delegate, bool need_guest_link);
64
65 virtual ~NewUserView();
66
67 // Initialize view layout.
68 void Init();
69
70 // Update strings from the resources. Executed on language change.
71 void UpdateLocalizedStringsAndFonts();
72
73 // Returns bounds of password field in screen coordinates.
74 gfx::Rect GetPasswordBounds() const;
75
76 // Returns bounds of username field in screen coordinates.
77 gfx::Rect GetUsernameBounds() const;
78
79 // views::View:
80 virtual gfx::Size GetPreferredSize();
81 virtual void Layout();
82 virtual void RequestFocus();
83
84 // Setters for textfields.
85 void SetUsername(const std::string& username);
86 void SetPassword(const std::string& password);
87
88 // Attempt to login with the current field values.
89 void Login();
90
91 // views::TextfieldController:
92 // Not thread-safe, by virtue of using SetupSession().
93 virtual bool HandleKeyEvent(views::Textfield* sender,
94 const views::KeyEvent& keystroke);
95 virtual void ContentsChanged(views::Textfield* sender,
96 const string16& new_contents);
97
98 // views::LinkListener:
99 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
100
101 // views::ButtonListener:
102 virtual void ButtonPressed(views::Button* sender, const views::Event& event);
103
104 virtual bool AcceleratorPressed(const views::Accelerator& accelerator);
105
106 // ThrobberHostView:
107 virtual gfx::Rect CalculateThrobberBounds(views::Throbber* throbber);
108
109 // UserInput:
110 virtual void EnableInputControls(bool enabled);
111 virtual void ClearAndFocusControls();
112 virtual void ClearAndFocusPassword();
113 virtual gfx::Rect GetMainInputScreenBounds() const;
114
115 // Navigates "away" to other user pods if allowed.
116 // Returns true if event has been processed.
117 bool NavigateAway();
118
119 protected:
120 // views::View:
121 virtual void ViewHierarchyChanged(bool is_add,
122 views::View *parent,
123 views::View *child);
124 virtual void OnLocaleChanged();
125 void AddChildView(View* view);
126
127 private:
128 // Creates Link control and adds it as a child.
129 views::Link* InitLink(SkColor background_color);
130
131 // Delete and recreate native controls that fail to update preferred size
132 // after text/locale update.
133 void RecreatePeculiarControls();
134
135 // Enable or disable the |sign_in_button_| based on the contents of the
136 // |username_field_| and |password_field_|. If there is text in both the
137 // button is enabled, otherwise it's disabled.
138 void UpdateSignInButtonState();
139
140 // Create view with specified solid background and add it as child.
141 views::View* CreateSplitter(SkColor color);
142
143 // Screen controls.
144 // NOTE: sign_in_button_ and languages_menubutton_ are handled with
145 // special care: they are recreated on any text/locale change
146 // because they are not resized properly.
147 views::Textfield* username_field_;
148 views::Textfield* password_field_;
149 views::Label* title_label_;
150 views::Label* title_hint_label_;
151 views::View* splitter_up1_;
152 views::View* splitter_up2_;
153 views::View* splitter_down1_;
154 views::View* splitter_down2_;
155 views::NativeTextButton* sign_in_button_;
156 views::Link* guest_link_;
157 views::Link* create_account_link_;
158 views::MenuButton* languages_menubutton_;
159
160 views::Accelerator accel_focus_pass_;
161 views::Accelerator accel_focus_user_;
162 views::Accelerator accel_enterprise_enrollment_;
163 views::Accelerator accel_login_off_the_record_;
164 views::Accelerator accel_toggle_accessibility_;
165
166 // Notifications receiver.
167 Delegate* delegate_;
168
169 base::WeakPtrFactory<NewUserView> weak_factory_;
170
171 LanguageSwitchMenu language_switch_menu_;
172
173 // True when login is in process.
174 bool login_in_process_;
175
176 // Whether Guest Mode link is needed.
177 bool need_guest_link_;
178
179 // Whether create account link is needed. Set to false for now but we may
180 // need it back in near future.
181 bool need_create_account_;
182
183 // Ordinal position of controls inside view layout.
184 int languages_menubutton_order_;
185 int sign_in_button_order_;
186
187 DISALLOW_COPY_AND_ASSIGN(NewUserView);
188 };
189
190 } // namespace chromeos
191
192 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/network_selection_view.cc ('k') | chrome/browser/chromeos/login/new_user_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698