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 #ifndef SERVICES_KIOSK_WM_KIOSK_WM_H_
6 #define SERVICES_KIOSK_WM_KIOSK_WM_H_
8 #include "base/memory/weak_ptr.h"
9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h"
11 #include "mojo/public/cpp/application/connect.h"
12 #include "mojo/public/cpp/application/service_provider_impl.h"
13 #include "mojo/services/kiosk_wm/navigator_host_impl.h"
14 #include "mojo/services/window_manager/window_manager_app.h"
15 #include "mojo/services/window_manager/window_manager_delegate.h"
16 #include "third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom.h"
17 #include "third_party/mojo_services/src/navigation/public/interfaces/navigation.mojom.h"
18 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager.h"
19 #include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.h"
20 #include "third_party/mojo_services/src/view_manager/public/cpp/view_observer.h"
21 #include "ui/base/accelerators/accelerator.h"
25 class MergedServiceProvider
;
27 class KioskWM
: public mojo::ApplicationDelegate
,
28 public mojo::ViewManagerDelegate
,
29 public mojo::ViewObserver
,
30 public window_manager::WindowManagerDelegate
,
31 public mojo::InterfaceFactory
<mojo::NavigatorHost
>,
32 public ui::AcceleratorTarget
{
37 base::WeakPtr
<KioskWM
> GetWeakPtr();
39 void ReplaceContentWithURL(const mojo::String
& url
);
42 // Overridden from mojo::ApplicationDelegate:
43 void Initialize(mojo::ApplicationImpl
* app
) override
;
44 bool ConfigureIncomingConnection(
45 mojo::ApplicationConnection
* connection
) override
;
46 bool ConfigureOutgoingConnection(
47 mojo::ApplicationConnection
* connection
) override
;
49 // Overridden from mojo::ViewManagerDelegate:
50 void OnEmbed(mojo::View
* root
,
51 mojo::InterfaceRequest
<mojo::ServiceProvider
> services
,
52 mojo::ServiceProviderPtr exposed_services
) override
;
53 void OnViewManagerDisconnected(mojo::ViewManager
* view_manager
) override
;
55 // Overriden from mojo::ViewObserver:
56 void OnViewDestroyed(mojo::View
* view
) override
;
57 void OnViewBoundsChanged(mojo::View
* view
,
58 const mojo::Rect
& old_bounds
,
59 const mojo::Rect
& new_bounds
) override
;
61 // Overridden from WindowManagerDelegate:
62 void Embed(const mojo::String
& url
,
63 mojo::InterfaceRequest
<mojo::ServiceProvider
> services
,
64 mojo::ServiceProviderPtr exposed_services
) override
;
66 // Overridden from mojo::InterfaceFactory<mojo::NavigatorHost>:
67 void Create(mojo::ApplicationConnection
* connection
,
68 mojo::InterfaceRequest
<mojo::NavigatorHost
> request
) override
;
70 // Overriden from ui::AcceleratorTarget:
71 bool AcceleratorPressed(const ui::Accelerator
& accelerator
) override
;
72 bool CanHandleAccelerators() const override
;
74 scoped_ptr
<window_manager::WindowManagerApp
> window_manager_app_
;
76 // Only support being embedded once, so both application-level
77 // and embedding-level state are shared on the same object.
80 std::string default_url_
;
81 std::string pending_url_
;
83 mojo::ServiceProviderImpl exposed_services_impl_
;
84 scoped_ptr
<MergedServiceProvider
> merged_service_provider_
;
86 NavigatorHostImpl navigator_host_
;
88 base::WeakPtrFactory
<KioskWM
> weak_factory_
;
90 DISALLOW_COPY_AND_ASSIGN(KioskWM
);
93 } // namespace kiosk_wm
95 #endif // SERVICES_KIOSK_WM_KIOSK_WM_H_