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

Side by Side Diff: webrtc/modules/desktop_capture/window_capturer.cc

Issue 2452263003: Add DesktopCapturer GetSourceList SelectSource FocusOnSelectedSource functions (Closed)
Patch Set: Created 4 years, 1 month 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 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/desktop_capture/window_capturer.h"
12
13 #include <string>
14 #include <utility>
15
16 namespace webrtc {
17
18 WindowCapturer::~WindowCapturer() = default;
19
20 bool WindowCapturer::GetWindowList(WindowList* windows) {
21 SourceList sources;
22 if (!GetSourceList(&sources)) {
23 return false;
24 }
25
26 for (const Source& source : sources) {
27 if (source.type == SourceType::WINDOW) {
28 windows->push_back({source.window_id(), std::move(source.title)});
29 }
30 }
31 return true;
32 }
33
34 bool WindowCapturer::SelectWindow(WindowId id) {
35 return SelectSource(Source::NewWindow(id, std::string()));
36 }
37
38 bool WindowCapturer::BringSelectedWindowToFront() {
39 return FocusOnSelectedSource();
40 }
41
42 bool WindowCapturer::GetSourceList(SourceList* sources) {
43 WindowList windows;
44 if (!GetWindowList(&windows)) {
45 return false;
46 }
47
48 for (const Window& window : windows) {
49 sources->push_back(Source::NewWindow(window.id, window.title));
50 }
51
52 return true;
53 }
54
55 bool WindowCapturer::SelectSource(const Source& source) {
56 if (source.type != SourceType::WINDOW) {
57 return false;
58 }
59
60 return SelectWindow(source.window_id());
61 }
62
63 bool WindowCapturer::FocusOnSelectedSource() {
64 return BringSelectedWindowToFront();
65 }
66
67 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698