Commit d7c088c6 authored by ben@chromium.org's avatar ben@chromium.org

As discussed, a new WM bootstrap flow.

First off, create a new window manager app (wm_flow_wm) which uses the core_window_manager_lib static lib to implement a basic WM.

Second, create a new demo launcher (wm_flow_init) that starts the view manager, embeds wm_flow_wm, and starts an additional app (wm_flow_app).

Thirdly, creates an additional app (wm_flow_app) that also connects to the view manager init service and asks it to embed it somewhere, thus giving it a connection to the view manager (and a top-level window).

I had to change ViewManagerInitService to have some shared state so that it was possible to connect to it > 1 time.

R=sky@chromium.org
BUG=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285345 0039d316-1c4b-4281-b951-d872f2087c98
parent 90e3b587
// 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 "base/bind.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/services/public/cpp/view_manager/node.h"
#include "mojo/services/public/cpp/view_manager/view.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
#include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
namespace examples {
namespace {
void ConnectCallback(bool success) {}
const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW };
} // namespace
// This app starts its life via Connect() rather than by being embed, so it does
// not start with a connection to the ViewManager service. It has to obtain a
// connection by connecting to the ViewManagerInit service and asking to be
// embed without a node context.
class WMFlowApp : public mojo::ApplicationDelegate,
public mojo::view_manager::ViewManagerDelegate {
public:
WMFlowApp() : embed_count_(0), view_manager_client_factory_(this) {}
virtual ~WMFlowApp() {}
private:
// Overridden from Application:
virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
mojo::view_manager::ViewManagerInitServicePtr init_svc;
app->ConnectToService("mojo:mojo_view_manager", &init_svc);
init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
}
virtual bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
connection->AddService(&view_manager_client_factory_);
return true;
}
void OnConnect(bool success) {}
// Overridden from mojo::view_manager::ViewManagerDelegate:
virtual void OnRootAdded(mojo::view_manager::ViewManager* view_manager,
mojo::view_manager::Node* root) MOJO_OVERRIDE {
mojo::view_manager::View* view =
mojo::view_manager::View::Create(view_manager);
root->SetActiveView(view);
view->SetColor(kColors[embed_count_++ % arraysize(kColors)]);
}
virtual void OnViewManagerDisconnected(
mojo::view_manager::ViewManager* view_manager) MOJO_OVERRIDE {}
int embed_count_;
mojo::view_manager::ViewManagerClientFactory view_manager_client_factory_;
DISALLOW_COPY_AND_ASSIGN(WMFlowApp);
};
} // namespace examples
namespace mojo {
// static
ApplicationDelegate* ApplicationDelegate::Create() {
return new examples::WMFlowApp;
}
} // namespace
// 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 "base/bind.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
namespace examples {
namespace {
void ConnectCallback(bool success) {}
} // namespace
// This application starts the view manager, embeds the window manager and then
// starts another app (wm_flow_app) which also connects to the view manager and
// asks to be embedded without context.
class WMFlowInit : public mojo::ApplicationDelegate {
public:
WMFlowInit() {}
virtual ~WMFlowInit() {}
private:
// Overridden from Application:
virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
app->ConnectToService("mojo:mojo_view_manager", &view_manager_init_);
view_manager_init_->Embed("mojo:mojo_wm_flow_wm",
base::Bind(&ConnectCallback));
app->ConnectToApplication("mojo:mojo_wm_flow_app");
}
void OnConnect(bool success) {}
mojo::view_manager::ViewManagerInitServicePtr view_manager_init_;
DISALLOW_COPY_AND_ASSIGN(WMFlowInit);
};
} // namespace examples
namespace mojo {
// static
ApplicationDelegate* ApplicationDelegate::Create() {
return new examples::WMFlowInit;
}
} // namespace
// 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 "mojo/public/cpp/application/application_delegate.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/cpp/view_manager/window_manager_delegate.h"
#include "mojo/services/window_manager/window_manager_app.h"
namespace examples {
class SimpleWM : public mojo::ApplicationDelegate,
public mojo::view_manager::ViewManagerDelegate,
public mojo::view_manager::WindowManagerDelegate {
public:
SimpleWM()
: window_manager_app_(new mojo::WindowManagerApp(this)),
view_manager_(NULL),
root_(NULL),
window_container_(NULL),
next_window_origin_(10, 10) {}
virtual ~SimpleWM() {}
private:
// Overridden from mojo::ApplicationDelegate:
virtual void Initialize(mojo::ApplicationImpl* impl) MOJO_OVERRIDE {
window_manager_app_->Initialize(impl);
}
virtual bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
window_manager_app_->ConfigureIncomingConnection(connection);
return true;
}
// Overridden from mojo::view_manager::ViewManagerDelegate:
virtual void OnRootAdded(
mojo::view_manager::ViewManager* view_manager,
mojo::view_manager::Node* root) MOJO_OVERRIDE {
view_manager_ = view_manager;
root_ = root;
view_manager_->SetWindowManagerDelegate(this);
window_container_ = mojo::view_manager::Node::Create(view_manager_);
window_container_->SetBounds(root_->bounds());
root_->AddChild(window_container_);
}
virtual void OnViewManagerDisconnected(
mojo::view_manager::ViewManager* view_manager) MOJO_OVERRIDE {
view_manager_ = NULL;
root_ = NULL;
}
// Overridden from mojo::view_manager::WindowManagerDelegate:
virtual void Embed(const mojo::String& url) MOJO_OVERRIDE {
mojo::view_manager::Node* embed_node =
mojo::view_manager::Node::Create(view_manager_);
embed_node->SetBounds(gfx::Rect(next_window_origin_, gfx::Size(400, 400)));
window_container_->AddChild(embed_node);
embed_node->Embed(url);
next_window_origin_.Offset(50, 50);
}
virtual void DispatchEvent(mojo::view_manager::View* target,
mojo::EventPtr event) MOJO_OVERRIDE {
view_manager_->DispatchEvent(target, event.Pass());
}
scoped_ptr<mojo::WindowManagerApp> window_manager_app_;
mojo::view_manager::ViewManager* view_manager_;
mojo::view_manager::Node* root_;
mojo::view_manager::Node* window_container_;
gfx::Point next_window_origin_;
DISALLOW_COPY_AND_ASSIGN(SimpleWM);
};
} // namespace examples
namespace mojo {
// static
ApplicationDelegate* ApplicationDelegate::Create() {
return new examples::SimpleWM;
}
} // namespace
......@@ -118,6 +118,9 @@
'mojo_media_viewer',
'mojo_nesting_app',
'mojo_window_manager',
'mojo_wm_flow_app',
'mojo_wm_flow_init',
'mojo_wm_flow_wm',
'mojo_view_manager',
'mojo_view_manager_unittests',
],
......
......@@ -594,6 +594,53 @@
'public/cpp/application/lib/mojo_main_chromium.cc',
],
},
{
'target_name': 'mojo_wm_flow_wm',
'type': 'loadable_module',
'dependencies': [
'../base/base.gyp:base',
'mojo_application',
'mojo_environment_chromium',
'mojo_core_window_manager_lib',
'mojo_view_manager_lib',
'<(mojo_system_for_loadable_module)',
],
'sources': [
'examples/wm_flow/wm/wm.cc',
'public/cpp/application/lib/mojo_main_chromium.cc',
],
},
{
'target_name': 'mojo_wm_flow_init',
'type': 'loadable_module',
'dependencies': [
'../base/base.gyp:base',
'mojo_application',
'mojo_environment_chromium',
'mojo_view_manager_bindings',
'<(mojo_system_for_loadable_module)',
],
'sources': [
'examples/wm_flow/init/init.cc',
'public/cpp/application/lib/mojo_main_chromium.cc',
],
},
{
'target_name': 'mojo_wm_flow_app',
'type': 'loadable_module',
'dependencies': [
'../base/base.gyp:base',
'mojo_application',
'mojo_environment_chromium',
'mojo_core_window_manager_bindings',
'mojo_view_manager_lib',
'<(mojo_system_for_loadable_module)',
],
'sources': [
'examples/wm_flow/app/app.cc',
'public/cpp/application/lib/mojo_main_chromium.cc',
],
},
],
}],
['OS=="linux"', {
......
......@@ -724,6 +724,8 @@
'services/view_manager/view.cc',
'services/view_manager/view.h',
'services/view_manager/view_manager_export.h',
'services/view_manager/view_manager_init_service_context.cc',
'services/view_manager/view_manager_init_service_context.h',
'services/view_manager/view_manager_init_service_impl.cc',
'services/view_manager/view_manager_init_service_impl.h',
'services/view_manager/view_manager_service_impl.cc',
......@@ -802,8 +804,8 @@
'includes': [ 'build/package_app.gypi' ],
},
{
'target_name': 'mojo_core_window_manager',
'type': 'loadable_module',
'target_name': 'mojo_core_window_manager_lib',
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base',
'../ui/base/ui_base.gyp:ui_base',
......@@ -816,16 +818,26 @@
'mojo_core_window_manager_bindings',
'mojo_environment_chromium',
'mojo_view_manager_lib',
'<(mojo_system_for_loadable_module)',
],
'sources': [
'public/cpp/application/lib/mojo_main_chromium.cc',
'services/window_manager/window_manager_app.cc',
'services/window_manager/window_manager_app.h',
'services/window_manager/window_manager_service_impl.cc',
'services/window_manager/window_manager_service_impl.h',
],
},
{
'target_name': 'mojo_core_window_manager',
'type': 'loadable_module',
'dependencies': [
'mojo_core_window_manager_lib',
'<(mojo_system_for_loadable_module)',
],
'sources': [
'public/cpp/application/lib/mojo_main_chromium.cc',
'services/window_manager/main.cc',
],
},
{
'target_name': 'mojo_core_window_manager_unittests',
'type': 'executable',
......
......@@ -4,6 +4,7 @@
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/services/view_manager/view_manager_init_service_context.h"
#include "mojo/services/view_manager/view_manager_init_service_impl.h"
namespace mojo {
......@@ -18,6 +19,7 @@ class ViewManagerApp : public ApplicationDelegate,
virtual bool ConfigureIncomingConnection(
ApplicationConnection* connection) OVERRIDE {
context_.ConfigureIncomingConnection(connection);
// TODO(sky): this needs some sort of authentication as well as making sure
// we only ever have one active at a time.
connection->AddService(this);
......@@ -27,10 +29,13 @@ class ViewManagerApp : public ApplicationDelegate,
virtual void Create(
ApplicationConnection* connection,
InterfaceRequest<ViewManagerInitService> request) OVERRIDE {
BindToRequest(new ViewManagerInitServiceImpl(connection), &request);
BindToRequest(new ViewManagerInitServiceImpl(connection, &context_),
&request);
}
private:
ViewManagerInitServiceContext context_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerApp);
};
......
// 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 "mojo/services/view_manager/view_manager_init_service_context.h"
#include "base/bind.h"
#include "mojo/services/view_manager/root_node_manager.h"
#include "mojo/services/view_manager/view_manager_init_service_impl.h"
namespace mojo {
namespace view_manager {
namespace service {
ViewManagerInitServiceContext::ViewManagerInitServiceContext()
: is_tree_host_ready_(false) {}
ViewManagerInitServiceContext::~ViewManagerInitServiceContext() {}
void ViewManagerInitServiceContext::AddConnection(
ViewManagerInitServiceImpl* connection) {
DCHECK(std::find(connections_.begin(), connections_.end(), connection) ==
connections_.end());
connections_.push_back(connection);
}
void ViewManagerInitServiceContext::RemoveConnection(
ViewManagerInitServiceImpl* connection) {
Connections::iterator it =
std::find(connections_.begin(), connections_.end(), connection);
DCHECK(it != connections_.end());
connections_.erase(it);
// This object is owned by an object that outlives the current thread's
// message loop, so we need to destroy the RootNodeManager earlier, as it may
// attempt to post tasks during its destruction.
if (connections_.empty())
root_node_manager_.reset();
}
void ViewManagerInitServiceContext::ConfigureIncomingConnection(
ApplicationConnection* connection) {
if (!root_node_manager_.get()) {
root_node_manager_.reset(new RootNodeManager(
connection,
this,
base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted,
base::Unretained(this))));
}
}
void ViewManagerInitServiceContext::OnNativeViewportDeleted() {
for (Connections::const_iterator it = connections_.begin();
it != connections_.end(); ++it) {
(*it)->OnNativeViewportDeleted();
}
}
void ViewManagerInitServiceContext::OnRootViewManagerWindowTreeHostCreated() {
DCHECK(!is_tree_host_ready_);
is_tree_host_ready_ = true;
for (Connections::const_iterator it = connections_.begin();
it != connections_.end(); ++it) {
(*it)->OnRootViewManagerWindowTreeHostCreated();
}
}
} // namespace service
} // namespace view_manager
} // namespace mojo
// 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 MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_
#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_
#include <set>
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/services/view_manager/root_view_manager_delegate.h"
#include "mojo/services/view_manager/view_manager_export.h"
namespace mojo {
namespace view_manager {
namespace service {
class RootNodeManager;
class ViewManagerInitServiceImpl;
// State shared between all ViewManagerInitService impls.
class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceContext
: public RootViewManagerDelegate {
public:
ViewManagerInitServiceContext();
virtual ~ViewManagerInitServiceContext();
void AddConnection(ViewManagerInitServiceImpl* connection);
void RemoveConnection(ViewManagerInitServiceImpl* connection);
void ConfigureIncomingConnection(ApplicationConnection* connection);
RootNodeManager* root_node_manager() { return root_node_manager_.get(); }
bool is_tree_host_ready() const { return is_tree_host_ready_; }
private:
typedef std::vector<ViewManagerInitServiceImpl*> Connections;
// RootViewManagerDelegate overrides:
virtual void OnRootViewManagerWindowTreeHostCreated() OVERRIDE;
void OnNativeViewportDeleted();
scoped_ptr<RootNodeManager> root_node_manager_;
Connections connections_;
bool is_tree_host_ready_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerInitServiceContext);
};
} // namespace service
} // namespace view_manager
} // namespace mojo
#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_
......@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
#include "mojo/services/view_manager/ids.h"
#include "mojo/services/view_manager/view_manager_init_service_context.h"
#include "mojo/services/view_manager/view_manager_service_impl.h"
namespace mojo {
......@@ -19,25 +20,34 @@ ViewManagerInitServiceImpl::ConnectParams::ConnectParams() {}
ViewManagerInitServiceImpl::ConnectParams::~ConnectParams() {}
ViewManagerInitServiceImpl::ViewManagerInitServiceImpl(
ApplicationConnection* connection)
: root_node_manager_(
connection,
this,
base::Bind(&ViewManagerInitServiceImpl::OnNativeViewportDeleted,
base::Unretained(this))),
is_tree_host_ready_(false) {
ApplicationConnection* connection,
ViewManagerInitServiceContext* context)
: context_(context) {
context_->AddConnection(this);
}
ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() {
context_->RemoveConnection(this);
}
void ViewManagerInitServiceImpl::OnNativeViewportDeleted() {
// TODO(beng): Should not have to rely on implementation detail of
// InterfaceImpl to close the connection. Instead should simply
// be able to delete this object.
internal_state()->router()->CloseMessagePipe();
}
void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() {
MaybeEmbed();
}
void ViewManagerInitServiceImpl::MaybeEmbed() {
if (!is_tree_host_ready_)
if (!context_->is_tree_host_ready())
return;
ScopedVector<ConnectParams>::const_iterator it = connect_params_.begin();
for (; it != connect_params_.end(); ++it) {
root_node_manager_.EmbedRoot((*it)->url);
context_->root_node_manager()->EmbedRoot((*it)->url);
(*it)->callback.Run(true);
}
connect_params_.clear();
......@@ -53,19 +63,6 @@ void ViewManagerInitServiceImpl::Embed(
MaybeEmbed();
}
void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() {
DCHECK(!is_tree_host_ready_);
is_tree_host_ready_ = true;
MaybeEmbed();
}
void ViewManagerInitServiceImpl::OnNativeViewportDeleted() {
// TODO(beng): Should not have to rely on implementation detail of
// InterfaceImpl to close the connection. Instead should simply
// be able to delete this object.
internal_state()->router()->CloseMessagePipe();
}
} // namespace service
} // namespace view_manager
} // namespace mojo
......@@ -12,7 +12,6 @@
#include "base/memory/scoped_vector.h"
#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
#include "mojo/services/view_manager/root_node_manager.h"
#include "mojo/services/view_manager/root_view_manager_delegate.h"
#include "mojo/services/view_manager/view_manager_export.h"
namespace mojo {
......@@ -23,6 +22,8 @@ class ServiceProvider;
namespace view_manager {
namespace service {
class ViewManagerInitServiceContext;
#if defined(OS_WIN)
// Equivalent of NON_EXPORTED_BASE which does not work with the template snafu
// below.
......@@ -33,12 +34,16 @@ namespace service {
// Used to create the initial ViewManagerClient. Doesn't initiate the Connect()
// until the WindowTreeHost has been created.
class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceImpl
: public InterfaceImpl<ViewManagerInitService>,
public RootViewManagerDelegate {
: public InterfaceImpl<ViewManagerInitService> {
public:
explicit ViewManagerInitServiceImpl(ApplicationConnection* connection);
ViewManagerInitServiceImpl(ApplicationConnection* connection,
ViewManagerInitServiceContext* context);
virtual ~ViewManagerInitServiceImpl();
void OnNativeViewportDeleted();
void OnRootViewManagerWindowTreeHostCreated();
private:
struct ConnectParams {
ConnectParams();
......@@ -54,15 +59,10 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceImpl
virtual void Embed(const String& url,
const Callback<void(bool)>& callback) OVERRIDE;
// RootViewManagerDelegate overrides:
virtual void OnRootViewManagerWindowTreeHostCreated() OVERRIDE;
void OnNativeViewportDeleted();
ViewManagerInitServiceContext* context_;
ServiceProvider* service_provider_;
RootNodeManager root_node_manager_;
// Stores information about inbound calls to Embed() pending execution on
// the window tree host being ready to use.
ScopedVector<ConnectParams> connect_params_;
......
// 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 "mojo/public/cpp/application/application_delegate.h"
#include "mojo/services/window_manager/window_manager_app.h"
// ApplicationDelegate implementation file for WindowManager users (e.g.
// core window manager tests) that do not want to provide their own
// ApplicationDelegate::Create().
namespace mojo {
// static
ApplicationDelegate* ApplicationDelegate::Create() {
return new WindowManagerApp(NULL);
}
} // namespace mojo
......@@ -70,12 +70,14 @@ class WMFocusRules : public wm::FocusRules {
////////////////////////////////////////////////////////////////////////////////
// WindowManagerApp, public:
WindowManagerApp::WindowManagerApp()
WindowManagerApp::WindowManagerApp(view_manager::ViewManagerDelegate* delegate)
: InterfaceFactoryWithContext(this),
wrapped_delegate_(delegate),
view_manager_(NULL),
view_manager_client_factory_(this),
root_(NULL) {
}
WindowManagerApp::~WindowManagerApp() {
// TODO(beng): Figure out if this should be done in
// OnViewManagerDisconnected().
......@@ -169,7 +171,7 @@ void WindowManagerApp::OnRootAdded(view_manager::ViewManager* view_manager,
focus_client_->AddObserver(this);
activation_client_->AddObserver(this);
// TODO(beng): Create the universe.
wrapped_delegate_->OnRootAdded(view_manager, root);
for (Connections::const_iterator it = connections_.begin();
it != connections_.end(); ++it) {
......@@ -180,6 +182,7 @@ void WindowManagerApp::OnRootAdded(view_manager::ViewManager* view_manager,
void WindowManagerApp::OnViewManagerDisconnected(
view_manager::ViewManager* view_manager) {
DCHECK_EQ(view_manager_, view_manager);
wrapped_delegate_->OnViewManagerDisconnected(view_manager);
root_->RemoveObserver(this);
root_ = NULL;
view_manager_ = NULL;
......@@ -274,12 +277,4 @@ void WindowManagerApp::UnregisterSubtree(view_manager::Id id) {
UnregisterSubtree((*child)->id());
}
////////////////////////////////////////////////////////////////////////////////
// ApplicationDelegate, public:
// static
ApplicationDelegate* ApplicationDelegate::Create() {
return new WindowManagerApp;
}
} // namespace mojo
......@@ -48,7 +48,7 @@ class WindowManagerApp
public InterfaceFactoryWithContext<WindowManagerServiceImpl,
WindowManagerApp> {
public:
WindowManagerApp();
explicit WindowManagerApp(view_manager::ViewManagerDelegate* delegate);
virtual ~WindowManagerApp();
void AddConnection(WindowManagerServiceImpl* connection);
......@@ -62,15 +62,15 @@ class WindowManagerApp
bool IsReady() const;
private:
typedef std::set<WindowManagerServiceImpl*> Connections;
typedef std::map<view_manager::Id, aura::Window*> NodeIdToWindowMap;
// Overridden from ApplicationDelegate:
virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE;
virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
MOJO_OVERRIDE;
private:
typedef std::set<WindowManagerServiceImpl*> Connections;
typedef std::map<view_manager::Id, aura::Window*> NodeIdToWindowMap;
// Overridden from view_manager::ViewManagerDelegate:
virtual void OnRootAdded(view_manager::ViewManager* view_manager,
view_manager::Node* root) MOJO_OVERRIDE;
......@@ -103,6 +103,8 @@ class WindowManagerApp
// and removes from the registry.
void UnregisterSubtree(view_manager::Id id);
view_manager::ViewManagerDelegate* wrapped_delegate_;
view_manager::ViewManager* view_manager_;
view_manager::ViewManagerClientFactory view_manager_client_factory_;
view_manager::Node* root_;
......
......@@ -37,7 +37,8 @@ void ViewManagerLoader::OnServiceError(ServiceManager* manager,
}
bool ViewManagerLoader::ConfigureIncomingConnection(
ApplicationConnection* connection) {
ApplicationConnection* connection) {
context_.ConfigureIncomingConnection(connection);
connection->AddService(this);
return true;
}
......@@ -45,7 +46,8 @@ bool ViewManagerLoader::ConfigureIncomingConnection(
void ViewManagerLoader::Create(
ApplicationConnection* connection,
InterfaceRequest<ViewManagerInitService> request) {
BindToRequest(new ViewManagerInitServiceImpl(connection), &request);
BindToRequest(new ViewManagerInitServiceImpl(connection, &context_),
&request);
}
} // namespace shell
......
......@@ -11,6 +11,7 @@
#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/service_manager/service_loader.h"
#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
#include "mojo/services/view_manager/view_manager_init_service_context.h"
namespace mojo {
......@@ -46,6 +47,7 @@ class ViewManagerLoader
InterfaceRequest<view_manager::ViewManagerInitService> request) OVERRIDE;
ScopedVector<Application> apps_;
view_manager::service::ViewManagerInitServiceContext context_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerLoader);
};
......
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