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_SCREEN_LOCK_VIEW_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCK_VIEW_H_ 7 #pragma once 8 9 #include "chrome/browser/chromeos/login/helper.h" 10 #include "chrome/browser/chromeos/login/user_view.h" 11 #include "content/common/notification_observer.h" 12 #include "content/common/notification_registrar.h" 13 #include "views/controls/textfield/textfield_controller.h" 14 #include "views/view.h" 15 16 namespace views { 17 class ImageView; 18 } // namespace views 19 20 namespace chromeos { 21 22 class ScreenLocker; 23 class UserView; 24 25 namespace test { 26 class ScreenLockerTester; 27 } // namespace test 28 29 // ScreenLockView creates view components necessary to authenticate 30 // a user to unlock the screen. 31 class ScreenLockView : public ThrobberHostView, 32 public views::TextfieldController, 33 public NotificationObserver, 34 public UserView::Delegate { 35 public: 36 explicit ScreenLockView(ScreenLocker* screen_locker); 37 virtual ~ScreenLockView(); 38 39 void Init(); 40 41 // Clears and sets the focus to the password field. 42 void ClearAndSetFocusToPassword(); 43 44 // Enable/Disable signout button. 45 void SetSignoutEnabled(bool enabled); 46 47 // Returns the bounds of the password field in ScreenLocker's coordinate. 48 gfx::Rect GetPasswordBoundsRelativeTo(const views::View* view); 49 50 // views::View: 51 virtual void SetEnabled(bool enabled); 52 virtual void Layout(); 53 virtual gfx::Size GetPreferredSize(); 54 55 // NotificationObserver: 56 virtual void Observe(NotificationType type, 57 const NotificationSource& source, 58 const NotificationDetails& details); 59 60 // views::TextfieldController: 61 virtual void ContentsChanged(views::Textfield* sender, 62 const string16& new_contents); 63 virtual bool HandleKeyEvent(views::Textfield* sender, 64 const views::KeyEvent& keystroke); 65 66 // UserView::Delegate: 67 virtual void OnSignout(); 68 virtual bool IsUserSelected() const { return true; } 69 70 private: 71 friend class test::ScreenLockerTester; 72 73 UserView* user_view_; 74 75 // For editing the password. 76 views::Textfield* password_field_; 77 78 // ScreenLocker is owned by itself. 79 ScreenLocker* screen_locker_; 80 81 NotificationRegistrar registrar_; 82 83 // User's picture, signout button and password field. 84 views::View* main_; 85 86 // Username that overlays on top of user's picture. 87 views::View* username_; 88 89 DISALLOW_COPY_AND_ASSIGN(ScreenLockView); 90 }; 91 92 } // namespace chromeos 93 94 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREEN_LOCK_VIEW_H_ 95