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

Side by Side Diff: chrome/browser/ui/views/desktop_media_picker_views_deprecated.h

Issue 1958293002: Revert "Desktop Capture Picker New UI: Non Mac Structure Change" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_DESKTOP_MEDIA_PICKER_VIEWS_DEPRECATED_H_
6 #define CHROME_BROWSER_UI_VIEWS_DESKTOP_MEDIA_PICKER_VIEWS_DEPRECATED_H_
7
8 #include "base/macros.h"
9 #include "chrome/browser/media/desktop_media_list_observer.h"
10 #include "chrome/browser/media/desktop_media_picker.h"
11 #include "ui/views/window/dialog_delegate.h"
12
13 namespace views {
14 class ImageView;
15 class Label;
16 class Checkbox;
17 } // namespace views
18
19 // TODO(qiangchen): Remove this file after new UI is done, and remove related
20 // resource strings, such as IDS_DESKTOP_MEDIA_PICKER_AUDIO_SHARE_TOOLTIP_NONE.
21 namespace deprecated {
22
23 class DesktopMediaPickerDialogView;
24 class DesktopMediaPickerViews;
25 class DesktopMediaSourceView;
26
27 // View that shows a list of desktop media sources available from
28 // DesktopMediaList.
29 class DesktopMediaListView : public views::View,
30 public DesktopMediaListObserver {
31 public:
32 DesktopMediaListView(DesktopMediaPickerDialogView* parent,
33 std::unique_ptr<DesktopMediaList> media_list);
34 ~DesktopMediaListView() override;
35
36 void StartUpdating(content::DesktopMediaID dialog_window_id);
37
38 // Called by DesktopMediaSourceView when selection has changed.
39 void OnSelectionChanged();
40
41 // Called by DesktopMediaSourceView when a source has been double-clicked.
42 void OnDoubleClick();
43
44 // Returns currently selected source.
45 DesktopMediaSourceView* GetSelection();
46
47 // views::View overrides.
48 gfx::Size GetPreferredSize() const override;
49 void Layout() override;
50 bool OnKeyPressed(const ui::KeyEvent& event) override;
51
52 private:
53 // DesktopMediaList::Observer interface
54 void OnSourceAdded(DesktopMediaList* list, int index) override;
55 void OnSourceRemoved(DesktopMediaList* list, int index) override;
56 void OnSourceMoved(DesktopMediaList* list,
57 int old_index,
58 int new_index) override;
59 void OnSourceNameChanged(DesktopMediaList* list, int index) override;
60 void OnSourceThumbnailChanged(DesktopMediaList* list, int index) override;
61
62 // Accepts whatever happens to be selected right now.
63 void AcceptSelection();
64
65 DesktopMediaPickerDialogView* parent_;
66 std::unique_ptr<DesktopMediaList> media_list_;
67 base::WeakPtrFactory<DesktopMediaListView> weak_factory_;
68
69 DISALLOW_COPY_AND_ASSIGN(DesktopMediaListView);
70 };
71
72 // View used for each item in DesktopMediaListView. Shows a single desktop media
73 // source as a thumbnail with the title under it.
74 class DesktopMediaSourceView : public views::View {
75 public:
76 DesktopMediaSourceView(DesktopMediaListView* parent,
77 content::DesktopMediaID source_id);
78 ~DesktopMediaSourceView() override;
79
80 // Updates thumbnail and title from |source|.
81 void SetName(const base::string16& name);
82 void SetThumbnail(const gfx::ImageSkia& thumbnail);
83
84 // Id for the source shown by this View.
85 const content::DesktopMediaID& source_id() const { return source_id_; }
86
87 // Returns true if the source is selected.
88 bool is_selected() const { return selected_; }
89
90 // views::View interface.
91 const char* GetClassName() const override;
92 void Layout() override;
93 views::View* GetSelectedViewForGroup(int group) override;
94 bool IsGroupFocusTraversable() const override;
95 void OnPaint(gfx::Canvas* canvas) override;
96 void OnFocus() override;
97 void OnBlur() override;
98 bool OnMousePressed(const ui::MouseEvent& event) override;
99 void OnGestureEvent(ui::GestureEvent* event) override;
100
101 private:
102 // Updates selection state of the element. If |selected| is true then also
103 // calls SetSelected(false) for the source view that was selected before that
104 // (if any).
105 void SetSelected(bool selected);
106
107 DesktopMediaListView* parent_;
108 content::DesktopMediaID source_id_;
109
110 views::ImageView* image_view_;
111 views::Label* label_;
112
113 bool selected_;
114
115 DISALLOW_COPY_AND_ASSIGN(DesktopMediaSourceView);
116 };
117
118 // Dialog view used for DesktopMediaPickerViews.
119 class DesktopMediaPickerDialogView : public views::DialogDelegateView {
120 public:
121 DesktopMediaPickerDialogView(content::WebContents* parent_web_contents,
122 gfx::NativeWindow context,
123 DesktopMediaPickerViews* parent,
124 const base::string16& app_name,
125 const base::string16& target_name,
126 std::unique_ptr<DesktopMediaList> screen_list,
127 std::unique_ptr<DesktopMediaList> window_list,
128 std::unique_ptr<DesktopMediaList> tab_list,
129 bool request_audio);
130 ~DesktopMediaPickerDialogView() override;
131
132 // Called by parent (DesktopMediaPickerViews) when it's destroyed.
133 void DetachParent();
134
135 // Called by DesktopMediaListView.
136 void OnSelectionChanged();
137 void OnDoubleClick();
138
139 // views::View overrides.
140 gfx::Size GetPreferredSize() const override;
141
142 // views::DialogDelegateView overrides.
143 ui::ModalType GetModalType() const override;
144 base::string16 GetWindowTitle() const override;
145 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
146 views::View* GetInitiallyFocusedView() override;
147 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
148 bool Accept() override;
149 void DeleteDelegate() override;
150
151 void OnMediaListRowsChanged();
152
153 DesktopMediaListView* GetMediaListViewForTesting() const;
154 DesktopMediaSourceView* GetMediaSourceViewForTesting(int index) const;
155
156 private:
157 DesktopMediaPickerViews* parent_;
158 base::string16 app_name_;
159
160 views::Label* description_label_;
161
162 // |audio_share_checked_| records whether the user permits audio, when
163 // |audio_share_checkbox_| is disabled.
164 views::Checkbox* audio_share_checkbox_;
165 bool audio_share_checked_;
166
167 views::ScrollView* sources_scroll_view_;
168 DesktopMediaListView* sources_list_view_;
169
170 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerDialogView);
171 };
172
173 // Implementation of DesktopMediaPicker for Views.
174 class DesktopMediaPickerViews : public DesktopMediaPicker {
175 public:
176 DesktopMediaPickerViews();
177 ~DesktopMediaPickerViews() override;
178
179 void NotifyDialogResult(content::DesktopMediaID source);
180
181 // DesktopMediaPicker overrides.
182 void Show(content::WebContents* web_contents,
183 gfx::NativeWindow context,
184 gfx::NativeWindow parent,
185 const base::string16& app_name,
186 const base::string16& target_name,
187 std::unique_ptr<DesktopMediaList> screen_list,
188 std::unique_ptr<DesktopMediaList> window_list,
189 std::unique_ptr<DesktopMediaList> tab_list,
190 bool request_audio,
191 const DoneCallback& done_callback) override;
192
193 DesktopMediaPickerDialogView* GetDialogViewForTesting() const {
194 return dialog_;
195 }
196
197 private:
198 DoneCallback callback_;
199
200 // The |dialog_| is owned by the corresponding views::Widget instance.
201 // When DesktopMediaPickerViews is destroyed the |dialog_| is destroyed
202 // asynchronously by closing the widget.
203 DesktopMediaPickerDialogView* dialog_;
204
205 DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerViews);
206 };
207
208 } // namespace deprecated
209
210 #endif // CHROME_BROWSER_UI_VIEWS_DESKTOP_MEDIA_PICKER_VIEWS_DEPRECATED_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698