Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: chrome/browser/ui/views/webshare/webshare_target_picker_view.cc

Issue 2667803002: Picker takes a vector of pairs, and passes back the user chosen target. (Closed)
Patch Set: Enable share button, only if target selected Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d951c905ac2b1e45e3f6633ee85671f359b3dc13 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() {
Matt Giuca 2017/02/01 07:04:33 DCHECK(!table_->selection_model().empty()); to st
constantina 2017/02/01 23:24:21 Done.
if (!close_callback_.is_null())
- close_callback_.Run(SharePickerResult::SHARE);
+ close_callback_.Run(GetText(table_->FirstSelectedRow(), 0));
return true;
}
@@ -97,6 +95,14 @@ base::string16 WebShareTargetPickerView::GetDialogButtonLabel(
return views::DialogDelegateView::GetDialogButtonLabel(button);
}
+bool WebShareTargetPickerView::IsDialogButtonEnabled(
+ ui::DialogButton button) const {
+ if (button == ui::DIALOG_BUTTON_OK)
Matt Giuca 2017/02/01 07:04:33 Small comment here to explain why.
constantina 2017/02/01 23:24:21 Done.
Matt Giuca 2017/02/02 00:07:40 how about "if there are no targets available". (Si
constantina 2017/02/02 00:54:17 "!table_->selection_model().empty()" is for whethe
+ return !table_->selection_model().empty();
+
+ return true;
+}
+
int WebShareTargetPickerView::RowCount() {
return targets_.size();
}

Powered by Google App Engine
This is Rietveld 408576698