| Index: chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.cc
|
| diff --git a/chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.cc b/chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.cc
|
| index 5d4d566b7ed5c9c1925bdf20f1d6203c0107087f..15d2bae5989996f7efe7e7107279442247705764 100644
|
| --- a/chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.cc
|
| +++ b/chrome/browser/ui/views/website_settings/chooser_bubble_ui_view.cc
|
| @@ -122,28 +122,22 @@ class ChooserTableModel : public ui::TableModel,
|
|
|
| // ui::TableModel:
|
| int RowCount() override {
|
| - const std::vector<base::string16>& device_names =
|
| - chooser_bubble_delegate_->GetOptions();
|
| - if (device_names.empty()) {
|
| - // Here it returns 1 when there is no device. In this case, the
|
| - // table view still needs to display a text message saying no
|
| - // devices found, so the number of rows is 1.
|
| - return 1;
|
| - } else {
|
| - return static_cast<int>(device_names.size());
|
| - }
|
| + size_t num_options = chooser_bubble_delegate_->NumOptions();
|
| + // Here it returns 1 when there is no device. In this case, the
|
| + // table view still needs to display a text message saying no
|
| + // devices found, so the number of rows is 1.
|
| + return num_options == 0 ? 1 : static_cast<int>(num_options);
|
| }
|
|
|
| // ui::TableModel:
|
| base::string16 GetText(int row, int column_id) override {
|
| - const std::vector<base::string16>& device_names =
|
| - chooser_bubble_delegate_->GetOptions();
|
| - if (device_names.empty()) {
|
| + size_t num_options = chooser_bubble_delegate_->NumOptions();
|
| + if (num_options == 0) {
|
| DCHECK(row == 0);
|
| return l10n_util::GetStringUTF16(
|
| IDS_CHOOSER_BUBBLE_NO_DEVICES_FOUND_PROMPT);
|
| - } else if (row >= 0 && row < static_cast<int>(device_names.size())) {
|
| - return device_names[row];
|
| + } else if (row >= 0 && row < static_cast<int>(num_options)) {
|
| + return chooser_bubble_delegate_->GetOption(static_cast<size_t>(row));
|
| } else {
|
| NOTREACHED();
|
| return base::string16();
|
| @@ -164,17 +158,17 @@ class ChooserTableModel : public ui::TableModel,
|
| }
|
|
|
| // ChooserOptions::Observer:
|
| - void OnOptionAdded(int index) override {
|
| + void OnOptionAdded(size_t index) override {
|
| if (observer_) {
|
| - observer_->OnItemsAdded(index, 1);
|
| + observer_->OnItemsAdded(static_cast<int>(index), 1);
|
| Update();
|
| }
|
| }
|
|
|
| // ChooserOptions::Observer:
|
| - void OnOptionRemoved(int index) override {
|
| + void OnOptionRemoved(size_t index) override {
|
| if (observer_) {
|
| - observer_->OnItemsRemoved(index, 1);
|
| + observer_->OnItemsRemoved(static_cast<int>(index), 1);
|
| Update();
|
| }
|
| }
|
| @@ -182,7 +176,7 @@ class ChooserTableModel : public ui::TableModel,
|
| void Update() {
|
| views::TableView* table_view = static_cast<views::TableView*>(observer_);
|
|
|
| - if (chooser_bubble_delegate_->GetOptions().empty()) {
|
| + if (chooser_bubble_delegate_->NumOptions() == 0) {
|
| observer_->OnModelChanged();
|
| table_view->SetEnabled(false);
|
| } else {
|
| @@ -232,7 +226,7 @@ ChooserBubbleUiViewDelegate::ChooserBubbleUiViewDelegate(
|
| views::GridLayout::FILL, views::GridLayout::FILL,
|
| kChooserPermissionBubbleWidth,
|
| kChooserPermissionBubbleHeight);
|
| - if (chooser_bubble_delegate_->GetOptions().empty()) {
|
| + if (chooser_bubble_delegate_->NumOptions() == 0) {
|
| table_view_->SetEnabled(false);
|
| }
|
|
|
|
|