| 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_CHOOSER_CONTENT_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_CHOOSER_CONTENT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_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 "ui/base/ui_base_types.h" | 12 #include "chrome/browser/chooser_controller/chooser_controller.h" |
| 13 #include "ui/base/models/table_model.h" |
| 14 #include "ui/views/controls/link_listener.h" |
| 15 #include "ui/views/controls/styled_label_listener.h" |
| 13 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 14 | 17 |
| 15 class ChooserController; | |
| 16 class ChooserTableModel; | |
| 17 | |
| 18 namespace ui { | |
| 19 class TableModel; | |
| 20 } | |
| 21 | |
| 22 namespace views { | 18 namespace views { |
| 19 class Link; |
| 23 class StyledLabel; | 20 class StyledLabel; |
| 24 class StyledLabelListener; | |
| 25 class TableView; | 21 class TableView; |
| 26 class TableViewObserver; | 22 class TableViewObserver; |
| 23 class Throbber; |
| 27 } | 24 } |
| 28 | 25 |
| 29 // A bubble or dialog view for choosing among several options in a table. | 26 // A bubble or dialog view for choosing among several options in a table. |
| 30 // Used for WebUSB/WebBluetooth device selection for Chrome and extensions. | 27 // Used for WebUSB/WebBluetooth device selection for Chrome and extensions. |
| 31 class ChooserContentView : public views::View { | 28 class ChooserContentView : public views::View, |
| 29 public ui::TableModel, |
| 30 public ChooserController::Observer, |
| 31 public views::LinkListener, |
| 32 public views::StyledLabelListener { |
| 32 public: | 33 public: |
| 33 ChooserContentView(views::TableViewObserver* observer, | 34 ChooserContentView(views::TableViewObserver* table_view_observer, |
| 34 std::unique_ptr<ChooserController> chooser_controller); | 35 std::unique_ptr<ChooserController> chooser_controller); |
| 35 ~ChooserContentView() override; | 36 ~ChooserContentView() override; |
| 36 | 37 |
| 37 // views::View: | 38 // views::View: |
| 38 gfx::Size GetPreferredSize() const override; | 39 gfx::Size GetPreferredSize() const override; |
| 39 | 40 |
| 41 // ui::TableModel: |
| 42 int RowCount() override; |
| 43 base::string16 GetText(int row, int column_id) override; |
| 44 void SetObserver(ui::TableModelObserver* observer) override; |
| 45 |
| 46 // ChooserController::Observer: |
| 47 void OnOptionsInitialized() override; |
| 48 void OnOptionAdded(size_t index) override; |
| 49 void OnOptionRemoved(size_t index) override; |
| 50 void AdapterOn() override; |
| 51 void AdapterOff() override; |
| 52 void Refresh() override; |
| 53 void Idle() override; |
| 54 |
| 55 // views::LinkListener: |
| 56 void LinkClicked(views::Link* source, int event_flags) override; |
| 57 |
| 58 // views::StyledLabelListener: |
| 59 void StyledLabelLinkClicked(views::StyledLabel* label, |
| 60 const gfx::Range& range, |
| 61 int event_flags) override; |
| 62 |
| 40 base::string16 GetWindowTitle() const; | 63 base::string16 GetWindowTitle() const; |
| 41 base::string16 GetDialogButtonLabel(ui::DialogButton button) const; | 64 base::string16 GetDialogButtonLabel(ui::DialogButton button) const; |
| 42 bool IsDialogButtonEnabled(ui::DialogButton button) const; | 65 bool IsDialogButtonEnabled(ui::DialogButton button) const; |
| 66 views::View* CreateExtraView(); |
| 43 // Ownership of the view is passed to the caller. | 67 // Ownership of the view is passed to the caller. |
| 44 views::StyledLabel* CreateFootnoteView( | 68 views::StyledLabel* CreateFootnoteView(); |
| 45 views::StyledLabelListener* listener) const; | |
| 46 void Accept(); | 69 void Accept(); |
| 47 void Cancel(); | 70 void Cancel(); |
| 48 void Close(); | 71 void Close(); |
| 49 void StyledLabelLinkClicked(); | 72 void UpdateTableView(); |
| 50 void UpdateTableModel(); | |
| 51 | 73 |
| 52 views::TableView* table_view_for_test() const { return table_view_; } | 74 views::TableView* table_view_for_test() const { return table_view_; } |
| 53 | 75 |
| 54 private: | 76 private: |
| 55 std::unique_ptr<ChooserController> chooser_controller_; | 77 std::unique_ptr<ChooserController> chooser_controller_; |
| 56 std::unique_ptr<ChooserTableModel> chooser_table_model_; | |
| 57 views::TableView* table_view_; | 78 views::TableView* table_view_; |
| 79 views::Throbber* throbber_ = nullptr; |
| 80 views::Link* discovery_state_ = nullptr; |
| 58 | 81 |
| 59 DISALLOW_COPY_AND_ASSIGN(ChooserContentView); | 82 DISALLOW_COPY_AND_ASSIGN(ChooserContentView); |
| 60 }; | 83 }; |
| 61 | 84 |
| 62 #endif // CHROME_BROWSER_UI_VIEWS_CHOOSER_CONTENT_VIEW_H_ | 85 #endif // CHROME_BROWSER_UI_VIEWS_CHOOSER_CONTENT_VIEW_H_ |
| OLD | NEW |