| 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 "components/chooser_controller/chooser_controller.h" | 8 #include "components/chooser_controller/chooser_controller.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 #include "ui/base/models/table_model.h" | 10 #include "ui/base/models/table_model.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 base::string16 ChooserTableModel::GetText(int row, int column_id) { | 64 base::string16 ChooserTableModel::GetText(int row, int column_id) { |
| 65 if (!chooser_controller_) | 65 if (!chooser_controller_) |
| 66 return base::string16(); | 66 return base::string16(); |
| 67 | 67 |
| 68 int num_options = static_cast<int>(chooser_controller_->NumOptions()); | 68 int num_options = static_cast<int>(chooser_controller_->NumOptions()); |
| 69 if (num_options == 0) { | 69 if (num_options == 0) { |
| 70 DCHECK_EQ(0, row); | 70 DCHECK_EQ(0, row); |
| 71 return l10n_util::GetStringUTF16( | 71 return l10n_util::GetStringUTF16( |
| 72 IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT); | 72 IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); |
| 73 } | 73 } |
| 74 | 74 |
| 75 DCHECK_GE(row, 0); | 75 DCHECK_GE(row, 0); |
| 76 DCHECK_LT(row, num_options); | 76 DCHECK_LT(row, num_options); |
| 77 return chooser_controller_->GetOption(static_cast<size_t>(row)); | 77 return chooser_controller_->GetOption(static_cast<size_t>(row)); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ChooserTableModel::SetObserver(ui::TableModelObserver* observer) { | 80 void ChooserTableModel::SetObserver(ui::TableModelObserver* observer) { |
| 81 observer_ = observer; | 81 observer_ = observer; |
| 82 } | 82 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 chooser_table_model_->SetObserver(nullptr); | 146 chooser_table_model_->SetObserver(nullptr); |
| 147 } | 147 } |
| 148 | 148 |
| 149 gfx::Size ChooserContentView::GetPreferredSize() const { | 149 gfx::Size ChooserContentView::GetPreferredSize() const { |
| 150 return gfx::Size(kChooserWidth, kChooserHeight); | 150 return gfx::Size(kChooserWidth, kChooserHeight); |
| 151 } | 151 } |
| 152 | 152 |
| 153 base::string16 ChooserContentView::GetDialogButtonLabel( | 153 base::string16 ChooserContentView::GetDialogButtonLabel( |
| 154 ui::DialogButton button) const { | 154 ui::DialogButton button) const { |
| 155 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK | 155 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK |
| 156 ? IDS_CHOOSER_BUBBLE_CONNECT_BUTTON_TEXT | 156 ? IDS_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT |
| 157 : IDS_CHOOSER_BUBBLE_CANCEL_BUTTON_TEXT); | 157 : IDS_DEVICE_CHOOSER_CANCEL_BUTTON_TEXT); |
| 158 } | 158 } |
| 159 | 159 |
| 160 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const { | 160 bool ChooserContentView::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 161 return button != ui::DIALOG_BUTTON_OK || | 161 return button != ui::DIALOG_BUTTON_OK || |
| 162 !table_view_->selection_model().empty(); | 162 !table_view_->selection_model().empty(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 views::StyledLabel* ChooserContentView::CreateFootnoteView( | 165 views::StyledLabel* ChooserContentView::CreateFootnoteView( |
| 166 views::StyledLabelListener* listener) const { | 166 views::StyledLabelListener* listener) const { |
| 167 base::string16 link = | 167 base::string16 link = |
| 168 l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_GET_HELP_LINK_TEXT); | 168 l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_GET_HELP_LINK_TEXT); |
| 169 size_t offset = 0; | 169 size_t offset = 0; |
| 170 base::string16 text = l10n_util::GetStringFUTF16( | 170 base::string16 text = l10n_util::GetStringFUTF16( |
| 171 IDS_CHOOSER_BUBBLE_FOOTNOTE_TEXT, link, &offset); | 171 IDS_DEVICE_CHOOSER_FOOTNOTE_TEXT, link, &offset); |
| 172 views::StyledLabel* styled_label = new views::StyledLabel(text, listener); | 172 views::StyledLabel* styled_label = new views::StyledLabel(text, listener); |
| 173 styled_label->AddStyleRange( | 173 styled_label->AddStyleRange( |
| 174 gfx::Range(offset, offset + link.length()), | 174 gfx::Range(offset, offset + link.length()), |
| 175 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 175 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
| 176 return styled_label; | 176 return styled_label; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void ChooserContentView::Accept() { | 179 void ChooserContentView::Accept() { |
| 180 if (chooser_controller_) { | 180 if (chooser_controller_) { |
| 181 chooser_controller_->Select(table_view_->selection_model().active()); | 181 chooser_controller_->Select(table_view_->selection_model().active()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 203 } | 203 } |
| 204 | 204 |
| 205 void ChooserContentView::UpdateTableModel() { | 205 void ChooserContentView::UpdateTableModel() { |
| 206 chooser_table_model_->Update(); | 206 chooser_table_model_->Update(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void ChooserContentView::ChooserControllerDestroying() { | 209 void ChooserContentView::ChooserControllerDestroying() { |
| 210 chooser_controller_ = nullptr; | 210 chooser_controller_ = nullptr; |
| 211 chooser_table_model_->ChooserControllerDestroying(); | 211 chooser_table_model_->ChooserControllerDestroying(); |
| 212 } | 212 } |
| OLD | NEW |