Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/webshare/webshare_target_picker_view.h" | 5 #include "chrome/browser/ui/views/webshare/webshare_target_picker_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/grit/generated_resources.h" | 8 #include "chrome/grit/generated_resources.h" |
| 9 #include "components/constrained_window/constrained_window_views.h" | 9 #include "components/constrained_window/constrained_window_views.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 | 124 |
| 125 bool WebShareTargetPickerView::Cancel() { | 125 bool WebShareTargetPickerView::Cancel() { |
| 126 if (!close_callback_.is_null()) | 126 if (!close_callback_.is_null()) |
| 127 close_callback_.Run(base::nullopt); | 127 close_callback_.Run(base::nullopt); |
| 128 | 128 |
| 129 return true; | 129 return true; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool WebShareTargetPickerView::Accept() { | 132 bool WebShareTargetPickerView::Accept() { |
| 133 if (!close_callback_.is_null()) { | 133 if (!close_callback_.is_null()) { |
| 134 DCHECK(!table_->selection_model().empty()); | 134 // If nothing is selected, can't accept. |
| 135 if (table_->selection_model().empty()) | |
|
sky
2017/02/08 17:03:44
How do we end up here with an empty selection? Doe
sky
2017/02/08 17:06:51
I suspect this is because your test is directly ca
Matt Giuca
2017/02/08 23:26:42
Oh OK, I wasn't sure if that was guaranteed or if
| |
| 136 return false; | |
| 137 | |
| 135 close_callback_.Run(targets_[table_->FirstSelectedRow()].second.spec()); | 138 close_callback_.Run(targets_[table_->FirstSelectedRow()].second.spec()); |
| 136 } | 139 } |
| 137 | 140 |
| 138 return true; | 141 return true; |
| 139 } | 142 } |
| 140 | 143 |
| 141 base::string16 WebShareTargetPickerView::GetDialogButtonLabel( | 144 base::string16 WebShareTargetPickerView::GetDialogButtonLabel( |
| 142 ui::DialogButton button) const { | 145 ui::DialogButton button) const { |
| 143 if (button == ui::DIALOG_BUTTON_OK) | 146 if (button == ui::DIALOG_BUTTON_OK) |
| 144 return l10n_util::GetStringUTF16(IDS_WEBSHARE_TARGET_PICKER_COMMIT); | 147 return l10n_util::GetStringUTF16(IDS_WEBSHARE_TARGET_PICKER_COMMIT); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 155 return true; | 158 return true; |
| 156 } | 159 } |
| 157 | 160 |
| 158 void WebShareTargetPickerView::OnSelectionChanged() { | 161 void WebShareTargetPickerView::OnSelectionChanged() { |
| 159 GetDialogClientView()->UpdateDialogButtons(); | 162 GetDialogClientView()->UpdateDialogButtons(); |
| 160 } | 163 } |
| 161 | 164 |
| 162 void WebShareTargetPickerView::OnDoubleClick() { | 165 void WebShareTargetPickerView::OnDoubleClick() { |
| 163 GetDialogClientView()->AcceptWindow(); | 166 GetDialogClientView()->AcceptWindow(); |
| 164 } | 167 } |
| OLD | NEW |