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

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

Issue 400113005: A new WM bootstrap flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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/wm_flow/app/DEPS ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "mojo/public/cpp/application/application_connection.h"
7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/services/public/cpp/view_manager/node.h"
10 #include "mojo/services/public/cpp/view_manager/view.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"
13 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
14 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
15
16 namespace examples {
17 namespace {
18 void ConnectCallback(bool success) {}
19
20 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW };
21
22 } // namespace
23
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
26 // connection by connecting to the ViewManagerInit service and asking to be
27 // embed without a node context.
28 class WMFlowApp : public mojo::ApplicationDelegate,
29 public mojo::view_manager::ViewManagerDelegate {
30 public:
31 WMFlowApp() : embed_count_(0), view_manager_client_factory_(this) {}
32 virtual ~WMFlowApp() {}
33
34 private:
35 // Overridden from Application:
36 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
37 mojo::view_manager::ViewManagerInitServicePtr init_svc;
38 app->ConnectToService("mojo:mojo_view_manager", &init_svc);
39 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));
42 }
43 virtual bool ConfigureIncomingConnection(
44 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
45 connection->AddService(&view_manager_client_factory_);
46 return true;
47 }
48
49 void OnConnect(bool success) {}
50
51 // Overridden from mojo::view_manager::ViewManagerDelegate:
52 virtual void OnRootAdded(mojo::view_manager::ViewManager* view_manager,
53 mojo::view_manager::Node* root) MOJO_OVERRIDE {
54 mojo::view_manager::View* view =
55 mojo::view_manager::View::Create(view_manager);
56 root->SetActiveView(view);
57 view->SetColor(kColors[embed_count_++ % arraysize(kColors)]);
58 }
59 virtual void OnViewManagerDisconnected(
60 mojo::view_manager::ViewManager* view_manager) MOJO_OVERRIDE {}
61
62 int embed_count_;
63 mojo::view_manager::ViewManagerClientFactory view_manager_client_factory_;
64
65 DISALLOW_COPY_AND_ASSIGN(WMFlowApp);
66 };
67
68 } // namespace examples
69
70 namespace mojo {
71
72 // static
73 ApplicationDelegate* ApplicationDelegate::Create() {
74 return new examples::WMFlowApp;
75 }
76
77 } // namespace
OLDNEW
« no previous file with comments | « mojo/examples/wm_flow/app/DEPS ('k') | mojo/examples/wm_flow/init/init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698