OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CHOOSER_CONTENT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DEVICE_CHOOSER_CONTENT_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_CHOOSER_CONTENT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DEVICE_CHOOSER_CONTENT_VIEW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "chrome/browser/chooser_controller/chooser_controller.h" | 12 #include "chrome/browser/chooser_controller/chooser_controller.h" |
13 #include "ui/base/models/table_model.h" | 13 #include "ui/base/models/table_model.h" |
14 #include "ui/gfx/range/range.h" | 14 #include "ui/gfx/range/range.h" |
15 #include "ui/views/controls/styled_label_listener.h" | 15 #include "ui/views/controls/styled_label_listener.h" |
16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 class StyledLabel; | 19 class StyledLabel; |
20 class TableView; | 20 class TableView; |
21 class TableViewObserver; | 21 class TableViewObserver; |
22 class Throbber; | 22 class Throbber; |
23 } | 23 } |
24 | 24 |
25 // A bubble or dialog view for choosing among several options in a table. | 25 // A bubble or dialog view for choosing among several options in a table. |
26 // Used for WebUSB/WebBluetooth device selection for Chrome and extensions. | 26 // Used for WebUSB/WebBluetooth device selection for Chrome and extensions. |
27 // | 27 class DeviceChooserContentView : public views::View, |
28 // TODO(juncai): change ChooserContentView class name to be more specific. | 28 public ui::TableModel, |
29 // https://crbug.com/651568 | 29 public ChooserController::View, |
30 class ChooserContentView : public views::View, | 30 public views::StyledLabelListener { |
31 public ui::TableModel, | |
32 public ChooserController::View, | |
33 public views::StyledLabelListener { | |
34 public: | 31 public: |
35 ChooserContentView(views::TableViewObserver* table_view_observer, | 32 DeviceChooserContentView( |
36 std::unique_ptr<ChooserController> chooser_controller); | 33 views::TableViewObserver* table_view_observer, |
37 ~ChooserContentView() override; | 34 std::unique_ptr<ChooserController> chooser_controller); |
| 35 ~DeviceChooserContentView() override; |
38 | 36 |
39 // views::View: | 37 // views::View: |
40 gfx::Size GetPreferredSize() const override; | 38 gfx::Size GetPreferredSize() const override; |
41 void Layout() override; | 39 void Layout() override; |
42 | 40 |
43 // ui::TableModel: | 41 // ui::TableModel: |
44 int RowCount() override; | 42 int RowCount() override; |
45 base::string16 GetText(int row, int column_id) override; | 43 base::string16 GetText(int row, int column_id) override; |
46 void SetObserver(ui::TableModelObserver* observer) override; | 44 void SetObserver(ui::TableModelObserver* observer) override; |
47 gfx::ImageSkia GetIcon(int row) override; | 45 gfx::ImageSkia GetIcon(int row) override; |
(...skipping 15 matching lines...) Expand all Loading... |
63 base::string16 GetDialogButtonLabel(ui::DialogButton button) const; | 61 base::string16 GetDialogButtonLabel(ui::DialogButton button) const; |
64 bool IsDialogButtonEnabled(ui::DialogButton button) const; | 62 bool IsDialogButtonEnabled(ui::DialogButton button) const; |
65 views::StyledLabel* footnote_link(); | 63 views::StyledLabel* footnote_link(); |
66 void Accept(); | 64 void Accept(); |
67 void Cancel(); | 65 void Cancel(); |
68 void Close(); | 66 void Close(); |
69 void UpdateTableView(); | 67 void UpdateTableView(); |
70 void SetGetHelpAndReScanLink(); | 68 void SetGetHelpAndReScanLink(); |
71 | 69 |
72 private: | 70 private: |
73 friend class ChooserContentViewTest; | |
74 friend class ChooserDialogViewTest; | 71 friend class ChooserDialogViewTest; |
75 FRIEND_TEST_ALL_PREFIXES(ChooserContentViewTest, InitialState); | 72 friend class DeviceChooserContentViewTest; |
76 FRIEND_TEST_ALL_PREFIXES(ChooserContentViewTest, AdapterOnAndOffAndOn); | 73 FRIEND_TEST_ALL_PREFIXES(DeviceChooserContentViewTest, InitialState); |
77 FRIEND_TEST_ALL_PREFIXES(ChooserContentViewTest, | 74 FRIEND_TEST_ALL_PREFIXES(DeviceChooserContentViewTest, AdapterOnAndOffAndOn); |
| 75 FRIEND_TEST_ALL_PREFIXES(DeviceChooserContentViewTest, |
78 DiscoveringAndNoOptionAddedAndIdle); | 76 DiscoveringAndNoOptionAddedAndIdle); |
79 FRIEND_TEST_ALL_PREFIXES(ChooserContentViewTest, | 77 FRIEND_TEST_ALL_PREFIXES(DeviceChooserContentViewTest, |
80 DiscoveringAndOneOptionAddedAndSelectedAndIdle); | 78 DiscoveringAndOneOptionAddedAndSelectedAndIdle); |
81 FRIEND_TEST_ALL_PREFIXES(ChooserContentViewTest, ClickRescanLink); | 79 FRIEND_TEST_ALL_PREFIXES(DeviceChooserContentViewTest, ClickRescanLink); |
82 FRIEND_TEST_ALL_PREFIXES(ChooserContentViewTest, ClickGetHelpLink); | 80 FRIEND_TEST_ALL_PREFIXES(DeviceChooserContentViewTest, ClickGetHelpLink); |
83 | 81 |
84 std::unique_ptr<ChooserController> chooser_controller_; | 82 std::unique_ptr<ChooserController> chooser_controller_; |
85 views::TableView* table_view_ = nullptr; // Weak. | 83 views::TableView* table_view_ = nullptr; // Weak. |
86 views::View* table_parent_ = nullptr; // Weak. | 84 views::View* table_parent_ = nullptr; // Weak. |
87 views::StyledLabel* turn_adapter_off_help_ = nullptr; // Weak. | 85 views::StyledLabel* turn_adapter_off_help_ = nullptr; // Weak. |
88 views::Throbber* throbber_ = nullptr; // Weak. | 86 views::Throbber* throbber_ = nullptr; // Weak. |
89 std::unique_ptr<views::StyledLabel> footnote_link_; | 87 std::unique_ptr<views::StyledLabel> footnote_link_; |
90 base::string16 help_text_; | 88 base::string16 help_text_; |
91 base::string16 help_and_scanning_text_; | 89 base::string16 help_and_scanning_text_; |
92 base::string16 help_and_re_scan_text_; | 90 base::string16 help_and_re_scan_text_; |
93 gfx::Range help_text_range_; | 91 gfx::Range help_text_range_; |
94 gfx::Range re_scan_text_range_; | 92 gfx::Range re_scan_text_range_; |
95 | 93 |
96 DISALLOW_COPY_AND_ASSIGN(ChooserContentView); | 94 DISALLOW_COPY_AND_ASSIGN(DeviceChooserContentView); |
97 }; | 95 }; |
98 | 96 |
99 #endif // CHROME_BROWSER_UI_VIEWS_CHOOSER_CONTENT_VIEW_H_ | 97 #endif // CHROME_BROWSER_UI_VIEWS_DEVICE_CHOOSER_CONTENT_VIEW_H_ |
OLD | NEW |