OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_ptr.h" | |
5 #include "mojo/public/cpp/application/application_delegate.h" | 6 #include "mojo/public/cpp/application/application_delegate.h" |
7 #include "mojo/public/cpp/application/service_provider_impl.h" | |
8 #include "mojo/services/public/cpp/view_manager/view_manager.h" | |
9 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | |
10 #include "mojo/services/public/cpp/view_manager/window_manager_delegate.h" | |
6 #include "mojo/services/window_manager/window_manager_app.h" | 11 #include "mojo/services/window_manager/window_manager_app.h" |
7 | 12 |
8 // ApplicationDelegate implementation file for WindowManager users (e.g. | 13 // ApplicationDelegate implementation file for WindowManager users (e.g. |
9 // core window manager tests) that do not want to provide their own | 14 // core window manager tests) that do not want to provide their own |
10 // ApplicationDelegate::Create(). | 15 // ApplicationDelegate::Create(). |
11 | 16 |
12 namespace mojo { | 17 namespace mojo { |
13 | 18 |
19 class DefaultWindowManager : public ApplicationDelegate, | |
20 public ViewManagerDelegate, | |
21 public WindowManagerDelegate { | |
22 public: | |
23 DefaultWindowManager() | |
24 : window_manager_app_(new WindowManagerApp(this)), | |
25 view_manager_(NULL) {} | |
sky
2014/08/13 14:41:53
root_(NULL) too.
| |
26 virtual ~DefaultWindowManager() {} | |
27 | |
28 private: | |
29 // Overridden from ApplicationDelegate: | |
30 virtual void Initialize(ApplicationImpl* impl) MOJO_OVERRIDE { | |
31 window_manager_app_->Initialize(impl); | |
32 } | |
33 virtual bool ConfigureIncomingConnection( | |
34 ApplicationConnection* connection) MOJO_OVERRIDE { | |
35 window_manager_app_->ConfigureIncomingConnection(connection); | |
36 return true; | |
37 } | |
38 | |
39 // Overridden from ViewManagerDelegate: | |
40 virtual void OnEmbed( | |
41 ViewManager* view_manager, | |
42 View* root, | |
43 ServiceProviderImpl* exported_services, | |
44 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE { | |
45 view_manager_ = view_manager; | |
46 root_ = root; | |
47 view_manager_->SetWindowManagerDelegate(this); | |
48 } | |
49 virtual void OnViewManagerDisconnected( | |
50 ViewManager* view_manager) MOJO_OVERRIDE {} | |
51 | |
52 // Overridden from WindowManagerDelegate: | |
53 virtual void Embed( | |
54 const String& url, | |
55 InterfaceRequest<ServiceProvider> service_provider) MOJO_OVERRIDE { | |
56 View* view = View::Create(view_manager_); | |
57 root_->AddChild(view); | |
58 view->Embed(url, scoped_ptr<mojo::ServiceProviderImpl>( | |
59 new mojo::ServiceProviderImpl).Pass()); | |
60 } | |
61 virtual void DispatchEvent(View* target, EventPtr event) MOJO_OVERRIDE {} | |
62 | |
63 scoped_ptr<WindowManagerApp> window_manager_app_; | |
64 | |
65 ViewManager* view_manager_; | |
66 View* root_; | |
67 | |
68 MOJO_DISALLOW_COPY_AND_ASSIGN(DefaultWindowManager); | |
69 }; | |
70 | |
14 // static | 71 // static |
15 ApplicationDelegate* ApplicationDelegate::Create() { | 72 ApplicationDelegate* ApplicationDelegate::Create() { |
16 return new WindowManagerApp(NULL); | 73 return new DefaultWindowManager; |
17 } | 74 } |
18 | 75 |
19 } // namespace mojo | 76 } // namespace mojo |
OLD | NEW |