| 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/browser/ui/browser_dialogs.h" | 
|  | 15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 
| 15 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_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/widget/widget.h" | 23 #include "ui/views/widget/widget.h" | 
| 24 #include "ui/views/window/dialog_client_view.h" | 24 #include "ui/views/window/dialog_client_view.h" | 
| 25 | 25 | 
| 26 namespace chromeos { | 26 namespace chromeos { | 
| 27 | 27 | 
| 28 RequestPinView::RequestPinView(const std::string& extension_name, | 28 RequestPinView::RequestPinView(const std::string& extension_name, | 
| 29                                RequestPinView::RequestPinCodeType code_type, | 29                                RequestPinView::RequestPinCodeType code_type, | 
| 30                                int attempts_left, | 30                                int attempts_left, | 
| 31                                const RequestPinCallback& callback, | 31                                const RequestPinCallback& callback, | 
| 32                                Delegate* delegate) | 32                                Delegate* delegate) | 
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 171                         views::GridLayout::USE_PREF, 0, 0); | 171                         views::GridLayout::USE_PREF, 0, 0); | 
| 172   layout->StartRow(0, column_view_set_id); | 172   layout->StartRow(0, column_view_set_id); | 
| 173 | 173 | 
| 174   // Infomation label. | 174   // Infomation label. | 
| 175   int label_text_id = IDS_REQUEST_PIN_DIALOG_HEADER; | 175   int label_text_id = IDS_REQUEST_PIN_DIALOG_HEADER; | 
| 176   base::string16 label_text = l10n_util::GetStringUTF16(label_text_id); | 176   base::string16 label_text = l10n_util::GetStringUTF16(label_text_id); | 
| 177   header_label_ = new views::Label(label_text); | 177   header_label_ = new views::Label(label_text); | 
| 178   header_label_->SetEnabled(true); | 178   header_label_->SetEnabled(true); | 
| 179   layout->AddView(header_label_); | 179   layout->AddView(header_label_); | 
| 180 | 180 | 
| 181   layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 181   const int related_vertical_spacing = | 
|  | 182       ChromeLayoutProvider::Get()->GetDistanceMetric( | 
|  | 183           views::DISTANCE_RELATED_CONTROL_VERTICAL); | 
|  | 184   layout->AddPaddingRow(0, related_vertical_spacing); | 
| 182 | 185 | 
| 183   column_view_set_id++; | 186   column_view_set_id++; | 
| 184   column_set = layout->AddColumnSet(column_view_set_id); | 187   column_set = layout->AddColumnSet(column_view_set_id); | 
| 185   column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 100, | 188   column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 100, | 
| 186                         views::GridLayout::USE_PREF, 0, 0); | 189                         views::GridLayout::USE_PREF, 0, 0); | 
| 187 | 190 | 
| 188   // Textfield to enter the PIN/PUK. | 191   // Textfield to enter the PIN/PUK. | 
| 189   layout->StartRow(0, column_view_set_id); | 192   layout->StartRow(0, column_view_set_id); | 
| 190   textfield_ = new PassphraseTextfield(); | 193   textfield_ = new PassphraseTextfield(); | 
| 191   textfield_->set_controller(this); | 194   textfield_->set_controller(this); | 
| 192   textfield_->SetEnabled(true); | 195   textfield_->SetEnabled(true); | 
| 193   layout->AddView(textfield_); | 196   layout->AddView(textfield_); | 
| 194 | 197 | 
| 195   layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 198   layout->AddPaddingRow(0, related_vertical_spacing); | 
| 196 | 199 | 
| 197   column_view_set_id++; | 200   column_view_set_id++; | 
| 198   column_set = layout->AddColumnSet(column_view_set_id); | 201   column_set = layout->AddColumnSet(column_view_set_id); | 
| 199   column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 202   column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 
| 200                         views::GridLayout::USE_PREF, 0, 0); | 203                         views::GridLayout::USE_PREF, 0, 0); | 
| 201 | 204 | 
| 202   // Error label. | 205   // Error label. | 
| 203   layout->StartRow(0, column_view_set_id); | 206   layout->StartRow(0, column_view_set_id); | 
| 204   error_label_ = new views::Label(); | 207   error_label_ = new views::Label(); | 
| 205   error_label_->SetVisible(false); | 208   error_label_->SetVisible(false); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 253   } | 256   } | 
| 254 | 257 | 
| 255   error_label_->SetVisible(true); | 258   error_label_->SetVisible(true); | 
| 256   error_label_->SetText(error_message); | 259   error_label_->SetText(error_message); | 
| 257   error_label_->SetTooltipText(error_message); | 260   error_label_->SetTooltipText(error_message); | 
| 258   error_label_->SetEnabledColor(SK_ColorRED); | 261   error_label_->SetEnabledColor(SK_ColorRED); | 
| 259   error_label_->SizeToPreferredSize(); | 262   error_label_->SizeToPreferredSize(); | 
| 260 } | 263 } | 
| 261 | 264 | 
| 262 }  // namespace chromeos | 265 }  // namespace chromeos | 
| OLD | NEW | 
|---|