Chromium Code Reviews| Index: chrome/browser/ui/views/webshare/webshare_target_picker_view.cc |
| diff --git a/chrome/browser/ui/views/webshare/webshare_target_picker_view.cc b/chrome/browser/ui/views/webshare/webshare_target_picker_view.cc |
| index 05ed1c26961524af3874c6d92c51cedfa8d194da..848b89991bf2fd308eb3b70c2bdfd3143e5e84ff 100644 |
| --- a/chrome/browser/ui/views/webshare/webshare_target_picker_view.cc |
| +++ b/chrome/browser/ui/views/webshare/webshare_target_picker_view.cc |
| @@ -9,7 +9,6 @@ |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/native_widget_types.h" |
| #include "ui/views/controls/label.h" |
| -#include "ui/views/controls/table/table_view.h" |
| #include "ui/views/layout/box_layout.h" |
| #include "ui/views/layout/layout_constants.h" |
| @@ -25,7 +24,7 @@ namespace chrome { |
| void ShowWebShareTargetPickerDialog( |
| gfx::NativeWindow parent_window, |
| const std::vector<base::string16>& targets, |
| - const base::Callback<void(SharePickerResult)>& callback) { |
| + const base::Callback<void(base::Optional<base::string16>)>& callback) { |
| constrained_window::CreateBrowserModalDialogViews( |
| new WebShareTargetPickerView(targets, callback), parent_window) |
| ->Show(); |
| @@ -35,7 +34,7 @@ void ShowWebShareTargetPickerDialog( |
| WebShareTargetPickerView::WebShareTargetPickerView( |
| const std::vector<base::string16>& targets, |
| - const base::Callback<void(SharePickerResult)>& close_callback) |
| + const base::Callback<void(base::Optional<base::string16>)>& close_callback) |
| : targets_(targets), close_callback_(close_callback) { |
| views::BoxLayout* layout = new views::BoxLayout( |
| views::BoxLayout::kVertical, views::kPanelHorizMargin, |
| @@ -47,15 +46,14 @@ WebShareTargetPickerView::WebShareTargetPickerView( |
| AddChildView(overview_label); |
| std::vector<ui::TableColumn> table_columns{ui::TableColumn()}; |
| - views::TableView* table = |
| - new views::TableView(this, table_columns, views::TEXT_ONLY, true); |
| + table_ = new views::TableView(this, table_columns, views::TEXT_ONLY, true); |
| // Select the first row. |
| if (RowCount() > 0) |
| - table->Select(0); |
| + table_->Select(0); |
| // Create the table parent (a ScrollView which includes the scroll bars and |
| // border). We add this parent (not the table itself) to the dialog. |
| - views::View* table_parent = table->CreateParentIfNecessary(); |
| + views::View* table_parent = table_->CreateParentIfNecessary(); |
| AddChildView(table_parent); |
| // Make the table expand to fill the space. |
| layout->SetFlexForView(table_parent, 1); |
| @@ -77,14 +75,14 @@ base::string16 WebShareTargetPickerView::GetWindowTitle() const { |
| bool WebShareTargetPickerView::Cancel() { |
| if (!close_callback_.is_null()) |
| - close_callback_.Run(SharePickerResult::CANCEL); |
| + close_callback_.Run(base::nullopt); |
| return true; |
| } |
| bool WebShareTargetPickerView::Accept() { |
| if (!close_callback_.is_null()) |
| - close_callback_.Run(SharePickerResult::SHARE); |
| + close_callback_.Run(GetText(table_->FirstSelectedRow(), 0)); |
|
sky
2017/01/31 05:22:32
What if there is no selected row?
constantina
2017/01/31 23:29:42
If there are no targets in the list, there will be
Matt Giuca
2017/01/31 23:48:27
This is true now, but won't be true very soon (and
sky
2017/02/01 00:51:33
Not just that, but there is nothing stopping the u
constantina
2017/02/01 01:06:02
Done. If nothing is selected and user accepts, UI
|
| return true; |
| } |