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

Side by Side Diff: chrome/browser/ui/views/webshare/webshare_target_picker_view.h

Issue 2667803002: Picker takes a vector of pairs, and passes back the user chosen target. (Closed)
Patch Set: Fixed, as per feedback Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/browser_dialogs.h" 13 #include "chrome/browser/ui/browser_dialogs.h"
14 #include "ui/base/models/table_model.h" 14 #include "ui/base/models/table_model.h"
15 #include "ui/base/ui_base_types.h" 15 #include "ui/base/ui_base_types.h"
16 #include "ui/views/controls/table/table_view.h"
16 #include "ui/views/window/dialog_delegate.h" 17 #include "ui/views/window/dialog_delegate.h"
17 18
19 class GURL;
20
18 // Dialog that presents the user with a list of share target apps. Allows the 21 // Dialog that presents the user with a list of share target apps. Allows the
19 // user to pick one target to be opened and have data passed to it. 22 // user to pick one target to be opened and have data passed to it.
20 // 23 //
21 // NOTE: This dialog has *not* been UI-reviewed, and is being used by an 24 // NOTE: This dialog has *not* been UI-reviewed, and is being used by an
22 // in-development feature (Web Share) behind a runtime flag. It should not be 25 // in-development feature (Web Share) behind a runtime flag. It should not be
23 // used by any released code until going through UI review. 26 // used by any released code until going through UI review.
24 class WebShareTargetPickerView : public views::DialogDelegateView, 27 class WebShareTargetPickerView : public views::DialogDelegateView,
25 public ui::TableModel { 28 public ui::TableModel {
26 public: 29 public:
27 // |targets| is a list of app titles that will be shown in a list. Calls 30 // |targets| is a list of app title and manifest URL pairs that will be shown
28 // |close_callback| with SHARE if an app was chosen, or CANCEL if the dialog 31 // in a list. If the user picks a target, this calls |callback| with the
29 // was cancelled. 32 // manifest URL of the chosen target, or returns null if the user cancelled
33 // the share.
30 WebShareTargetPickerView( 34 WebShareTargetPickerView(
31 const std::vector<base::string16>& targets, 35 const std::vector<std::pair<base::string16, GURL>>& targets,
32 const base::Callback<void(SharePickerResult)>& close_callback); 36 const base::Callback<void(base::Optional<std::string>)>&
37 close_callback);
33 ~WebShareTargetPickerView() override; 38 ~WebShareTargetPickerView() override;
34 39
35 // views::View overrides: 40 // views::View overrides:
36 gfx::Size GetPreferredSize() const override; 41 gfx::Size GetPreferredSize() const override;
37 42
38 // views::WidgetDelegate overrides: 43 // views::WidgetDelegate overrides:
39 ui::ModalType GetModalType() const override; 44 ui::ModalType GetModalType() const override;
40 base::string16 GetWindowTitle() const override; 45 base::string16 GetWindowTitle() const override;
41 46
42 // views::DialogDelegate overrides: 47 // views::DialogDelegate overrides:
43 bool Cancel() override; 48 bool Cancel() override;
44 bool Accept() override; 49 bool Accept() override;
45 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; 50 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
51 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
46 52
47 // ui::TableModel overrides: 53 // ui::TableModel overrides:
48 int RowCount() override; 54 int RowCount() override;
49 base::string16 GetText(int row, int column_id) override; 55 base::string16 GetText(int row, int column_id) override;
50 void SetObserver(ui::TableModelObserver* observer) override; 56 void SetObserver(ui::TableModelObserver* observer) override;
51 57
52 private: 58 private:
53 const std::vector<base::string16> targets_; 59 views::TableView* table_;
54 60
55 base::Callback<void(SharePickerResult)> close_callback_; 61 const std::vector<std::pair<base::string16, GURL>> targets_;
62
63 base::Callback<void(base::Optional<std::string>)> close_callback_;
56 64
57 DISALLOW_COPY_AND_ASSIGN(WebShareTargetPickerView); 65 DISALLOW_COPY_AND_ASSIGN(WebShareTargetPickerView);
58 }; 66 };
59 67
60 #endif // CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_ 68 #endif // CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698