Skip to content

Commit

Permalink
Remote assistance on Chrome OS Part VIII - Compile on Ozone
Browse files Browse the repository at this point in the history
This CL makes It2Me host compile on platforms that uses Ozone.
It replaces the X11-based LocalInputMonitor, MouseCursorMonitor and InputInjector
with placeholder implementations for Chrome OS.
An actual implementation is provided for the LocalInputMonitor with code ported from
https://codereview.chromium.org/652293003/.

BUG=431876

Review URL: https://codereview.chromium.org/700333007

Cr-Commit-Position: refs/heads/master@{#303971}
  • Loading branch information
kelvinp authored and Commit bot committed Nov 13, 2014
1 parent fe48afd commit 18ffa03
Show file tree
Hide file tree
Showing 19 changed files with 447 additions and 114 deletions.
3 changes: 0 additions & 3 deletions chrome/browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ static_library("extensions") {
sources -= [
"global_shortcut_listener_chromeos.cc",
]
deps -= [
"//remoting/host/it2me:common",
]
}
if (!use_ozone) {
sources -= [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
#include "extensions/common/switches.h"
#include "extensions/common/url_pattern.h"
#include "net/url_request/url_request_context_getter.h"
#if defined(USE_X11)
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/it2me/it2me_native_messaging_host.h"
# endif // defined(USE_X11)
#include "ui/gfx/native_widget_types.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -97,9 +95,6 @@ struct BuiltInHost {
scoped_ptr<NativeMessageHost>(*create_function)();
};

// Remote assistance currently only supports X11.
// TODO(kelvinp): Migrate to ozone once it is ready (crbug.com/426716).
#if defined(USE_X11)
scoped_ptr<NativeMessageHost> CreateIt2MeHost() {
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableRemoteAssistance)) {
Expand Down Expand Up @@ -130,19 +125,16 @@ const char* const kRemotingIt2MeOrigins[] = {
"chrome-extension://dokpleeekgeeiehdhmdkeimnkmoifgdd/",
"chrome-extension://ajoainacpilcemgiakehflpbkbfipojk/",
"chrome-extension://hmboipgjngjoiaeicfdifdoeacilalgc/"};
#endif // defined(USE_X11)

static const BuiltInHost kBuiltInHost[] = {
{"com.google.chrome.test.echo", // ScopedTestNativeMessagingHost::kHostName
kEchoHostOrigins,
arraysize(kEchoHostOrigins),
&EchoHost::Create},
#if defined(USE_X11)
{"com.google.chrome.remote_assistance",
kRemotingIt2MeOrigins,
arraysize(kRemotingIt2MeOrigins),
&CreateIt2MeHost},
#endif // defined(USE_X11)
};

bool MatchesSecurityOrigin(const BuiltInHost& host,
Expand Down
12 changes: 3 additions & 9 deletions chrome/chrome_browser_extensions.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -965,19 +965,13 @@
],
'conditions': [
['chromeos==1', {
'conditions': [
['use_x11==1', {
'dependencies': [
'../remoting/remoting.gyp:remoting_it2me_host_static',
],
'include_dirs': [
'../third_party/libjingle/source',
],
}]
'include_dirs': [
'../third_party/libjingle/source',
],
'dependencies': [
'../build/linux/system.gyp:dbus',
'../chromeos/ime/input_method.gyp:gencode',
'../remoting/remoting.gyp:remoting_it2me_host_static',
'../third_party/libevent/libevent.gyp:libevent',
],
'sources': [
Expand Down
32 changes: 24 additions & 8 deletions remoting/host/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static_library("host") {
"//remoting/base",
"//remoting/protocol",
"//remoting/resources",
"//ui/events/platform",
"//ui/events:dom4_keycode_converter",
]

Expand All @@ -43,7 +44,11 @@ static_library("host") {
"//build/config/linux:x11",
]
} else {
sources -= [ "clipboard_x11.cc" ]
sources -= [
"clipboard_x11.cc",
"linux/x_server_clipboard.cc",
"linux/x_server_clipboard.h",
]
}

if (is_chromeos) {
Expand All @@ -63,19 +68,30 @@ static_library("host") {
deps += [ "//ash" ]
}

if (use_ozone) {
sources -= [
"input_injector_x11.cc",
"local_input_monitor_x11.cc",
]
} else {
sources -= [
"chromeos/mouse_cursor_monitor_aura.cc",
"chromeos/mouse_cursor_monitor_aura.h",
"clipboard_x11.cc",
"input_injector_chromeos.cc",
"input_injector_chromeos.h",
"linux/x_server_clipboard.cc",
"linux/x_server_clipboard.h",
"local_input_monitor_chromeos.cc",
]
}

sources -= [
"clipboard_x11.cc",
"continue_window_linux.cc",
"disconnect_window_linux.cc",
"policy_hack/policy_watcher_linux.cc",
"remoting_me2me_host.cc",
]

} else {
sources -= [
"clipboard_aura.cc",
"clipboard_aura.h",
]
}

if (is_mac) {
Expand Down
8 changes: 8 additions & 0 deletions remoting/host/basic_desktop_environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#if defined(OS_CHROMEOS)
#include "remoting/host/chromeos/aura_desktop_capturer.h"
#endif
#if defined(OS_CHROMEOS) && defined(USE_OZONE)
#include "remoting/host/chromeos/mouse_cursor_monitor_aura.h"
#endif
#include "remoting/host/client_session_control.h"
#include "remoting/host/gnubby_auth_handler.h"
#include "remoting/host/input_injector.h"
Expand Down Expand Up @@ -45,8 +48,13 @@ scoped_ptr<ScreenControls> BasicDesktopEnvironment::CreateScreenControls() {

scoped_ptr<webrtc::MouseCursorMonitor>
BasicDesktopEnvironment::CreateMouseCursorMonitor() {
#if defined(OS_CHROMEOS) && defined(USE_OZONE)
return make_scoped_ptr(
new MouseCursorMonitorAura(*desktop_capture_options_));
#else
return make_scoped_ptr(webrtc::MouseCursorMonitor::CreateForScreen(
*desktop_capture_options_, webrtc::kFullDesktopScreenId));
#endif
}

std::string BasicDesktopEnvironment::GetCapabilities() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/clipboard_aura.h"
#include "remoting/host/chromeos/clipboard_aura.h"

#include "base/strings/utf_string_conversions.h"
#include "base/timer/timer.h"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/clipboard_aura.h"
#include "remoting/host/chromeos/clipboard_aura.h"

#include "base/bind.h"
#include "base/bind_helpers.h"
Expand Down
35 changes: 35 additions & 0 deletions remoting/host/chromeos/mouse_cursor_monitor_aura.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/chromeos/mouse_cursor_monitor_aura.h"

#include "base/logging.h"

namespace remoting {

MouseCursorMonitorAura::MouseCursorMonitorAura(
const webrtc::DesktopCaptureOptions& options)
: callback_(nullptr),
mode_(SHAPE_AND_POSITION) {
}

MouseCursorMonitorAura::~MouseCursorMonitorAura() {
NOTIMPLEMENTED();
}

void MouseCursorMonitorAura::Init(Callback* callback, Mode mode) {
DCHECK(!callback_);
DCHECK(callback);

callback_ = callback;
mode_ = mode;

NOTIMPLEMENTED();
}

void MouseCursorMonitorAura::Capture() {
NOTIMPLEMENTED();
}

} // namespace remoting
32 changes: 32 additions & 0 deletions remoting/host/chromeos/mouse_cursor_monitor_aura.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_CHROMEOS_MOUSE_CURSOR_MONITOR_AURA_H_
#define REMOTING_HOST_CHROMEOS_MOUSE_CURSOR_MONITOR_AURA_H_

#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"

namespace remoting {

// A MouseCursorMonitor place holder implementation for Chrome OS with ozone.
// TODO(kelvinp): Implement this (See crbug.com/431457).
class MouseCursorMonitorAura : public webrtc::MouseCursorMonitor {
public:
explicit MouseCursorMonitorAura(const webrtc::DesktopCaptureOptions& options);
~MouseCursorMonitorAura() override;

void Init(Callback* callback, Mode mode) override;
void Capture() override;

private:
Callback* callback_;
Mode mode_;

DISALLOW_COPY_AND_ASSIGN(MouseCursorMonitorAura);
};

} // namespace remoting

#endif // REMOTING_HOST_CHROMEOS_MOUSE_CURSOR_MONITOR_AURA_H_
File renamed without changes.
58 changes: 58 additions & 0 deletions remoting/host/input_injector_chromeos.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "remoting/host/input_injector_chromeos.h"

#include "base/logging.h"
#include "remoting/proto/internal.pb.h"

namespace remoting {

using protocol::ClipboardEvent;
using protocol::KeyEvent;
using protocol::MouseEvent;
using protocol::TextEvent;

// TODO(kelvinp): Implement this class (See crbug.com/426716).
InputInjectorChromeos::InputInjectorChromeos(
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: input_task_runner_(task_runner) {
NOTIMPLEMENTED();
}

InputInjectorChromeos::~InputInjectorChromeos() {
NOTIMPLEMENTED();
}

void InputInjectorChromeos::InjectClipboardEvent(const ClipboardEvent& event) {
NOTIMPLEMENTED();
}

void InputInjectorChromeos::InjectKeyEvent(const KeyEvent& event) {
NOTIMPLEMENTED();
}

void InputInjectorChromeos::InjectTextEvent(const TextEvent& event) {
NOTIMPLEMENTED();
}

void InputInjectorChromeos::InjectMouseEvent(const MouseEvent& event) {
NOTIMPLEMENTED();
}

void InputInjectorChromeos::Start(
scoped_ptr<protocol::ClipboardStub> client_clipboard) {
NOTIMPLEMENTED();
}

// static
scoped_ptr<InputInjector> InputInjector::Create(
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
scoped_ptr<InputInjectorChromeos> injector(new InputInjectorChromeos(
ui_task_runner));
return injector.Pass();
}

} // namespace remoting
42 changes: 42 additions & 0 deletions remoting/host/input_injector_chromeos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_INPUT_INJECTOR_CHROMEOS_H_
#define REMOTING_HOST_INPUT_INJECTOR_CHROMEOS_H_

#include "base/single_thread_task_runner.h"
#include "remoting/host/input_injector.h"

namespace remoting {

// InputInjector implementation that translates input to ui::Events and passes
// them to a supplied delegate for injection into ChromeOS.
class InputInjectorChromeos : public InputInjector {
public:
explicit InputInjectorChromeos(
scoped_refptr<base::SingleThreadTaskRunner> task_runner);

~InputInjectorChromeos() override;

// Clipboard stub interface.
void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;

// InputStub interface.
void InjectKeyEvent(const protocol::KeyEvent& event) override;
void InjectTextEvent(const protocol::TextEvent& event) override;
void InjectMouseEvent(const protocol::MouseEvent& event) override;

// InputInjector interface.
void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override;

private:
// Task runner for input injection.
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;

DISALLOW_COPY_AND_ASSIGN(InputInjectorChromeos);
};

} // namespace remoting

#endif // REMOTING_HOST_INPUT_INJECTOR_CHROMEOS_H_
Loading

0 comments on commit 18ffa03

Please sign in to comment.