Commit cfd11748 authored by Denis Kuznetsov's avatar Denis Kuznetsov Committed by Commit Bot

Move the ChromeOS creation of It2Me messaging host to //remoting

Moving component so that it can be reused
by other targets.

Bug: 864455
Change-Id: I65886aebee703868d98b02b8db6f19faf457bcd4
Reviewed-on: https://chromium-review.googlesource.com/1173234Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Denis Kuznetsov <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582927}
parent 21f89769
...@@ -1004,7 +1004,7 @@ jumbo_static_library("extensions") { ...@@ -1004,7 +1004,7 @@ jumbo_static_library("extensions") {
"//components/user_manager", "//components/user_manager",
"//remoting/base", "//remoting/base",
"//remoting/host", "//remoting/host",
"//remoting/host/it2me:common", "//remoting/host/it2me:chrome_os_host",
"//services/video_capture/public/mojom:constants", "//services/video_capture/public/mojom:constants",
"//third_party/protobuf:protobuf_lite", "//third_party/protobuf:protobuf_lite",
"//ui/chromeos", "//ui/chromeos",
......
...@@ -12,12 +12,9 @@ ...@@ -12,12 +12,9 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/lazy_instance.h"
#include "base/location.h" #include "base/location.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
...@@ -26,18 +23,10 @@ ...@@ -26,18 +23,10 @@
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "extensions/common/url_pattern.h" #include "extensions/common/url_pattern.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "remoting/base/auto_thread_task_runner.h" #include "remoting/host/it2me/it2me_native_messaging_host_chromeos.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/it2me/it2me_native_messaging_host.h"
#include "remoting/host/policy_watcher.h"
#include "ui/events/system_input_injector.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "url/gurl.h" #include "url/gurl.h"
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
namespace extensions { namespace extensions {
namespace { namespace {
...@@ -102,52 +91,14 @@ struct BuiltInHost { ...@@ -102,52 +91,14 @@ struct BuiltInHost {
std::unique_ptr<NativeMessageHost> (*create_function)(); std::unique_ptr<NativeMessageHost> (*create_function)();
}; };
#if defined(USE_OZONE)
class OzoneSystemInputInjectorAdaptor : public ui::SystemInputInjectorFactory {
public:
std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector()
override {
return ui::OzonePlatform::GetInstance()->CreateSystemInputInjector();
}
};
base::LazyInstance<OzoneSystemInputInjectorAdaptor>::Leaky
g_ozone_system_input_injector_adaptor = LAZY_INSTANCE_INITIALIZER;
#endif
ui::SystemInputInjectorFactory* GetInputInjector() {
ui::SystemInputInjectorFactory* system = ui::GetSystemInputInjectorFactory();
if (system)
return system;
#if defined(USE_OZONE)
return g_ozone_system_input_injector_adaptor.Pointer();
#endif
return nullptr;
}
std::unique_ptr<NativeMessageHost> CreateIt2MeHost() { std::unique_ptr<NativeMessageHost> CreateIt2MeHost() {
std::unique_ptr<remoting::It2MeHostFactory> host_factory( return remoting::CreateIt2MeNativeMessagingHostForChromeOS(
new remoting::It2MeHostFactory()); g_browser_process->system_request_context(),
std::unique_ptr<remoting::ChromotingHostContext> context = content::BrowserThread::GetTaskRunnerForThread(
remoting::ChromotingHostContext::CreateForChromeOS( content::BrowserThread::IO),
base::WrapRefCounted(g_browser_process->system_request_context()), content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::GetTaskRunnerForThread( content::BrowserThread::UI),
content::BrowserThread::IO), g_browser_process->policy_service());
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI),
base::CreateSingleThreadTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT}),
GetInputInjector());
std::unique_ptr<remoting::PolicyWatcher> policy_watcher =
remoting::PolicyWatcher::CreateWithPolicyService(
g_browser_process->policy_service());
std::unique_ptr<NativeMessageHost> host(
new remoting::It2MeNativeMessagingHost(
/*needs_elevation=*/false, std::move(policy_watcher),
std::move(context), std::move(host_factory)));
return host;
} }
// If you modify the list of allowed_origins, don't forget to update // If you modify the list of allowed_origins, don't forget to update
......
...@@ -14,6 +14,9 @@ if (is_mac) { ...@@ -14,6 +14,9 @@ if (is_mac) {
import("//build/config/mac/rules.gni") import("//build/config/mac/rules.gni")
import("//third_party/icu/config.gni") import("//third_party/icu/config.gni")
} }
if (is_chromeos) {
import("//ui/ozone/ozone.gni")
}
source_set("common") { source_set("common") {
sources = [ sources = [
...@@ -49,7 +52,6 @@ source_set("common") { ...@@ -49,7 +52,6 @@ source_set("common") {
"//remoting/resources", "//remoting/resources",
"//remoting/signaling", "//remoting/signaling",
] ]
if (is_desktop_linux) { if (is_desktop_linux) {
deps += [ deps += [
"//build/config/linux/gtk", "//build/config/linux/gtk",
...@@ -62,6 +64,24 @@ source_set("common") { ...@@ -62,6 +64,24 @@ source_set("common") {
} }
} }
if (is_chromeos) {
source_set("chrome_os_host") {
sources = [
"it2me_native_messaging_host_chromeos.cc",
"it2me_native_messaging_host_chromeos.h",
]
deps = [
":common",
"//skia",
]
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
}
}
if (!is_chromeos && enable_remoting_host) { if (!is_chromeos && enable_remoting_host) {
if (is_win) { if (is_win) {
executable("remote_assistance_host") { executable("remote_assistance_host") {
......
specific_include_rules = { specific_include_rules = {
"native_message_host_chromeos.cc": [ "it2me_native_messaging_host_chromeos.cc": [
# TODO(erg): This allows us to switch between mus and classic ash/ozone as # TODO(erg): This allows us to switch between mus and classic ash/ozone as
# targets. It should be removed when support for classic ash is removed; # targets. It should be removed when support for classic ash is removed;
# which means that remoting never touches ozone. # which means that remoting never touches ozone.
......
...@@ -27,6 +27,14 @@ class Value; ...@@ -27,6 +27,14 @@ class Value;
class SingleThreadTaskRunner; class SingleThreadTaskRunner;
} // namespace base } // namespace base
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace policy {
class PolicyService;
} // namespace policy
namespace remoting { namespace remoting {
class ChromotingHostContext; class ChromotingHostContext;
...@@ -63,6 +71,16 @@ class It2MeNativeMessagingHost : public It2MeHost::Observer, ...@@ -63,6 +71,16 @@ class It2MeNativeMessagingHost : public It2MeHost::Observer,
static std::string HostStateToString(It2MeHostState host_state); static std::string HostStateToString(It2MeHostState host_state);
#if defined(OS_CHROMEOS)
// Creates native messaging host on ChromeOS. Must be called on the UI thread
// of the browser process.
static std::unique_ptr<extensions::NativeMessageHost> CreateForChromeOS(
net::URLRequestContextGetter* system_request_context,
scoped_refptr<base::SingleThreadTaskRunner> io_runnner,
scoped_refptr<base::SingleThreadTaskRunner> ui_runnner,
policy::PolicyService* policy_service);
#endif // defined(OS_CHROMEOS)
private: private:
// These "Process.." methods handle specific request types. The |response| // These "Process.." methods handle specific request types. The |response|
// dictionary is pre-filled by ProcessMessage() with the parts of the // dictionary is pre-filled by ProcessMessage() with the parts of the
......
// Copyright 2018 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/it2me/it2me_native_messaging_host_chromeos.h"
#include <memory>
#include "base/lazy_instance.h"
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
#include "net/url_request/url_request_context_getter.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/it2me/it2me_native_messaging_host.h"
#include "remoting/host/policy_watcher.h"
#include "ui/events/system_input_injector.h"
#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
namespace {
#if defined(USE_OZONE)
class OzoneSystemInputInjectorAdaptor
: public ::ui::SystemInputInjectorFactory {
public:
std::unique_ptr<ui::SystemInputInjector> CreateSystemInputInjector()
override {
return ui::OzonePlatform::GetInstance()->CreateSystemInputInjector();
}
};
base::LazyInstance<OzoneSystemInputInjectorAdaptor>::Leaky
g_ozone_system_input_injector_adaptor = LAZY_INSTANCE_INITIALIZER;
#endif
ui::SystemInputInjectorFactory* GetInputInjector() {
ui::SystemInputInjectorFactory* system = ui::GetSystemInputInjectorFactory();
if (system)
return system;
#if defined(USE_OZONE)
return g_ozone_system_input_injector_adaptor.Pointer();
#endif
return nullptr;
}
} // namespace
namespace remoting {
std::unique_ptr<extensions::NativeMessageHost>
CreateIt2MeNativeMessagingHostForChromeOS(
net::URLRequestContextGetter* system_request_context,
scoped_refptr<base::SingleThreadTaskRunner> io_runnner,
scoped_refptr<base::SingleThreadTaskRunner> ui_runnner,
policy::PolicyService* policy_service) {
std::unique_ptr<It2MeHostFactory> host_factory(new It2MeHostFactory());
std::unique_ptr<ChromotingHostContext> context =
ChromotingHostContext::CreateForChromeOS(
base::WrapRefCounted(system_request_context), io_runnner, ui_runnner,
base::CreateSingleThreadTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT}),
GetInputInjector());
std::unique_ptr<PolicyWatcher> policy_watcher =
PolicyWatcher::CreateWithPolicyService(policy_service);
std::unique_ptr<extensions::NativeMessageHost> host(
new It2MeNativeMessagingHost(
/*needs_elevation=*/false, std::move(policy_watcher),
std::move(context), std::move(host_factory)));
return host;
}
} // namespace remoting
// Copyright 2018 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_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_CHROMEOS_H_
#define REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_CHROMEOS_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "extensions/browser/api/messaging/native_message_host.h"
namespace base {
class SingleThreadTaskRunner;
} // namespace base
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace policy {
class PolicyService;
} // namespace policy
namespace remoting {
// Creates native messaging host on ChromeOS. Must be called on the UI thread
// of the browser process.
std::unique_ptr<extensions::NativeMessageHost>
CreateIt2MeNativeMessagingHostForChromeOS(
net::URLRequestContextGetter* system_request_context,
scoped_refptr<base::SingleThreadTaskRunner> io_runnner,
scoped_refptr<base::SingleThreadTaskRunner> ui_runnner,
policy::PolicyService* policy_service);
} // namespace remoting
#endif // REMOTING_HOST_IT2ME_IT2ME_NATIVE_MESSAGING_HOST_CHROMEOS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment