Commit 2faab020 authored by Santosh Mahto's avatar Santosh Mahto

Enabling mus in content_shell

parent 6bd1e0fc
......@@ -45,6 +45,7 @@ int main(int argc, const char** argv) {
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
params.env_mode = aura::Env::Mode::MUS;
return content::ContentMain(params);
#endif // OS_MACOSX
}
......
......@@ -10,10 +10,14 @@
]
},
"requires": {
"echo": [
"echo"
],
"ui": [ "test", "window_tree_host_factory" ]
"ui": [
"display_controller",
"external_window_tree_factory",
"ime_registrar",
"input_device_controller",
"window_manager",
"window_tree_host_factory_registrar"
]
}
},
"navigation:frame": {
......
......@@ -31,6 +31,8 @@
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
#include "ui/views/test/desktop_test_views_delegate.h"
#include "content/public/common/service_names.mojom.h"
#if defined(OS_ANDROID)
#include "base/message_loop/message_loop.h"
......@@ -40,6 +42,17 @@
#include "net/base/network_change_notifier.h"
#endif
#include "services/service_manager/public/cpp/connector.h"
#include "services/ui/public/interfaces/input_devices/input_device_server.mojom.h"
#include "services/ui/public/cpp/input_devices/input_device_client.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "ui/aura/env.h"
#include "content/public/common/service_manager_connection.h"
#include "services/service_manager/runner/common/client_util.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/ui/public/interfaces/ime/ime.mojom.h"
#if defined(USE_X11)
#include "ui/base/x/x11_util.h" // nogncheck
#endif
......@@ -96,12 +109,9 @@ base::StringPiece PlatformResourceProvider(int key) {
ShellBrowserMainParts::ShellBrowserMainParts(
const MainFunctionParams& parameters)
: parameters_(parameters),
run_message_loop_(true) {
}
: parameters_(parameters), run_message_loop_(true) {}
ShellBrowserMainParts::~ShellBrowserMainParts() {
}
ShellBrowserMainParts::~ShellBrowserMainParts() {}
#if !defined(OS_MACOSX)
void ShellBrowserMainParts::PreMainMessageLoopStart() {
......@@ -146,6 +156,7 @@ void ShellBrowserMainParts::InitializeBrowserContexts() {
}
void ShellBrowserMainParts::InitializeMessageLoopContext() {
LOG(INFO) << __PRETTY_FUNCTION__;
ui::MaterialDesignController::Initialize();
Shell::CreateNewWindow(browser_context_.get(), GetStartupURL(), nullptr,
gfx::Size());
......@@ -168,6 +179,90 @@ int ShellBrowserMainParts::PreCreateThreads() {
}
#endif
void ShellBrowserMainParts::ToolkitInitialized() {
#if defined(USE_AURA)
CHECK(aura::Env::GetInstance());
new views::DesktopTestViewsDelegate;
wm_state_.reset(new wm::WMState);
#endif // defined(USE_AURA)
}
class ShellInputMethod : public ui::mojom::InputMethod {
public:
explicit ShellInputMethod(ui::mojom::TextInputClientPtr client)
: client_(std::move(client)) {}
~ShellInputMethod() override {}
private:
void OnTextInputTypeChanged(ui::TextInputType text_input_type) override {}
void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {}
void ProcessKeyEvent(std::unique_ptr<ui::Event> key_event,
ProcessKeyEventCallback callback) override {
DCHECK(key_event->IsKeyEvent());
if (key_event->AsKeyEvent()->is_char()) {
client_->InsertChar(std::move(key_event));
std::move(callback).Run(true);
} else {
std::move(callback).Run(false);
}
}
void CancelComposition() override {}
ui::mojom::TextInputClientPtr client_;
DISALLOW_COPY_AND_ASSIGN(ShellInputMethod);
};
class ShellIMEDriver : public ui::mojom::IMEDriver {
public:
ShellIMEDriver() = default;
~ShellIMEDriver() override = default;
private:
void StartSession(ui::mojom::StartSessionDetailsPtr details) override {
mojo::MakeStrongBinding(
std::make_unique<ShellInputMethod>(
ui::mojom::TextInputClientPtr(std::move(details->client))),
std::move(details->input_method_request));
}
DISALLOW_COPY_AND_ASSIGN(ShellIMEDriver);
};
void ShellBrowserMainParts::ServiceManagerConnectionStarted(
ServiceManagerConnection* connection) {
#if defined(USE_AURA)
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL)
return;
input_device_client_ = base::MakeUnique<ui::InputDeviceClient>();
ui::mojom::InputDeviceServerPtr server;
connection->GetConnector()->BindInterface(ui::mojom::kServiceName, &server);
input_device_client_->Connect(std::move(server));
//IMEDriver::Register();
ui::mojom::IMEDriverPtr ime_driver_ptr;
mojo::MakeStrongBinding(base::MakeUnique<ShellIMEDriver>(),
MakeRequest(&ime_driver_ptr));
ui::mojom::IMERegistrarPtr ime_registrar;
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ui::mojom::kServiceName, &ime_registrar);
ime_registrar->RegisterDriver(std::move(ime_driver_ptr));
const bool create_wm_state = false;
mus_client_ = base::MakeUnique<views::MusClient>(
connection->GetConnector(), service_manager::Identity(),
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO),
create_wm_state);
#endif
}
void ShellBrowserMainParts::PreMainMessageLoopRun() {
net_log_.reset(new ShellNetLog("content_shell"));
InitializeBrowserContexts();
......@@ -183,7 +278,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
}
}
bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
return !run_message_loop_;
}
......@@ -204,4 +299,4 @@ void ShellBrowserMainParts::PostDestroyThreads() {
#endif
}
} // namespace
} // namespace content
......@@ -13,6 +13,9 @@
#include "content/public/common/main_function_params.h"
#include "content/shell/browser/shell_browser_context.h"
#include "ui/views/mus/mus_client.h"
#include "ui/wm/core/wm_state.h"
#include "services/ui/public/cpp/input_devices/input_device_client.h"
namespace net {
class NetLog;
}
......@@ -35,6 +38,9 @@ class ShellBrowserMainParts : public BrowserMainParts {
bool MainMessageLoopRun(int* result_code) override;
void PostMainMessageLoopRun() override;
void PostDestroyThreads() override;
void ToolkitInitialized() override;
void ServiceManagerConnectionStarted(ServiceManagerConnection* connection) override;
ShellBrowserContext* browser_context() { return browser_context_.get(); }
ShellBrowserContext* off_the_record_browser_context() {
......@@ -58,6 +64,9 @@ class ShellBrowserMainParts : public BrowserMainParts {
std::unique_ptr<net::NetLog> net_log_;
std::unique_ptr<ShellBrowserContext> browser_context_;
std::unique_ptr<ShellBrowserContext> off_the_record_browser_context_;
std::unique_ptr<ui::InputDeviceClient> input_device_client_;
std::unique_ptr<wm::WMState> wm_state_;
std::unique_ptr<views::MusClient> mus_client_;
// For running content_browsertests.
const MainFunctionParams parameters_;
......
......@@ -344,11 +344,11 @@ void Shell::PlatformInitialize(const gfx::Size& default_window_size) {
ui_context_factory);
#else
#if defined(USE_AURA)
wm_state_ = new wm::WMState;
//wm_state_ = new wm::WMState;
#endif
display::Screen::SetScreenInstance(views::CreateDesktopScreen());
//display::Screen::SetScreenInstance(views::CreateDesktopScreen());
#endif
views_delegate_ = new views::DesktopTestViewsDelegate();
//views_delegate_ = new views::DesktopTestViewsDelegate();
}
void Shell::PlatformExit() {
......@@ -401,6 +401,7 @@ void Shell::PlatformSetIsLoading(bool loading) {
}
void Shell::PlatformCreateWindow(int width, int height) {
LOG(INFO) << __PRETTY_FUNCTION__;
if (headless_) {
content_size_ = gfx::Size(width, height);
if (!platform_)
......@@ -415,6 +416,7 @@ void Shell::PlatformCreateWindow(int width, int height) {
wm_test_helper_->GetDefaultParent(nullptr, gfx::Rect()),
gfx::Rect(0, 0, width, height));
#else
LOG(INFO) << __PRETTY_FUNCTION__;
window_widget_ = new views::Widget;
views::Widget::InitParams params;
params.bounds = gfx::Rect(0, 0, width, height);
......
......@@ -4,6 +4,7 @@
#include "services/ui/ws/external_window_tree_factory.h"
#include "services/ui/ws/external_window_access_policy.h"
#include "services/ui/ws/window_manager_access_policy.h"
#include "services/ui/ws/window_server.h"
#include "services/ui/ws/window_server_delegate.h"
......@@ -36,7 +37,7 @@ void ExternalWindowTreeFactory::Register(
// FIXME(tonikitoo,msisov,fwang): Do we need our own AccessPolicy?
std::unique_ptr<ws::WindowTree> tree(
new ws::WindowTree(window_server_, user_id_, nullptr /*ServerWindow*/,
base::WrapUnique(new WindowManagerAccessPolicy)));
base::WrapUnique(new ExternalWindowAccessPolicy)));
std::unique_ptr<ws::DefaultWindowTreeBinding> tree_binding(
new ws::DefaultWindowTreeBinding(tree.get(), window_server_,
......
......@@ -110,9 +110,9 @@ MusClient::MusClient(service_manager::Connector* connector,
window_tree_client_ = std::make_unique<aura::WindowTreeClient>(
connector, this, nullptr /* window_manager_delegate */,
nullptr /* window_tree_client_request */, std::move(io_task_runner));
nullptr /* window_tree_client_request */, std::move(io_task_runner), false);
aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get());
window_tree_client_->ConnectViaWindowTreeFactory();
window_tree_client_->ConnectViaWindowTreeHostFactory();
pointer_watcher_event_router_ =
std::make_unique<PointerWatcherEventRouter>(window_tree_client_.get());
......@@ -124,10 +124,12 @@ MusClient::MusClient(service_manager::Connector* connector,
clipboard->Init(connector);
ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard));
ViewsDelegate::GetInstance()->set_native_widget_factory(
base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this)));
ViewsDelegate::NativeWidgetFactory factory = base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this));
if (ViewsDelegate::GetInstance()) {
ViewsDelegate::GetInstance()->set_native_widget_factory(factory);
ViewsDelegate::GetInstance()->set_desktop_window_tree_host_factory(base::Bind(
&MusClient::CreateDesktopWindowTreeHost, base::Unretained(this)));
}
}
MusClient::~MusClient() {
......@@ -298,7 +300,7 @@ std::unique_ptr<DesktopWindowTreeHost> MusClient::CreateDesktopWindowTreeHost(
void MusClient::OnEmbed(
std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
NOTREACHED();
//NOTREACHED();
}
void MusClient::OnLostConnection(aura::WindowTreeClient* client) {}
......
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