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

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

Issue 418983002: Nukes view_manager namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolve merge Created 6 years, 5 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
« no previous file with comments | « mojo/examples/window_manager/window_manager.cc ('k') | mojo/examples/wm_flow/init/init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/public/cpp/application/application_connection.h" 6 #include "mojo/public/cpp/application/application_connection.h"
7 #include "mojo/public/cpp/application/application_delegate.h" 7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_impl.h" 8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/services/public/cpp/view_manager/node.h" 9 #include "mojo/services/public/cpp/view_manager/node.h"
10 #include "mojo/services/public/cpp/view_manager/view.h" 10 #include "mojo/services/public/cpp/view_manager/view.h"
11 #include "mojo/services/public/cpp/view_manager/view_manager.h" 11 #include "mojo/services/public/cpp/view_manager/view_manager.h"
12 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" 12 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
13 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" 13 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
14 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" 14 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
15 15
16 namespace examples { 16 namespace examples {
17 namespace { 17 namespace {
18 void ConnectCallback(bool success) {} 18 void ConnectCallback(bool success) {}
19 19
20 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW }; 20 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW };
21 21
22 } // namespace 22 } // namespace
23 23
24 // This app starts its life via Connect() rather than by being embed, so it does 24 // This app starts its life via Connect() rather than by being embed, so it does
25 // not start with a connection to the ViewManager service. It has to obtain a 25 // not start with a connection to the ViewManager service. It has to obtain a
26 // connection by connecting to the ViewManagerInit service and asking to be 26 // connection by connecting to the ViewManagerInit service and asking to be
27 // embed without a node context. 27 // embed without a node context.
28 class WMFlowApp : public mojo::ApplicationDelegate, 28 class WMFlowApp : public mojo::ApplicationDelegate,
29 public mojo::view_manager::ViewManagerDelegate { 29 public mojo::ViewManagerDelegate {
30 public: 30 public:
31 WMFlowApp() : embed_count_(0), view_manager_client_factory_(this) {} 31 WMFlowApp() : embed_count_(0), view_manager_client_factory_(this) {}
32 virtual ~WMFlowApp() {} 32 virtual ~WMFlowApp() {}
33 33
34 private: 34 private:
35 // Overridden from Application: 35 // Overridden from Application:
36 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { 36 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
37 mojo::view_manager::ViewManagerInitServicePtr init_svc; 37 mojo::ViewManagerInitServicePtr init_svc;
38 app->ConnectToService("mojo:mojo_view_manager", &init_svc); 38 app->ConnectToService("mojo:mojo_view_manager", &init_svc);
39 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback)); 39 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
40 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback)); 40 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
41 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback)); 41 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
42 } 42 }
43 virtual bool ConfigureIncomingConnection( 43 virtual bool ConfigureIncomingConnection(
44 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 44 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
45 connection->AddService(&view_manager_client_factory_); 45 connection->AddService(&view_manager_client_factory_);
46 return true; 46 return true;
47 } 47 }
48 48
49 void OnConnect(bool success) {} 49 void OnConnect(bool success) {}
50 50
51 // Overridden from mojo::view_manager::ViewManagerDelegate: 51 // Overridden from mojo::ViewManagerDelegate:
52 virtual void OnRootAdded(mojo::view_manager::ViewManager* view_manager, 52 virtual void OnRootAdded(mojo::ViewManager* view_manager,
53 mojo::view_manager::Node* root) MOJO_OVERRIDE { 53 mojo::Node* root) MOJO_OVERRIDE {
54 mojo::view_manager::View* view = 54 mojo::View* view =
55 mojo::view_manager::View::Create(view_manager); 55 mojo::View::Create(view_manager);
56 root->SetActiveView(view); 56 root->SetActiveView(view);
57 view->SetColor(kColors[embed_count_++ % arraysize(kColors)]); 57 view->SetColor(kColors[embed_count_++ % arraysize(kColors)]);
58 } 58 }
59 virtual void OnViewManagerDisconnected( 59 virtual void OnViewManagerDisconnected(
60 mojo::view_manager::ViewManager* view_manager) MOJO_OVERRIDE {} 60 mojo::ViewManager* view_manager) MOJO_OVERRIDE {}
61 61
62 int embed_count_; 62 int embed_count_;
63 mojo::view_manager::ViewManagerClientFactory view_manager_client_factory_; 63 mojo::ViewManagerClientFactory view_manager_client_factory_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(WMFlowApp); 65 DISALLOW_COPY_AND_ASSIGN(WMFlowApp);
66 }; 66 };
67 67
68 } // namespace examples 68 } // namespace examples
69 69
70 namespace mojo { 70 namespace mojo {
71 71
72 // static 72 // static
73 ApplicationDelegate* ApplicationDelegate::Create() { 73 ApplicationDelegate* ApplicationDelegate::Create() {
74 return new examples::WMFlowApp; 74 return new examples::WMFlowApp;
75 } 75 }
76 76
77 } // namespace 77 } // namespace
OLDNEW
« no previous file with comments | « mojo/examples/window_manager/window_manager.cc ('k') | mojo/examples/wm_flow/init/init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698