| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/ui/request_pin_view.h" | 5 #include "chrome/browser/chromeos/ui/request_pin_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/chromeos/options/passphrase_textfield.h" | 13 #include "chrome/browser/chromeos/options/passphrase_textfield.h" |
| 14 #include "chrome/browser/ui/browser_dialogs.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 15 #include "chrome/grit/theme_resources.h" | 16 #include "chrome/grit/theme_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/controls/textfield/textfield.h" | 21 #include "ui/views/controls/textfield/textfield.h" |
| 21 #include "ui/views/layout/grid_layout.h" | 22 #include "ui/views/layout/grid_layout.h" |
| 22 #include "ui/views/layout/layout_constants.h" | 23 #include "ui/views/layout/layout_constants.h" |
| 23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 24 #include "ui/views/window/dialog_client_view.h" | 25 #include "ui/views/window/dialog_client_view.h" |
| 25 | 26 |
| 26 namespace chromeos { | 27 namespace chromeos { |
| 27 | 28 |
| 28 RequestPinView::RequestPinView(const std::string& extension_name, | 29 RequestPinView::RequestPinView(const std::string& extension_name, |
| 29 RequestPinView::RequestPinCodeType code_type, | 30 RequestPinView::RequestPinCodeType code_type, |
| 30 int attempts_left, | 31 int attempts_left, |
| 31 const RequestPinCallback& callback, | 32 const RequestPinCallback& callback, |
| 32 Delegate* delegate) | 33 Delegate* delegate) |
| 33 : callback_(callback), delegate_(delegate), weak_ptr_factory_(this) { | 34 : callback_(callback), delegate_(delegate), weak_ptr_factory_(this) { |
| 34 DCHECK(code_type != RequestPinCodeType::UNCHANGED); | 35 DCHECK(code_type != RequestPinCodeType::UNCHANGED); |
| 35 DCHECK(delegate); | 36 DCHECK(delegate); |
| 36 Init(); | 37 Init(); |
| 37 SetExtensionName(extension_name); | 38 SetExtensionName(extension_name); |
| 38 const bool accept_input = (attempts_left != 0); | 39 const bool accept_input = (attempts_left != 0); |
| 39 SetDialogParameters(code_type, RequestPinErrorType::NONE, attempts_left, | 40 SetDialogParameters(code_type, RequestPinErrorType::NONE, attempts_left, |
| 40 accept_input); | 41 accept_input); |
| 42 chrome::RecordDialogCreation(chrome::DialogIdentifier::REQUEST_PIN); |
| 41 } | 43 } |
| 42 | 44 |
| 43 // When the parent window is closed while the dialog is active, this object is | 45 // When the parent window is closed while the dialog is active, this object is |
| 44 // destroyed without triggering Accept or Cancel. If the callback_ wasn't called | 46 // destroyed without triggering Accept or Cancel. If the callback_ wasn't called |
| 45 // it needs to send the response. | 47 // it needs to send the response. |
| 46 RequestPinView::~RequestPinView() { | 48 RequestPinView::~RequestPinView() { |
| 47 if (!callback_.is_null()) { | 49 if (!callback_.is_null()) { |
| 48 base::ResetAndReturn(&callback_).Run(base::string16()); | 50 base::ResetAndReturn(&callback_).Run(base::string16()); |
| 49 } | 51 } |
| 50 | 52 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 254 } |
| 253 | 255 |
| 254 error_label_->SetVisible(true); | 256 error_label_->SetVisible(true); |
| 255 error_label_->SetText(error_message); | 257 error_label_->SetText(error_message); |
| 256 error_label_->SetTooltipText(error_message); | 258 error_label_->SetTooltipText(error_message); |
| 257 error_label_->SetEnabledColor(SK_ColorRED); | 259 error_label_->SetEnabledColor(SK_ColorRED); |
| 258 error_label_->SizeToPreferredSize(); | 260 error_label_->SizeToPreferredSize(); |
| 259 } | 261 } |
| 260 | 262 |
| 261 } // namespace chromeos | 263 } // namespace chromeos |
| OLD | NEW |