OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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_UI_REQUEST_PIN_VIEW_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_UI_REQUEST_PIN_VIEW_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 #include "base/callback.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "base/macros.h" | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "base/strings/string16.h" | |
16 #include "ui/views/controls/textfield/textfield_controller.h" | |
17 #include "ui/views/view.h" | |
18 #include "ui/views/window/dialog_delegate.h" | |
19 | |
20 namespace views { | |
21 class Label; | |
22 } | |
23 | |
24 namespace chromeos { | |
25 | |
26 class PassphraseTextfield; | |
27 | |
28 // A dialog box for requesting PIN code. | |
29 class RequestPinView : public views::DialogDelegateView, | |
30 public views::TextfieldController { | |
31 public: | |
32 using RequestPinCallback = base::Callback<void(const base::string16&)>; | |
stevenjb
2016/08/09 21:04:39
Document the callback arg
igorcov1
2016/08/10 18:05:04
Done.
| |
33 RequestPinView(const std::string& extension_name, | |
34 const std::string& dialog_type, | |
35 const base::string16& error_message, | |
36 bool accept_input, | |
37 const RequestPinCallback& callback); | |
stevenjb
2016/08/09 21:04:39
Document the input params
igorcov1
2016/08/10 18:05:03
Done.
| |
38 ~RequestPinView() override; | |
39 | |
40 // views::TextfieldController | |
41 void ContentsChanged(views::Textfield* sender, | |
42 const base::string16& new_contents) override; | |
43 | |
44 // views::DialogDelegateView | |
45 bool Cancel() override; | |
46 bool Accept() override; | |
47 base::string16 GetWindowTitle() const override; | |
48 ui::ModalType GetModalType() const override; | |
49 views::View* GetInitiallyFocusedView() override; | |
50 bool IsDialogButtonEnabled(ui::DialogButton button) const override; | |
51 | |
52 bool IsLocked(); | |
stevenjb
2016/08/09 21:04:39
Document new public methods
igorcov1
2016/08/10 18:05:03
Done.
| |
53 void SetCallback(const RequestPinCallback& callback); | |
54 void SetDialogParameters(const base::string16& error_message, | |
55 bool accept_input); | |
56 void SetDialogParameters(const std::string& dialog_type, | |
57 const base::string16& error_message, | |
58 bool accept_input); | |
stevenjb
2016/08/09 21:04:39
Avoid multiple methods with the same name, it is c
igorcov1
2016/08/10 18:05:03
Done. I've changed the dialog_type to an enum, as
| |
59 void SetExtensionName(const std::string& extension_name); | |
60 | |
61 views::Textfield* textfield_for_testing() { return textfield_; } | |
62 views::Label* error_label_for_testing() { return error_label_; } | |
63 | |
64 private: | |
65 // This will initialize the view. | |
66 void Init(); | |
67 void SetAcceptInput(bool accept_input); | |
68 void SetErrorMessage(const base::string16& error_message); | |
69 | |
70 RequestPinCallback callback_; | |
71 base::string16 window_title_; | |
72 views::Label* header_label_ = nullptr; | |
73 views::Label* textfield_label_ = nullptr; | |
74 views::Textfield* textfield_ = nullptr; | |
75 views::Label* error_label_ = nullptr; | |
76 | |
77 // Flag to know when user submitted input and the view is locked, waiting for | |
78 // changes from outside. | |
79 bool locked_ = false; | |
80 | |
81 base::WeakPtrFactory<RequestPinView> weak_ptr_factory_; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(RequestPinView); | |
84 }; | |
85 | |
86 } // namespace chromeos | |
87 | |
88 #endif // CHROME_BROWSER_CHROMEOS_UI_REQUEST_PIN_VIEW_H_ | |
OLD | NEW |