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