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/basictypes.h" | |
6 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "mojo/application/application_runner_chromium.h" | 9 #include "mojo/application/application_runner_chromium.h" |
10 #include "mojo/examples/window_manager/window_manager.mojom.h" | 10 #include "mojo/examples/window_manager/window_manager.mojom.h" |
11 #include "mojo/public/c/system/main.h" | 11 #include "mojo/public/c/system/main.h" |
12 #include "mojo/public/cpp/application/application_connection.h" | 12 #include "mojo/public/cpp/application/application_connection.h" |
13 #include "mojo/public/cpp/application/application_delegate.h" | 13 #include "mojo/public/cpp/application/application_delegate.h" |
14 #include "mojo/public/cpp/application/application_impl.h" | 14 #include "mojo/public/cpp/application/application_impl.h" |
15 #include "mojo/public/cpp/application/interface_factory_impl.h" | 15 #include "mojo/public/cpp/application/interface_factory_impl.h" |
16 #include "mojo/services/public/cpp/view_manager/view.h" | 16 #include "mojo/services/public/cpp/view_manager/view.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 ApplicationConnection* connection) override { | 52 ApplicationConnection* connection) override { |
53 connection->ConnectToService(&window_manager_); | 53 connection->ConnectToService(&window_manager_); |
54 connection->AddService(view_manager_client_factory_.get()); | 54 connection->AddService(view_manager_client_factory_.get()); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 // Overridden from ViewManagerDelegate: | 58 // Overridden from ViewManagerDelegate: |
59 virtual void OnEmbed(ViewManager* view_manager, | 59 virtual void OnEmbed(ViewManager* view_manager, |
60 View* root, | 60 View* root, |
61 ServiceProviderImpl* exported_services, | 61 ServiceProviderImpl* exported_services, |
62 scoped_ptr<ServiceProvider> imported_services) OVERRIDE { | 62 scoped_ptr<ServiceProvider> imported_services) override { |
63 root->AddObserver(this); | 63 root->AddObserver(this); |
64 root->SetColor(SK_ColorCYAN); | 64 root->SetColor(SK_ColorCYAN); |
65 | 65 |
66 nested_ = View::Create(view_manager); | 66 nested_ = View::Create(view_manager); |
67 root->AddChild(nested_); | 67 root->AddChild(nested_); |
68 nested_->SetBounds(gfx::Rect(20, 20, 50, 50)); | 68 nested_->SetBounds(gfx::Rect(20, 20, 50, 50)); |
69 nested_->Embed(kEmbeddedAppURL); | 69 nested_->Embed(kEmbeddedAppURL); |
70 } | 70 } |
71 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE { | 71 virtual void OnViewManagerDisconnected(ViewManager* view_manager) override { |
72 base::MessageLoop::current()->Quit(); | 72 base::MessageLoop::current()->Quit(); |
73 } | 73 } |
74 | 74 |
75 // Overridden from ViewObserver: | 75 // Overridden from ViewObserver: |
76 virtual void OnViewDestroyed(View* view) OVERRIDE { | 76 virtual void OnViewDestroyed(View* view) override { |
77 // TODO(beng): reap views & child Views. | 77 // TODO(beng): reap views & child Views. |
78 nested_ = NULL; | 78 nested_ = NULL; |
79 } | 79 } |
80 virtual void OnViewInputEvent(View* view, const EventPtr& event) OVERRIDE { | 80 virtual void OnViewInputEvent(View* view, const EventPtr& event) override { |
81 if (event->action == EVENT_TYPE_MOUSE_RELEASED) | 81 if (event->action == EVENT_TYPE_MOUSE_RELEASED) |
82 window_manager_->CloseWindow(view->id()); | 82 window_manager_->CloseWindow(view->id()); |
83 } | 83 } |
84 | 84 |
85 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; | 85 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
86 | 86 |
87 View* nested_; | 87 View* nested_; |
88 IWindowManagerPtr window_manager_; | 88 IWindowManagerPtr window_manager_; |
89 | 89 |
90 DISALLOW_COPY_AND_ASSIGN(NestingApp); | 90 DISALLOW_COPY_AND_ASSIGN(NestingApp); |
91 }; | 91 }; |
92 | 92 |
93 } // namespace examples | 93 } // namespace examples |
94 } // namespace mojo | 94 } // namespace mojo |
95 | 95 |
96 MojoResult MojoMain(MojoHandle shell_handle) { | 96 MojoResult MojoMain(MojoHandle shell_handle) { |
97 mojo::ApplicationRunnerChromium runner(new mojo::examples::NestingApp); | 97 mojo::ApplicationRunnerChromium runner(new mojo::examples::NestingApp); |
98 return runner.Run(shell_handle); | 98 return runner.Run(shell_handle); |
99 } | 99 } |
OLD | NEW |