| 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/ui/views/chooser_content_view.h" | 5 #include "chrome/browser/ui/views/chooser_content_view.h" |
| 6 | 6 |
| 7 #include "chrome/grit/generated_resources.h" | 7 #include "chrome/grit/generated_resources.h" |
| 8 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
| 9 #include "ui/views/controls/link.h" | 9 #include "ui/views/controls/link.h" |
| 10 #include "ui/views/controls/styled_label.h" | 10 #include "ui/views/controls/styled_label.h" |
| 11 #include "ui/views/controls/table/table_view.h" | 11 #include "ui/views/controls/table/table_view.h" |
| 12 #include "ui/views/controls/throbber.h" | 12 #include "ui/views/controls/throbber.h" |
| 13 #include "ui/views/layout/fill_layout.h" | 13 #include "ui/views/layout/fill_layout.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int kChooserWidth = 330; | 17 const int kChooserWidth = 330; |
| 18 | 18 |
| 19 const int kChooserHeight = 220; | 19 const int kChooserHeight = 220; |
| 20 | 20 |
| 21 const int kThrobberDiameter = 50; | 21 const int kThrobberDiameter = 24; |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 ChooserContentView::ChooserContentView( | 25 ChooserContentView::ChooserContentView( |
| 26 views::TableViewObserver* table_view_observer, | 26 views::TableViewObserver* table_view_observer, |
| 27 std::unique_ptr<ChooserController> chooser_controller) | 27 std::unique_ptr<ChooserController> chooser_controller) |
| 28 : chooser_controller_(std::move(chooser_controller)) { | 28 : chooser_controller_(std::move(chooser_controller)) { |
| 29 chooser_controller_->set_view(this); | 29 chooser_controller_->set_view(this); |
| 30 std::vector<ui::TableColumn> table_columns; | 30 std::vector<ui::TableColumn> table_columns; |
| 31 table_columns.push_back(ui::TableColumn()); | 31 table_columns.push_back(ui::TableColumn()); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return button == ui::DIALOG_BUTTON_OK | 151 return button == ui::DIALOG_BUTTON_OK |
| 152 ? chooser_controller_->GetOkButtonLabel() | 152 ? chooser_controller_->GetOkButtonLabel() |
| 153 : l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT); | 153 : l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const { | 156 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 157 return button != ui::DIALOG_BUTTON_OK || | 157 return button != ui::DIALOG_BUTTON_OK || |
| 158 !table_view_->selection_model().empty(); | 158 !table_view_->selection_model().empty(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 views::View* ChooserContentView::CreateExtraView() { | 161 views::Link* ChooserContentView::CreateExtraView() { |
| 162 discovery_state_ = new views::Link(chooser_controller_->GetStatus()); | 162 discovery_state_ = new views::Link(chooser_controller_->GetStatus()); |
| 163 discovery_state_->SetHandlesTooltips(false); | 163 discovery_state_->SetHandlesTooltips(false); |
| 164 discovery_state_->SetUnderline(false); | 164 discovery_state_->SetUnderline(false); |
| 165 discovery_state_->set_listener(this); | 165 discovery_state_->set_listener(this); |
| 166 return discovery_state_; | 166 return discovery_state_; |
| 167 } | 167 } |
| 168 | 168 |
| 169 views::StyledLabel* ChooserContentView::CreateFootnoteView() { | 169 views::StyledLabel* ChooserContentView::CreateFootnoteView() { |
| 170 base::string16 link = | 170 base::string16 link = |
| 171 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_GET_HELP_LINK_TEXT); | 171 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_GET_HELP_LINK_TEXT); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 192 } | 192 } |
| 193 | 193 |
| 194 void ChooserContentView::UpdateTableView() { | 194 void ChooserContentView::UpdateTableView() { |
| 195 if (chooser_controller_->NumOptions() == 0) { | 195 if (chooser_controller_->NumOptions() == 0) { |
| 196 table_view_->OnModelChanged(); | 196 table_view_->OnModelChanged(); |
| 197 table_view_->SetEnabled(false); | 197 table_view_->SetEnabled(false); |
| 198 } else { | 198 } else { |
| 199 table_view_->SetEnabled(true); | 199 table_view_->SetEnabled(true); |
| 200 } | 200 } |
| 201 } | 201 } |
| OLD | NEW |