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

Side by Side Diff: chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc

Issue 1622733002: Add CombinedDesktopMediaList class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_base.h" 5 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_base.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/extensions/extension_tab_util.h" 12 #include "chrome/browser/extensions/extension_tab_util.h"
13 #include "chrome/browser/media/combined_desktop_media_list.h"
13 #include "chrome/browser/media/desktop_media_list_ash.h" 14 #include "chrome/browser/media/desktop_media_list_ash.h"
14 #include "chrome/browser/media/desktop_streams_registry.h" 15 #include "chrome/browser/media/desktop_streams_registry.h"
15 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 16 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
16 #include "chrome/browser/media/native_desktop_media_list.h" 17 #include "chrome/browser/media/native_desktop_media_list.h"
17 #include "chrome/browser/ui/ash/ash_util.h" 18 #include "chrome/browser/ui/ash/ash_util.h"
18 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" 22 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
22 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" 23 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 98 }
98 } 99 }
99 100
100 if (!show_screens && !show_windows) { 101 if (!show_screens && !show_windows) {
101 error_ = kEmptySourcesListError; 102 error_ = kEmptySourcesListError;
102 return false; 103 return false;
103 } 104 }
104 105
105 const gfx::NativeWindow parent_window = 106 const gfx::NativeWindow parent_window =
106 web_contents->GetTopLevelNativeWindow(); 107 web_contents->GetTopLevelNativeWindow();
107 scoped_ptr<DesktopMediaList> media_list; 108
109 std::vector<scoped_ptr<DesktopMediaList>> media_lists;
108 if (g_picker_factory) { 110 if (g_picker_factory) {
109 media_list = g_picker_factory->CreateModel( 111 scoped_ptr<DesktopMediaList> media_list =
110 show_screens, show_windows); 112 g_picker_factory->CreateModel(show_screens, show_windows);
113 media_lists.push_back(std::move(media_list));
111 picker_ = g_picker_factory->CreatePicker(); 114 picker_ = g_picker_factory->CreatePicker();
112 } else { 115 } else {
116 scoped_ptr<DesktopMediaList> screen_window_list;
113 #if defined(USE_ASH) 117 #if defined(USE_ASH)
114 if (chrome::IsNativeWindowInAsh(parent_window)) { 118 if (chrome::IsNativeWindowInAsh(parent_window)) {
115 media_list.reset(new DesktopMediaListAsh( 119 screen_window_list.reset(new DesktopMediaListAsh(
116 (show_screens ? DesktopMediaListAsh::SCREENS : 0) | 120 (show_screens ? DesktopMediaListAsh::SCREENS : 0) |
117 (show_windows ? DesktopMediaListAsh::WINDOWS : 0))); 121 (show_windows ? DesktopMediaListAsh::WINDOWS : 0)));
118 } 122 }
119 #endif 123 #endif
120 if (!media_list) { 124 if (!screen_window_list) {
121 webrtc::DesktopCaptureOptions options = 125 webrtc::DesktopCaptureOptions options =
122 webrtc::DesktopCaptureOptions::CreateDefault(); 126 webrtc::DesktopCaptureOptions::CreateDefault();
123 options.set_disable_effects(false); 127 options.set_disable_effects(false);
124 scoped_ptr<webrtc::ScreenCapturer> screen_capturer( 128 scoped_ptr<webrtc::ScreenCapturer> screen_capturer(
125 show_screens ? webrtc::ScreenCapturer::Create(options) : NULL); 129 show_screens ? webrtc::ScreenCapturer::Create(options) : NULL);
126 scoped_ptr<webrtc::WindowCapturer> window_capturer( 130 scoped_ptr<webrtc::WindowCapturer> window_capturer(
127 show_windows ? webrtc::WindowCapturer::Create(options) : NULL); 131 show_windows ? webrtc::WindowCapturer::Create(options) : NULL);
128 132
129 media_list.reset(new NativeDesktopMediaList(std::move(screen_capturer), 133 screen_window_list.reset(new NativeDesktopMediaList(
130 std::move(window_capturer))); 134 std::move(screen_capturer), std::move(window_capturer)));
131 } 135 }
132 136
137 media_lists.push_back(std::move(screen_window_list));
138
133 // DesktopMediaPicker is implemented only for Windows, OSX and 139 // DesktopMediaPicker is implemented only for Windows, OSX and
134 // Aura Linux builds. 140 // Aura Linux builds.
135 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX) 141 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
136 picker_ = DesktopMediaPicker::Create(); 142 picker_ = DesktopMediaPicker::Create();
137 #else 143 #else
138 error_ = "Desktop Capture API is not yet implemented for this platform."; 144 error_ = "Desktop Capture API is not yet implemented for this platform.";
139 return false; 145 return false;
140 #endif 146 #endif
141 } 147 }
148
149 scoped_ptr<CombinedDesktopMediaList> combined_list(
150 new CombinedDesktopMediaList(media_lists));
Sergey Ulanov 2016/01/27 00:36:31 Does this need to be part of this CL? media_lists
GeorgeZ 2016/01/27 22:57:16 This makes CombinedDesktopMediaList be part of liv
142 DesktopMediaPicker::DoneCallback callback = base::Bind( 151 DesktopMediaPicker::DoneCallback callback = base::Bind(
143 &DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults, 152 &DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults,
144 this); 153 this);
145 154
146 picker_->Show(web_contents, parent_window, parent_window, 155 picker_->Show(web_contents, parent_window, parent_window,
147 base::UTF8ToUTF16(extension()->name()), target_name, 156 base::UTF8ToUTF16(extension()->name()), target_name,
148 std::move(media_list), callback); 157 std::move(combined_list), callback);
149 origin_ = origin; 158 origin_ = origin;
150 return true; 159 return true;
151 } 160 }
152 161
153 void DesktopCaptureChooseDesktopMediaFunctionBase::WebContentsDestroyed() { 162 void DesktopCaptureChooseDesktopMediaFunctionBase::WebContentsDestroyed() {
154 Cancel(); 163 Cancel();
155 } 164 }
156 165
157 void DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults( 166 void DesktopCaptureChooseDesktopMediaFunctionBase::OnPickerDialogResults(
158 content::DesktopMediaID source) { 167 content::DesktopMediaID source) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 238
230 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id, 239 void DesktopCaptureRequestsRegistry::CancelRequest(int process_id,
231 int request_id) { 240 int request_id) {
232 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id)); 241 RequestsMap::iterator it = requests_.find(RequestId(process_id, request_id));
233 if (it != requests_.end()) 242 if (it != requests_.end())
234 it->second->Cancel(); 243 it->second->Cancel();
235 } 244 }
236 245
237 246
238 } // namespace extensions 247 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/combined_desktop_media_list.h » ('j') | chrome/browser/media/combined_desktop_media_list.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698