Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / remoting / host / single_window_desktop_environment.cc
blob15da395237f0b49ff001acf98978773a7fd884d1
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.
5 #include "remoting/host/single_window_desktop_environment.h"
7 #include "base/logging.h"
8 #include "base/single_thread_task_runner.h"
9 #include "remoting/host/single_window_input_injector.h"
10 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
11 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
13 namespace remoting {
15 // Enables capturing and streaming of windows.
16 class SingleWindowDesktopEnvironment : public BasicDesktopEnvironment {
18 public:
19 ~SingleWindowDesktopEnvironment() override;
21 // DesktopEnvironment interface.
22 scoped_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() override;
23 scoped_ptr<InputInjector> CreateInputInjector() override;
25 protected:
26 friend class SingleWindowDesktopEnvironmentFactory;
27 SingleWindowDesktopEnvironment(
28 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
29 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
30 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
31 webrtc::WindowId window_id,
32 bool supports_touch_events);
34 private:
35 webrtc::WindowId window_id_;
37 DISALLOW_COPY_AND_ASSIGN(SingleWindowDesktopEnvironment);
40 SingleWindowDesktopEnvironment::~SingleWindowDesktopEnvironment() {
43 scoped_ptr<webrtc::DesktopCapturer>
44 SingleWindowDesktopEnvironment::CreateVideoCapturer() {
45 DCHECK(caller_task_runner()->BelongsToCurrentThread());
47 webrtc::DesktopCaptureOptions options =
48 webrtc::DesktopCaptureOptions::CreateDefault();
49 options.set_use_update_notifications(true);
51 scoped_ptr<webrtc::WindowCapturer>window_capturer(
52 webrtc::WindowCapturer::Create(options));
53 window_capturer->SelectWindow(window_id_);
55 return window_capturer.Pass();
58 scoped_ptr<InputInjector>
59 SingleWindowDesktopEnvironment::CreateInputInjector() {
60 DCHECK(caller_task_runner()->BelongsToCurrentThread());
62 scoped_ptr<InputInjector> input_injector(
63 InputInjector::Create(input_task_runner(),
64 ui_task_runner()));
65 return SingleWindowInputInjector::CreateForWindow(
66 window_id_, input_injector.Pass()).Pass();
69 SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment(
70 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
71 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
73 webrtc::WindowId window_id,
74 bool supports_touch_events)
75 : BasicDesktopEnvironment(caller_task_runner,
76 input_task_runner,
77 ui_task_runner,
78 supports_touch_events),
79 window_id_(window_id) {
82 SingleWindowDesktopEnvironmentFactory::SingleWindowDesktopEnvironmentFactory(
83 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
84 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
85 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
86 webrtc::WindowId window_id)
87 : BasicDesktopEnvironmentFactory(caller_task_runner,
88 input_task_runner,
89 ui_task_runner),
90 window_id_(window_id) {
93 SingleWindowDesktopEnvironmentFactory::
94 ~SingleWindowDesktopEnvironmentFactory() {
97 scoped_ptr<DesktopEnvironment> SingleWindowDesktopEnvironmentFactory::Create(
98 base::WeakPtr<ClientSessionControl> client_session_control) {
99 DCHECK(caller_task_runner()->BelongsToCurrentThread());
101 scoped_ptr<SingleWindowDesktopEnvironment> desktop_environment(
102 new SingleWindowDesktopEnvironment(caller_task_runner(),
103 input_task_runner(),
104 ui_task_runner(),
105 window_id_,
106 supports_touch_events()));
107 return desktop_environment.Pass();
110 } // namespace remoting