OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/crypto_module_password_dialog_view.h" | 5 #include "chrome/browser/ui/views/crypto_module_password_dialog_view.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
| 9 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
9 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
10 #include "components/strings/grit/components_strings.h" | 11 #include "components/strings/grit/components_strings.h" |
11 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
12 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
13 #include "ui/views/controls/label.h" | 14 #include "ui/views/controls/label.h" |
14 #include "ui/views/controls/textfield/textfield.h" | 15 #include "ui/views/controls/textfield/textfield.h" |
15 #include "ui/views/layout/grid_layout.h" | 16 #include "ui/views/layout/grid_layout.h" |
16 #include "ui/views/layout/layout_constants.h" | |
17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
18 | 18 |
19 namespace chrome { | 19 namespace chrome { |
20 | 20 |
21 //////////////////////////////////////////////////////////////////////////////// | 21 //////////////////////////////////////////////////////////////////////////////// |
22 // CryptoModulePasswordDialogView, public: | 22 // CryptoModulePasswordDialogView, public: |
23 | 23 |
24 CryptoModulePasswordDialogView::CryptoModulePasswordDialogView( | 24 CryptoModulePasswordDialogView::CryptoModulePasswordDialogView( |
25 const std::string& slot_name, | 25 const std::string& slot_name, |
26 CryptoModulePasswordReason reason, | 26 CryptoModulePasswordReason reason, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 reason_label_ = new views::Label(base::UTF8ToUTF16(text)); | 116 reason_label_ = new views::Label(base::UTF8ToUTF16(text)); |
117 reason_label_->SetMultiLine(true); | 117 reason_label_->SetMultiLine(true); |
118 | 118 |
119 password_label_ = new views::Label(l10n_util::GetStringUTF16( | 119 password_label_ = new views::Label(l10n_util::GetStringUTF16( |
120 IDS_CRYPTO_MODULE_AUTH_DIALOG_PASSWORD_FIELD)); | 120 IDS_CRYPTO_MODULE_AUTH_DIALOG_PASSWORD_FIELD)); |
121 | 121 |
122 password_entry_ = new views::Textfield(); | 122 password_entry_ = new views::Textfield(); |
123 password_entry_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 123 password_entry_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
124 password_entry_->set_controller(this); | 124 password_entry_->set_controller(this); |
125 | 125 |
| 126 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 127 |
126 views::GridLayout* layout = views::GridLayout::CreatePanel(this); | 128 views::GridLayout* layout = views::GridLayout::CreatePanel(this); |
127 | 129 |
128 views::ColumnSet* reason_column_set = layout->AddColumnSet(0); | 130 views::ColumnSet* reason_column_set = layout->AddColumnSet(0); |
129 reason_column_set->AddColumn( | 131 reason_column_set->AddColumn( |
130 views::GridLayout::LEADING, views::GridLayout::LEADING, 1, | 132 views::GridLayout::LEADING, views::GridLayout::LEADING, 1, |
131 views::GridLayout::USE_PREF, 0, 0); | 133 views::GridLayout::USE_PREF, 0, 0); |
132 | 134 |
133 views::ColumnSet* column_set = layout->AddColumnSet(1); | 135 views::ColumnSet* column_set = layout->AddColumnSet(1); |
134 column_set->AddColumn(views::GridLayout::LEADING, | 136 column_set->AddColumn(views::GridLayout::LEADING, |
135 views::GridLayout::LEADING, 0, | 137 views::GridLayout::LEADING, 0, |
136 views::GridLayout::USE_PREF, 0, 0); | 138 views::GridLayout::USE_PREF, 0, 0); |
137 column_set->AddPaddingColumn( | 139 column_set->AddPaddingColumn( |
138 0, views::kUnrelatedControlLargeHorizontalSpacing); | 140 0, |
| 141 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE)); |
139 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 142 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
140 views::GridLayout::USE_PREF, 0, 0); | 143 views::GridLayout::USE_PREF, 0, 0); |
141 | 144 |
142 layout->StartRow(0, 0); | 145 layout->StartRow(0, 0); |
143 layout->AddView(reason_label_); | 146 layout->AddView(reason_label_); |
144 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 147 layout->AddPaddingRow( |
| 148 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL)); |
145 | 149 |
146 layout->StartRow(0, 1); | 150 layout->StartRow(0, 1); |
147 layout->AddView(password_label_); | 151 layout->AddView(password_label_); |
148 layout->AddView(password_entry_); | 152 layout->AddView(password_entry_); |
149 } | 153 } |
150 | 154 |
151 void ShowCryptoModulePasswordDialog( | 155 void ShowCryptoModulePasswordDialog( |
152 const std::string& slot_name, | 156 const std::string& slot_name, |
153 bool retry, | 157 bool retry, |
154 CryptoModulePasswordReason reason, | 158 CryptoModulePasswordReason reason, |
155 const std::string& hostname, | 159 const std::string& hostname, |
156 gfx::NativeWindow parent, | 160 gfx::NativeWindow parent, |
157 const CryptoModulePasswordCallback& callback) { | 161 const CryptoModulePasswordCallback& callback) { |
158 CryptoModulePasswordDialogView* dialog = | 162 CryptoModulePasswordDialogView* dialog = |
159 new CryptoModulePasswordDialogView(slot_name, reason, hostname, callback); | 163 new CryptoModulePasswordDialogView(slot_name, reason, hostname, callback); |
160 views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent)->Show(); | 164 views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent)->Show(); |
161 } | 165 } |
162 | 166 |
163 } // namespace chrome | 167 } // namespace chrome |
OLD | NEW |