OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_ |
| 6 #define ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_ |
| 7 |
| 8 #include "ash/ash_export.h" |
| 9 #include "base/strings/string16.h" |
| 10 #include "ui/views/controls/button/button.h" |
| 11 #include "ui/views/view.h" |
| 12 |
| 13 namespace views { |
| 14 class ButtonListener; |
| 15 class Textfield; |
| 16 } // namespace views |
| 17 |
| 18 namespace ash { |
| 19 |
| 20 // Contains a textfield instance with a submit button. The user can type a |
| 21 // password into the textfield and hit enter to submit. |
| 22 // |
| 23 // The password view looks like this: |
| 24 // |
| 25 // * * * * * * => |
| 26 // ------------------ |
| 27 class ASH_EXPORT LoginPasswordView : public views::View, |
| 28 public views::ButtonListener { |
| 29 public: |
| 30 // TestApi is used for tests to get internal implementation details. |
| 31 class ASH_EXPORT TestApi { |
| 32 public: |
| 33 explicit TestApi(LoginPasswordView* view); |
| 34 ~TestApi(); |
| 35 |
| 36 views::View* textfield() const; |
| 37 views::View* submit_button() const; |
| 38 |
| 39 private: |
| 40 LoginPasswordView* view_; |
| 41 }; |
| 42 |
| 43 using OnPasswordSubmit = |
| 44 base::RepeatingCallback<void(const base::string16& password)>; |
| 45 |
| 46 // |on_submit| is called when the user hits enter or pressed the submit arrow. |
| 47 // Must not be null. |
| 48 explicit LoginPasswordView(const OnPasswordSubmit& on_submit); |
| 49 ~LoginPasswordView() override; |
| 50 |
| 51 // views::View: |
| 52 const char* GetClassName() const override; |
| 53 gfx::Size CalculatePreferredSize() const override; |
| 54 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 55 |
| 56 // views::ButtonListener: |
| 57 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 58 |
| 59 private: |
| 60 friend class TestApi; |
| 61 |
| 62 // Submits the current password field text to mojo call and resets the text |
| 63 // field. |
| 64 void SubmitPassword(); |
| 65 |
| 66 OnPasswordSubmit on_submit_; |
| 67 views::Textfield* textfield_; |
| 68 views::View* submit_button_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(LoginPasswordView); |
| 71 }; |
| 72 |
| 73 } // namespace ash |
| 74 |
| 75 #endif // ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_ |
OLD | NEW |