Chromium Code Reviews| Index: mojo/examples/wm_flow/app/app.cc |
| diff --git a/mojo/examples/wm_flow/app/app.cc b/mojo/examples/wm_flow/app/app.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..634213d2dc45b33f7eb883c23b671a7f9db000ee |
| --- /dev/null |
| +++ b/mojo/examples/wm_flow/app/app.cc |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/bind.h" |
| +#include "mojo/public/cpp/application/application_connection.h" |
| +#include "mojo/public/cpp/application/application_delegate.h" |
| +#include "mojo/public/cpp/application/application_impl.h" |
| +#include "mojo/services/public/cpp/view_manager/node.h" |
| +#include "mojo/services/public/cpp/view_manager/view.h" |
| +#include "mojo/services/public/cpp/view_manager/view_manager.h" |
| +#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| +#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| + |
| +namespace examples { |
| +namespace { |
| +void ConnectCallback(bool success) {} |
| + |
| +const SkColor kColors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorYELLOW }; |
| + |
| +} // namespace |
| + |
| +class WMFlowApp : public mojo::ApplicationDelegate, |
|
sky
2014/07/24 16:43:27
Please add descriptions to your classes. It helps
|
| + public mojo::view_manager::ViewManagerDelegate { |
| + public: |
| + WMFlowApp() : embed_count_(0) {} |
| + virtual ~WMFlowApp() {} |
| + |
| + private: |
| + // Overridden from Application: |
| + virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { |
| + mojo::view_manager::ViewManagerInitServicePtr init_svc; |
| + app->ConnectToService("mojo:mojo_view_manager", &init_svc); |
| + init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback)); |
| + init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback)); |
| + init_svc->Embed("mojo:mojo_wm_flow_app", base::Bind(&ConnectCallback)); |
| + } |
| + virtual bool ConfigureIncomingConnection( |
| + mojo::ApplicationConnection* connection) MOJO_OVERRIDE { |
| + mojo::view_manager::ViewManager::ConfigureIncomingConnection( |
| + connection, this); |
| + return true; |
| + } |
| + |
| + void OnConnect(bool success) {} |
| + |
| + // Overridden from mojo::view_manager::ViewManagerDelegate: |
| + virtual void OnRootAdded(mojo::view_manager::ViewManager* view_manager, |
| + mojo::view_manager::Node* root) MOJO_OVERRIDE { |
| + mojo::view_manager::View* view = |
| + mojo::view_manager::View::Create(view_manager); |
| + root->SetActiveView(view); |
| + view->SetColor(kColors[embed_count_++ % arraysize(kColors)]); |
| + } |
| + virtual void OnViewManagerDisconnected( |
| + mojo::view_manager::ViewManager* view_manager) MOJO_OVERRIDE {} |
| + |
| + int embed_count_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WMFlowApp); |
| +}; |
| + |
| +} // namespace examples |
| + |
| +namespace mojo { |
| + |
| +// static |
| +ApplicationDelegate* ApplicationDelegate::Create() { |
| + return new examples::WMFlowApp; |
| +} |
| + |
| +} // namespace |