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

Unified Diff: ash/login/ui/login_password_view.h

Issue 2896533002: cros: Simple password view for lock. Adds test support. (Closed)
Patch Set: Initial upload Created 3 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: ash/login/ui/login_password_view.h
diff --git a/ash/login/ui/login_password_view.h b/ash/login/ui/login_password_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..7f651487b5cb9ea52d40fa50acb5c2ddba5bc056
--- /dev/null
+++ b/ash/login/ui/login_password_view.h
@@ -0,0 +1,65 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_
+#define ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_
+
+#include "ash/ash_export.h"
+#include "base/strings/string16.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/view.h"
+
+namespace views {
+class ButtonListener;
+class Textfield;
+}
+
+namespace ash {
+
+class ASH_EXPORT LoginPasswordView : public views::View,
+ public views::ButtonListener {
+ public:
+ // TestApi is used for tests to get internal implementation details.
+ class ASH_EXPORT TestApi {
+ public:
+ explicit TestApi(LoginPasswordView* view);
+ ~TestApi();
+
+ views::View* textfield() const;
+ views::View* submit_button() const;
+
+ private:
+ LoginPasswordView* view_;
+ };
+
+ using OnPasswordSubmit = base::Callback<void(const base::string16& password)>;
+
+ explicit LoginPasswordView(const OnPasswordSubmit& on_submit);
+ ~LoginPasswordView() override;
+
+ // views::View:
+ const char* GetClassName() const override;
+ gfx::Size GetPreferredSize() const override;
+ bool OnKeyPressed(const ui::KeyEvent& event) override;
+
+ // views::ButtonListener:
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+
+ private:
+ friend class TestApi;
+
+ // Submits the current password field text to mojo call and resets the text
+ // field.
+ void SubmitPassword();
+
+ OnPasswordSubmit on_submit_;
+ views::Textfield* textfield_;
+ views::View* submit_button_;
+
+ DISALLOW_COPY_AND_ASSIGN(LoginPasswordView);
+};
+
+} // namespace ash
+
+#endif // ASH_LOGIN_UI_LOGIN_PASSWORD_VIEW_H_

Powered by Google App Engine
This is Rietveld 408576698