OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/certificate_selector.h" | 5 #include "chrome/browser/ui/views/certificate_selector.h" |
6 | 6 |
7 #include <stddef.h> // For size_t. | 7 #include <stddef.h> // For size_t. |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Select the first row automatically. This must be done after the dialog has | 91 // Select the first row automatically. This must be done after the dialog has |
92 // been created. | 92 // been created. |
93 table_->Select(0); | 93 table_->Select(0); |
94 } | 94 } |
95 | 95 |
96 void CertificateSelector::InitWithText(const base::string16& text) { | 96 void CertificateSelector::InitWithText(const base::string16& text) { |
97 views::GridLayout* const layout = views::GridLayout::CreatePanel(this); | 97 views::GridLayout* const layout = views::GridLayout::CreatePanel(this); |
98 SetLayoutManager(layout); | 98 SetLayoutManager(layout); |
99 | 99 |
| 100 // The dimensions of the certificate selector table view, in pixels. |
| 101 const int kTableViewWidth = 400; |
| 102 const int kTableViewHeight = 100; |
| 103 |
100 const int kColumnSetId = 0; | 104 const int kColumnSetId = 0; |
101 views::ColumnSet* const column_set = layout->AddColumnSet(kColumnSetId); | 105 views::ColumnSet* const column_set = layout->AddColumnSet(kColumnSetId); |
102 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 106 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
103 views::GridLayout::USE_PREF, 0, 0); | 107 views::GridLayout::USE_PREF, 0, 0); |
104 | 108 |
105 layout->StartRow(0, kColumnSetId); | 109 layout->StartRow(0, kColumnSetId); |
106 scoped_ptr<views::Label> label(new views::Label(text)); | 110 scoped_ptr<views::Label> label(new views::Label(text)); |
107 label->SetMultiLine(true); | 111 label->SetMultiLine(true); |
108 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 112 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
109 label->SetAllowCharacterBreak(true); | 113 label->SetAllowCharacterBreak(true); |
| 114 label->SizeToFit(kTableViewWidth); |
110 layout->AddView(label.release()); | 115 layout->AddView(label.release()); |
111 | 116 |
112 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 117 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
113 | 118 |
114 // The dimensions of the certificate selector table view, in pixels. | |
115 const int kTableViewWidth = 400; | |
116 const int kTableViewHeight = 100; | |
117 | |
118 std::vector<ui::TableColumn> columns; | 119 std::vector<ui::TableColumn> columns; |
119 columns.push_back(ui::TableColumn()); | 120 columns.push_back(ui::TableColumn()); |
120 table_ = new views::TableView(model_.get(), columns, views::TEXT_ONLY, | 121 table_ = new views::TableView(model_.get(), columns, views::TEXT_ONLY, |
121 true /* single_selection */); | 122 true /* single_selection */); |
122 table_->SetObserver(this); | 123 table_->SetObserver(this); |
123 layout->StartRow(1, kColumnSetId); | 124 layout->StartRow(1, kColumnSetId); |
124 layout->AddView(table_->CreateParentIfNecessary(), 1, 1, | 125 layout->AddView(table_->CreateParentIfNecessary(), 1, 1, |
125 views::GridLayout::FILL, views::GridLayout::FILL, | 126 views::GridLayout::FILL, views::GridLayout::FILL, |
126 kTableViewWidth, kTableViewHeight); | 127 kTableViewWidth, kTableViewHeight); |
127 | 128 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void CertificateSelector::OnSelectionChanged() { | 180 void CertificateSelector::OnSelectionChanged() { |
180 GetDialogClientView()->ok_button()->SetEnabled(GetSelectedCert() != nullptr); | 181 GetDialogClientView()->ok_button()->SetEnabled(GetSelectedCert() != nullptr); |
181 } | 182 } |
182 | 183 |
183 void CertificateSelector::OnDoubleClick() { | 184 void CertificateSelector::OnDoubleClick() { |
184 if (Accept()) | 185 if (Accept()) |
185 GetWidget()->Close(); | 186 GetWidget()->Close(); |
186 } | 187 } |
187 | 188 |
188 } // namespace chrome | 189 } // namespace chrome |
OLD | NEW |