Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: mojo/examples/wm_flow/app/app.cc

Issue 460863002: Rename Node to View in the View Manager mojom & client lib. Service TBD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "mojo/examples/wm_flow/app/embedder.mojom.h" 6 #include "mojo/examples/wm_flow/app/embedder.mojom.h"
7 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h" 7 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
11 #include "mojo/public/cpp/application/connect.h" 11 #include "mojo/public/cpp/application/connect.h"
12 #include "mojo/public/cpp/application/interface_factory_impl.h" 12 #include "mojo/public/cpp/application/interface_factory_impl.h"
13 #include "mojo/public/cpp/application/service_provider_impl.h" 13 #include "mojo/public/cpp/application/service_provider_impl.h"
14 #include "mojo/public/interfaces/application/service_provider.mojom.h" 14 #include "mojo/public/interfaces/application/service_provider.mojom.h"
15 #include "mojo/services/public/cpp/view_manager/node.h" 15 #include "mojo/services/public/cpp/view_manager/view.h"
16 #include "mojo/services/public/cpp/view_manager/view_manager.h" 16 #include "mojo/services/public/cpp/view_manager/view_manager.h"
17 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" 17 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
18 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" 18 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
19 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 19 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
20 20
21 namespace examples { 21 namespace examples {
22 namespace { 22 namespace {
23 void ConnectCallback(bool success) {} 23 void ConnectCallback(bool success) {}
24 24
25 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW }; 25 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW };
(...skipping 10 matching lines...) Expand all
36 } 36 }
37 37
38 DISALLOW_COPY_AND_ASSIGN(EmbedderImpl); 38 DISALLOW_COPY_AND_ASSIGN(EmbedderImpl);
39 }; 39 };
40 40
41 } // namespace 41 } // namespace
42 42
43 // This app starts its life via Connect() rather than by being embed, so it does 43 // This app starts its life via Connect() rather than by being embed, so it does
44 // not start with a connection to the ViewManager service. It has to obtain a 44 // not start with a connection to the ViewManager service. It has to obtain a
45 // connection by connecting to the ViewManagerInit service and asking to be 45 // connection by connecting to the ViewManagerInit service and asking to be
46 // embed without a node context. 46 // embed without a view context.
47 class WMFlowApp : public mojo::ApplicationDelegate, 47 class WMFlowApp : public mojo::ApplicationDelegate,
48 public mojo::ViewManagerDelegate { 48 public mojo::ViewManagerDelegate {
49 public: 49 public:
50 WMFlowApp() 50 WMFlowApp()
51 : embed_count_(0), 51 : embed_count_(0),
52 view_manager_client_factory_(this) {} 52 view_manager_client_factory_(this) {}
53 virtual ~WMFlowApp() {} 53 virtual ~WMFlowApp() {}
54 54
55 private: 55 private:
56 // Overridden from Application: 56 // Overridden from Application:
57 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { 57 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
58 mojo::ServiceProviderPtr sp; 58 mojo::ServiceProviderPtr sp;
59 app->ConnectToService("mojo:mojo_view_manager", &init_svc_); 59 app->ConnectToService("mojo:mojo_view_manager", &init_svc_);
60 init_svc_->Embed("mojo:mojo_wm_flow_app", sp.Pass(), 60 init_svc_->Embed("mojo:mojo_wm_flow_app", sp.Pass(),
61 base::Bind(&ConnectCallback)); 61 base::Bind(&ConnectCallback));
62 } 62 }
63 virtual bool ConfigureIncomingConnection( 63 virtual bool ConfigureIncomingConnection(
64 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 64 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
65 connection->AddService(&view_manager_client_factory_); 65 connection->AddService(&view_manager_client_factory_);
66 return true; 66 return true;
67 } 67 }
68 68
69 void OnConnect(bool success) {} 69 void OnConnect(bool success) {}
70 70
71 // Overridden from mojo::ViewManagerDelegate: 71 // Overridden from mojo::ViewManagerDelegate:
72 virtual void OnEmbed( 72 virtual void OnEmbed(
73 mojo::ViewManager* view_manager, 73 mojo::ViewManager* view_manager,
74 mojo::Node* root, 74 mojo::View* root,
75 mojo::ServiceProviderImpl* exported_services, 75 mojo::ServiceProviderImpl* exported_services,
76 scoped_ptr<mojo::ServiceProvider> imported_services) MOJO_OVERRIDE { 76 scoped_ptr<mojo::ServiceProvider> imported_services) MOJO_OVERRIDE {
77 root->SetColor(kColors[embed_count_++ % arraysize(kColors)]); 77 root->SetColor(kColors[embed_count_++ % arraysize(kColors)]);
78 78
79 mojo::Node* embed = mojo::Node::Create(view_manager); 79 mojo::View* embed = mojo::View::Create(view_manager);
80 root->AddChild(embed); 80 root->AddChild(embed);
81 gfx::Rect bounds = root->bounds(); 81 gfx::Rect bounds = root->bounds();
82 bounds.Inset(25, 25); 82 bounds.Inset(25, 25);
83 embed->SetBounds(bounds); 83 embed->SetBounds(bounds);
84 84
85 scoped_ptr<mojo::ServiceProviderImpl> registry( 85 scoped_ptr<mojo::ServiceProviderImpl> registry(
86 new mojo::ServiceProviderImpl); 86 new mojo::ServiceProviderImpl);
87 // Expose some services to the embeddee... 87 // Expose some services to the embeddee...
88 registry->AddService(&embedder_factory_); 88 registry->AddService(&embedder_factory_);
89 scoped_ptr<mojo::ServiceProvider> imported = 89 scoped_ptr<mojo::ServiceProvider> imported =
(...skipping 21 matching lines...) Expand all
111 } // namespace examples 111 } // namespace examples
112 112
113 namespace mojo { 113 namespace mojo {
114 114
115 // static 115 // static
116 ApplicationDelegate* ApplicationDelegate::Create() { 116 ApplicationDelegate* ApplicationDelegate::Create() {
117 return new examples::WMFlowApp; 117 return new examples::WMFlowApp;
118 } 118 }
119 119
120 } // namespace 120 } // namespace
OLDNEW
« no previous file with comments | « mojo/examples/window_manager/window_manager.cc ('k') | mojo/examples/wm_flow/embedded/embedded.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698