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/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "mojo/public/cpp/application/application.h" |
9 #include "mojo/public/cpp/environment/environment.h" | 10 #include "mojo/public/cpp/environment/environment.h" |
10 #include "mojo/public/cpp/shell/application.h" | |
11 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
12 #include "mojo/public/cpp/system/macros.h" | 12 #include "mojo/public/cpp/system/macros.h" |
13 #include "mojo/public/cpp/utility/run_loop.h" | 13 #include "mojo/public/cpp/utility/run_loop.h" |
14 #include "mojo/services/public/cpp/view_manager/view.h" | 14 #include "mojo/services/public/cpp/view_manager/view.h" |
15 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
16 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" | 16 #include "mojo/services/public/cpp/view_manager/view_tree_node.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
18 | 18 |
19 #if defined(WIN32) | 19 #if defined(WIN32) |
20 #if !defined(CDECL) | 20 #if !defined(CDECL) |
21 #define CDECL __cdecl | 21 #define CDECL __cdecl |
22 #endif | 22 #endif |
23 #define SAMPLE_APP_EXPORT __declspec(dllexport) | 23 #define SAMPLE_APP_EXPORT __declspec(dllexport) |
24 #else | 24 #else |
25 #define CDECL | 25 #define CDECL |
26 #define SAMPLE_APP_EXPORT __attribute__((visibility("default"))) | 26 #define SAMPLE_APP_EXPORT __attribute__((visibility("default"))) |
27 #endif | 27 #endif |
28 | 28 |
29 namespace mojo { | 29 namespace mojo { |
30 namespace examples { | 30 namespace examples { |
31 | 31 |
32 class SampleApp : public Application { | 32 class SampleApp : public Application { |
33 public: | 33 public: |
34 explicit SampleApp(MojoHandle shell_handle) | 34 explicit SampleApp(MojoHandle service_provider_handle) |
35 : Application(shell_handle) { | 35 : Application(service_provider_handle) { |
36 view_manager_.reset(new view_manager::ViewManager(shell())); | 36 view_manager_.reset(new view_manager::ViewManager(service_provider())); |
37 view_manager_->Init(); | 37 view_manager_->Init(); |
38 view_manager::ViewTreeNode* node1 = | 38 view_manager::ViewTreeNode* node1 = |
39 view_manager::ViewTreeNode::Create(view_manager_.get()); | 39 view_manager::ViewTreeNode::Create(view_manager_.get()); |
40 view_manager::ViewTreeNode* node11 = | 40 view_manager::ViewTreeNode* node11 = |
41 view_manager::ViewTreeNode::Create(view_manager_.get()); | 41 view_manager::ViewTreeNode::Create(view_manager_.get()); |
42 node11->SetBounds(gfx::Rect(800, 600)); | 42 node11->SetBounds(gfx::Rect(800, 600)); |
43 | 43 |
44 view_manager::View* view11 = | 44 view_manager::View* view11 = |
45 view_manager::View::Create(view_manager_.get()); | 45 view_manager::View::Create(view_manager_.get()); |
46 node11->SetActiveView(view11); | 46 node11->SetActiveView(view11); |
(...skipping 13 matching lines...) Expand all Loading... |
60 // SampleApp creates a ViewManager and a trivial node hierarchy. | 60 // SampleApp creates a ViewManager and a trivial node hierarchy. |
61 scoped_ptr<view_manager::ViewManager> view_manager_; | 61 scoped_ptr<view_manager::ViewManager> view_manager_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(SampleApp); | 63 DISALLOW_COPY_AND_ASSIGN(SampleApp); |
64 }; | 64 }; |
65 | 65 |
66 } // namespace examples | 66 } // namespace examples |
67 } // namespace mojo | 67 } // namespace mojo |
68 | 68 |
69 extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( | 69 extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( |
70 MojoHandle shell_handle) { | 70 MojoHandle service_provider_handle) { |
71 base::MessageLoop loop; | 71 base::MessageLoop loop; |
72 | 72 |
73 mojo::examples::SampleApp app(shell_handle); | 73 mojo::examples::SampleApp app(service_provider_handle); |
74 loop.Run(); | 74 loop.Run(); |
75 return MOJO_RESULT_OK; | 75 return MOJO_RESULT_OK; |
76 } | 76 } |
OLD | NEW |