Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DESKTOP_CAPTURE_DESKTOP_MEDIA_PICKER_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_PICKER_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_PICKER_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_PICKER_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/media/desktop_media_list_observer.h" | |
| 10 #include "chrome/browser/media/desktop_media_picker.h" | 9 #include "chrome/browser/media/desktop_media_picker.h" |
| 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" | |
|
msw
2016/05/16 17:49:47
Just forward declare the classes here, don't inclu
qiangchen
2016/05/16 21:39:37
Done.
| |
| 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" | |
| 11 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" | 12 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" |
| 12 #include "ui/views/window/dialog_delegate.h" | 13 #include "ui/views/window/dialog_delegate.h" |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 class ImageView; | |
| 16 class Label; | |
| 17 class Checkbox; | 16 class Checkbox; |
| 18 class TabbedPane; | 17 class TabbedPane; |
| 19 } // namespace views | 18 } // namespace views |
| 20 | 19 |
| 21 class DesktopMediaPickerDialogView; | |
| 22 class DesktopMediaPickerViews; | 20 class DesktopMediaPickerViews; |
| 23 class DesktopMediaSourceView; | |
| 24 | |
| 25 // View that shows a list of desktop media sources available from | |
| 26 // DesktopMediaList. | |
| 27 class DesktopMediaListView : public views::View, | |
| 28 public DesktopMediaListObserver { | |
| 29 public: | |
| 30 DesktopMediaListView(DesktopMediaPickerDialogView* parent, | |
| 31 std::unique_ptr<DesktopMediaList> media_list); | |
| 32 ~DesktopMediaListView() override; | |
| 33 | |
| 34 void StartUpdating(content::DesktopMediaID dialog_window_id); | |
| 35 | |
| 36 // Called by DesktopMediaSourceView when selection has changed. | |
| 37 void OnSelectionChanged(); | |
| 38 | |
| 39 // Called by DesktopMediaSourceView when a source has been double-clicked. | |
| 40 void OnDoubleClick(); | |
| 41 | |
| 42 // Returns currently selected source. | |
| 43 DesktopMediaSourceView* GetSelection(); | |
| 44 | |
| 45 // views::View overrides. | |
| 46 gfx::Size GetPreferredSize() const override; | |
| 47 void Layout() override; | |
| 48 bool OnKeyPressed(const ui::KeyEvent& event) override; | |
| 49 | |
| 50 private: | |
| 51 // DesktopMediaList::Observer interface | |
| 52 void OnSourceAdded(DesktopMediaList* list, int index) override; | |
| 53 void OnSourceRemoved(DesktopMediaList* list, int index) override; | |
| 54 void OnSourceMoved(DesktopMediaList* list, | |
| 55 int old_index, | |
| 56 int new_index) override; | |
| 57 void OnSourceNameChanged(DesktopMediaList* list, int index) override; | |
| 58 void OnSourceThumbnailChanged(DesktopMediaList* list, int index) override; | |
| 59 | |
| 60 // Accepts whatever happens to be selected right now. | |
| 61 void AcceptSelection(); | |
| 62 | |
| 63 DesktopMediaPickerDialogView* parent_; | |
| 64 std::unique_ptr<DesktopMediaList> media_list_; | |
| 65 base::WeakPtrFactory<DesktopMediaListView> weak_factory_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListView); | |
| 68 }; | |
| 69 | |
| 70 // View used for each item in DesktopMediaListView. Shows a single desktop media | |
| 71 // source as a thumbnail with the title under it. | |
| 72 class DesktopMediaSourceView : public views::View { | |
| 73 public: | |
| 74 DesktopMediaSourceView(DesktopMediaListView* parent, | |
| 75 content::DesktopMediaID source_id); | |
| 76 ~DesktopMediaSourceView() override; | |
| 77 | |
| 78 // Updates thumbnail and title from |source|. | |
| 79 void SetName(const base::string16& name); | |
| 80 void SetThumbnail(const gfx::ImageSkia& thumbnail); | |
| 81 | |
| 82 // Id for the source shown by this View. | |
| 83 const content::DesktopMediaID& source_id() const { return source_id_; } | |
| 84 | |
| 85 // Returns true if the source is selected. | |
| 86 bool is_selected() const { return selected_; } | |
| 87 | |
| 88 // views::View interface. | |
| 89 const char* GetClassName() const override; | |
| 90 void Layout() override; | |
| 91 views::View* GetSelectedViewForGroup(int group) override; | |
| 92 bool IsGroupFocusTraversable() const override; | |
| 93 void OnPaint(gfx::Canvas* canvas) override; | |
| 94 void OnFocus() override; | |
| 95 void OnBlur() override; | |
| 96 bool OnMousePressed(const ui::MouseEvent& event) override; | |
| 97 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 98 | |
| 99 private: | |
| 100 // Updates selection state of the element. If |selected| is true then also | |
| 101 // calls SetSelected(false) for the source view that was selected before that | |
| 102 // (if any). | |
| 103 void SetSelected(bool selected); | |
| 104 | |
| 105 DesktopMediaListView* parent_; | |
| 106 content::DesktopMediaID source_id_; | |
| 107 | |
| 108 views::ImageView* image_view_; | |
| 109 views::Label* label_; | |
| 110 | |
| 111 bool selected_; | |
| 112 | |
| 113 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView); | |
| 114 }; | |
| 115 | 21 |
| 116 // Dialog view used for DesktopMediaPickerViews. | 22 // Dialog view used for DesktopMediaPickerViews. |
| 117 class DesktopMediaPickerDialogView : public views::DialogDelegateView, | 23 class DesktopMediaPickerDialogView : public views::DialogDelegateView, |
| 118 public views::TabbedPaneListener { | 24 public views::TabbedPaneListener { |
| 119 public: | 25 public: |
| 120 DesktopMediaPickerDialogView(content::WebContents* parent_web_contents, | 26 DesktopMediaPickerDialogView(content::WebContents* parent_web_contents, |
| 121 gfx::NativeWindow context, | 27 gfx::NativeWindow context, |
| 122 DesktopMediaPickerViews* parent, | 28 DesktopMediaPickerViews* parent, |
| 123 const base::string16& app_name, | 29 const base::string16& app_name, |
| 124 const base::string16& target_name, | 30 const base::string16& target_name, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 | 112 |
| 207 // The |dialog_| is owned by the corresponding views::Widget instance. | 113 // The |dialog_| is owned by the corresponding views::Widget instance. |
| 208 // When DesktopMediaPickerViews is destroyed the |dialog_| is destroyed | 114 // When DesktopMediaPickerViews is destroyed the |dialog_| is destroyed |
| 209 // asynchronously by closing the widget. | 115 // asynchronously by closing the widget. |
| 210 DesktopMediaPickerDialogView* dialog_; | 116 DesktopMediaPickerDialogView* dialog_; |
| 211 | 117 |
| 212 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerViews); | 118 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerViews); |
| 213 }; | 119 }; |
| 214 | 120 |
| 215 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_PICKER_VIEWS_H_ | 121 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_CAPTURE_DESKTOP_MEDIA_PICKER_VIEWS_H_ |
| OLD | NEW |