Chromium Code Reviews| Index: chrome/browser/chromeos/ui/request_pin_view.h |
| diff --git a/chrome/browser/chromeos/ui/request_pin_view.h b/chrome/browser/chromeos/ui/request_pin_view.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99ec369b4b041185b2519b48429ec9b2c492991a |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/ui/request_pin_view.h |
| @@ -0,0 +1,88 @@ |
| +// Copyright (c) 2016 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 CHROME_BROWSER_CHROMEOS_UI_REQUEST_PIN_VIEW_H_ |
| +#define CHROME_BROWSER_CHROMEOS_UI_REQUEST_PIN_VIEW_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/strings/string16.h" |
| +#include "ui/views/controls/textfield/textfield_controller.h" |
| +#include "ui/views/view.h" |
| +#include "ui/views/window/dialog_delegate.h" |
| + |
| +namespace views { |
| +class Label; |
| +} |
| + |
| +namespace chromeos { |
| + |
| +class PassphraseTextfield; |
| + |
| +// A dialog box for requesting PIN code. |
| +class RequestPinView : public views::DialogDelegateView, |
| + public views::TextfieldController { |
| + public: |
| + 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.
|
| + RequestPinView(const std::string& extension_name, |
| + const std::string& dialog_type, |
| + const base::string16& error_message, |
| + bool accept_input, |
| + const RequestPinCallback& callback); |
|
stevenjb
2016/08/09 21:04:39
Document the input params
igorcov1
2016/08/10 18:05:03
Done.
|
| + ~RequestPinView() override; |
| + |
| + // views::TextfieldController |
| + void ContentsChanged(views::Textfield* sender, |
| + const base::string16& new_contents) override; |
| + |
| + // views::DialogDelegateView |
| + bool Cancel() override; |
| + bool Accept() override; |
| + base::string16 GetWindowTitle() const override; |
| + ui::ModalType GetModalType() const override; |
| + views::View* GetInitiallyFocusedView() override; |
| + bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
| + |
| + bool IsLocked(); |
|
stevenjb
2016/08/09 21:04:39
Document new public methods
igorcov1
2016/08/10 18:05:03
Done.
|
| + void SetCallback(const RequestPinCallback& callback); |
| + void SetDialogParameters(const base::string16& error_message, |
| + bool accept_input); |
| + void SetDialogParameters(const std::string& dialog_type, |
| + const base::string16& error_message, |
| + 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
|
| + void SetExtensionName(const std::string& extension_name); |
| + |
| + views::Textfield* textfield_for_testing() { return textfield_; } |
| + views::Label* error_label_for_testing() { return error_label_; } |
| + |
| + private: |
| + // This will initialize the view. |
| + void Init(); |
| + void SetAcceptInput(bool accept_input); |
| + void SetErrorMessage(const base::string16& error_message); |
| + |
| + RequestPinCallback callback_; |
| + base::string16 window_title_; |
| + views::Label* header_label_ = nullptr; |
| + views::Label* textfield_label_ = nullptr; |
| + views::Textfield* textfield_ = nullptr; |
| + views::Label* error_label_ = nullptr; |
| + |
| + // Flag to know when user submitted input and the view is locked, waiting for |
| + // changes from outside. |
| + bool locked_ = false; |
| + |
| + base::WeakPtrFactory<RequestPinView> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RequestPinView); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_UI_REQUEST_PIN_VIEW_H_ |