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

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

Issue 2682753004: Fix crash closing the Web Share target picker dialog. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/webshare/webshare_target_picker_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
15 #include "ui/base/ui_base_types.h" 14 #include "ui/base/ui_base_types.h"
16 #include "ui/views/controls/table/table_view.h"
17 #include "ui/views/controls/table/table_view_observer.h" 15 #include "ui/views/controls/table/table_view_observer.h"
18 #include "ui/views/window/dialog_delegate.h" 16 #include "ui/views/window/dialog_delegate.h"
19 17
20 class GURL; 18 class GURL;
19 class TargetPickerTableModel;
20
21 namespace views {
22 class TableView;
23 }
21 24
22 // Dialog that presents the user with a list of share target apps. Allows the 25 // Dialog that presents the user with a list of share target apps. Allows the
23 // user to pick one target to be opened and have data passed to it. 26 // user to pick one target to be opened and have data passed to it.
24 // 27 //
25 // NOTE: This dialog has *not* been UI-reviewed, and is being used by an 28 // NOTE: This dialog has *not* been UI-reviewed, and is being used by an
26 // in-development feature (Web Share) behind a runtime flag. It should not be 29 // in-development feature (Web Share) behind a runtime flag. It should not be
27 // used by any released code until going through UI review. 30 // used by any released code until going through UI review.
28 class WebShareTargetPickerView : public views::DialogDelegateView, 31 class WebShareTargetPickerView : public views::DialogDelegateView,
29 public views::TableViewObserver, 32 public views::TableViewObserver {
30 public ui::TableModel {
31 public: 33 public:
32 // |targets| is a list of app title and manifest URL pairs that will be shown 34 // |targets| is a list of app title and manifest URL pairs that will be shown
33 // in a list. If the user picks a target, this calls |callback| with the 35 // in a list. If the user picks a target, this calls |callback| with the
34 // manifest URL of the chosen target, or returns null if the user cancelled 36 // manifest URL of the chosen target, or returns null if the user cancelled
35 // the share. 37 // the share.
36 WebShareTargetPickerView( 38 WebShareTargetPickerView(
37 const std::vector<std::pair<base::string16, GURL>>& targets, 39 const std::vector<std::pair<base::string16, GURL>>& targets,
38 const base::Callback<void(base::Optional<std::string>)>& 40 const base::Callback<void(base::Optional<std::string>)>&
39 close_callback); 41 close_callback);
40 ~WebShareTargetPickerView() override; 42 ~WebShareTargetPickerView() override;
41 43
42 // views::View overrides: 44 // views::View overrides:
43 gfx::Size GetPreferredSize() const override; 45 gfx::Size GetPreferredSize() const override;
44 46
45 // views::WidgetDelegate overrides: 47 // views::WidgetDelegate overrides:
46 ui::ModalType GetModalType() const override; 48 ui::ModalType GetModalType() const override;
47 base::string16 GetWindowTitle() const override; 49 base::string16 GetWindowTitle() const override;
48 50
49 // views::DialogDelegate overrides: 51 // views::DialogDelegate overrides:
50 bool Cancel() override; 52 bool Cancel() override;
51 bool Accept() override; 53 bool Accept() override;
52 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; 54 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
53 bool IsDialogButtonEnabled(ui::DialogButton button) const override; 55 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
54 56
55 // views::TableViewObserver overrides: 57 // views::TableViewObserver overrides:
56 void OnSelectionChanged() override; 58 void OnSelectionChanged() override;
57 void OnDoubleClick() override; 59 void OnDoubleClick() override;
58 60
59 // ui::TableModel overrides:
60 int RowCount() override;
61 base::string16 GetText(int row, int column_id) override;
62 void SetObserver(ui::TableModelObserver* observer) override;
63
64 private: 61 private:
65 views::TableView* table_; 62 views::TableView* table_ = nullptr;
66 63
67 const std::vector<std::pair<base::string16, GURL>> targets_; 64 const std::vector<std::pair<base::string16, GURL>> targets_;
65 std::unique_ptr<TargetPickerTableModel> table_model_;
68 66
69 base::Callback<void(base::Optional<std::string>)> close_callback_; 67 base::Callback<void(base::Optional<std::string>)> close_callback_;
70 68
71 DISALLOW_COPY_AND_ASSIGN(WebShareTargetPickerView); 69 DISALLOW_COPY_AND_ASSIGN(WebShareTargetPickerView);
72 }; 70 };
73 71
74 #endif // CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_ 72 #endif // CHROME_BROWSER_UI_VIEWS_WEBSHARE_WEBSHARE_TARGET_PICKER_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/webshare/webshare_target_picker_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698