Revert of Remove OneClickSigninHelper since it is no longer used. (patchset #5 id...
[chromium-blink-merge.git] / remoting / host / single_window_desktop_environment.cc
blob3b721fce0e3fa83fb43a4b52aff603e3954c5a11
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);
33 private:
34 webrtc::WindowId window_id_;
36 DISALLOW_COPY_AND_ASSIGN(SingleWindowDesktopEnvironment);
39 SingleWindowDesktopEnvironment::~SingleWindowDesktopEnvironment() {
42 scoped_ptr<webrtc::DesktopCapturer>
43 SingleWindowDesktopEnvironment::CreateVideoCapturer() {
44 DCHECK(caller_task_runner()->BelongsToCurrentThread());
46 webrtc::DesktopCaptureOptions options =
47 webrtc::DesktopCaptureOptions::CreateDefault();
48 options.set_use_update_notifications(true);
50 scoped_ptr<webrtc::WindowCapturer>window_capturer(
51 webrtc::WindowCapturer::Create(options));
52 window_capturer->SelectWindow(window_id_);
54 return window_capturer.Pass();
57 scoped_ptr<InputInjector>
58 SingleWindowDesktopEnvironment::CreateInputInjector() {
59 DCHECK(caller_task_runner()->BelongsToCurrentThread());
61 scoped_ptr<InputInjector> input_injector(
62 InputInjector::Create(input_task_runner(),
63 ui_task_runner()));
64 return SingleWindowInputInjector::CreateForWindow(
65 window_id_, input_injector.Pass()).Pass();
68 SingleWindowDesktopEnvironment::SingleWindowDesktopEnvironment(
69 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
70 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
71 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
72 webrtc::WindowId window_id)
73 : BasicDesktopEnvironment(caller_task_runner,
74 input_task_runner,
75 ui_task_runner),
76 window_id_(window_id) {
79 SingleWindowDesktopEnvironmentFactory::SingleWindowDesktopEnvironmentFactory(
80 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
81 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
82 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
83 webrtc::WindowId window_id)
84 : BasicDesktopEnvironmentFactory(caller_task_runner,
85 input_task_runner,
86 ui_task_runner),
87 window_id_(window_id) {
90 SingleWindowDesktopEnvironmentFactory::
91 ~SingleWindowDesktopEnvironmentFactory() {
94 scoped_ptr<DesktopEnvironment> SingleWindowDesktopEnvironmentFactory::Create(
95 base::WeakPtr<ClientSessionControl> client_session_control) {
96 DCHECK(caller_task_runner()->BelongsToCurrentThread());
98 scoped_ptr<SingleWindowDesktopEnvironment> desktop_environment(
99 new SingleWindowDesktopEnvironment(caller_task_runner(),
100 input_task_runner(),
101 ui_task_runner(),
102 window_id_));
103 return desktop_environment.Pass();
106 } // namespace remoting