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

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
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_delegate.h"
13 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
14
15 namespace examples {
16 namespace {
17 void ConnectCallback(bool success) {}
18
19 const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW };
20
21 } // namespace
22
23 class WMFlowApp : public mojo::ApplicationDelegate,
sky 2014/07/24 16:43:27 Please add descriptions to your classes. It helps
24 public mojo::view_manager::ViewManagerDelegate {
25 public:
26 WMFlowApp() : embed_count_(0) {}
27 virtual ~WMFlowApp() {}
28
29 private:
30 // Overridden from Application:
31 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
32 mojo::view_manager::ViewManagerInitServicePtr init_svc;
33 app->ConnectToService("mojo:mojo_view_manager", &init_svc);
34 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
35 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
36 init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback));
37 }
38 virtual bool ConfigureIncomingConnection(
39 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
40 mojo::view_manager::ViewManager::ConfigureIncomingConnection(
41 connection, this);
42 return true;
43 }
44
45 void OnConnect(bool success) {}
46
47 // Overridden from mojo::view_manager::ViewManagerDelegate:
48 virtual void OnRootAdded(mojo::view_manager::ViewManager* view_manager,
49 mojo::view_manager::Node* root) MOJO_OVERRIDE {
50 mojo::view_manager::View* view =
51 mojo::view_manager::View::Create(view_manager);
52 root->SetActiveView(view);
53 view->SetColor(kColors[embed_count_++ % arraysize(kColors)]);
54 }
55 virtual void OnViewManagerDisconnected(
56 mojo::view_manager::ViewManager* view_manager) MOJO_OVERRIDE {}
57
58 int embed_count_;
59
60 DISALLOW_COPY_AND_ASSIGN(WMFlowApp);
61 };
62
63 } // namespace examples
64
65 namespace mojo {
66
67 // static
68 ApplicationDelegate* ApplicationDelegate::Create() {
69 return new examples::WMFlowApp;
70 }
71
72 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698