Move PseudoTCP and channel auth out of LibjingleTransportFactory.
[chromium-blink-merge.git] / mojo / services / window_manager / main.cc
blob514fc973b9467ae38b192b25f1eca854e2141397
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 "base/memory/scoped_ptr.h"
6 #include "mojo/public/c/system/main.h"
7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_runner_chromium.h"
9 #include "mojo/public/cpp/application/service_provider_impl.h"
10 #include "mojo/services/public/cpp/view_manager/view_manager.h"
11 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
12 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h"
13 #include "mojo/services/window_manager/window_manager_app.h"
15 // ApplicationDelegate implementation file for WindowManager users (e.g.
16 // core window manager tests) that do not want to provide their own
17 // ApplicationDelegate::Create().
19 namespace mojo {
21 class DefaultWindowManager : public ApplicationDelegate,
22 public ViewManagerDelegate,
23 public WindowManagerDelegate {
24 public:
25 DefaultWindowManager()
26 : window_manager_app_(new WindowManagerApp(this, this)),
27 view_manager_(NULL),
28 root_(NULL) {}
29 virtual ~DefaultWindowManager() {}
31 private:
32 // Overridden from ApplicationDelegate:
33 virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE {
34 window_manager_app_->Initialize(impl);
36 virtual bool ConfigureIncomingConnection(
37 ApplicationConnection* connection) MOJO_OVERRIDE {
38 window_manager_app_->ConfigureIncomingConnection(connection);
39 return true;
42 // Overridden from ViewManagerDelegate:
43 virtual void OnEmbed(
44 ViewManager* view_manager,
45 View* root,
46 ServiceProviderImpl* exported_services,
47 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE {
48 view_manager_ = view_manager;
49 root_ = root;
50 view_manager_->SetWindowManagerDelegate(this);
52 virtual void OnViewManagerDisconnected(
53 ViewManager* view_manager) MOJO_OVERRIDE {}
55 // Overridden from WindowManagerDelegate:
56 virtual void Embed(
57 const String& url,
58 InterfaceRequest<ServiceProvider> service_provider) MOJO_OVERRIDE {
59 View* view = View::Create(view_manager_);
60 root_->AddChild(view);
61 view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>(
62 new mojo::ServiceProviderImpl).Pass());
64 virtual void DispatchEvent(EventPtr event) MOJO_OVERRIDE {}
66 scoped_ptr<WindowManagerApp> window_manager_app_;
68 ViewManager* view_manager_;
69 View* root_;
71 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager);
74 } // namespace mojo
76 MojoResult MojoMain(MojoHandle shell_handle) {
77 mojo::ApplicationRunnerChromium runner(new mojo::DefaultWindowManager);
78 return runner.Run(shell_handle);