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

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

Issue 684543003: Move //mojo/examples to //examples (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « mojo/examples/wm_flow/app/embedder.mojom ('k') | mojo/examples/wm_flow/embedded/embeddee.mojom » ('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 "base/macros.h"
7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/examples/bitmap_uploader/bitmap_uploader.h"
9 #include "mojo/examples/wm_flow/app/embedder.mojom.h"
10 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h"
11 #include "mojo/public/cpp/application/application_connection.h"
12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/application/connect.h"
15 #include "mojo/public/cpp/application/interface_factory_impl.h"
16 #include "mojo/public/cpp/application/service_provider_impl.h"
17 #include "mojo/services/public/cpp/view_manager/view.h"
18 #include "mojo/services/public/cpp/view_manager/view_manager.h"
19 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h"
20 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
21
22 namespace examples {
23
24 namespace {
25
26 class EmbeddeeImpl : public mojo::InterfaceImpl<Embeddee> {
27 public:
28 EmbeddeeImpl() {}
29 virtual ~EmbeddeeImpl() {}
30
31 private:
32 // Overridden from Embeddee:
33 virtual void HelloBack(const mojo::Callback<void()>& callback) override {
34 callback.Run();
35 }
36
37 DISALLOW_COPY_AND_ASSIGN(EmbeddeeImpl);
38 };
39
40 } // namespace
41
42 class WMFlowEmbedded : public mojo::ApplicationDelegate,
43 public mojo::ViewManagerDelegate {
44 public:
45 WMFlowEmbedded() : shell_(nullptr) {}
46 virtual ~WMFlowEmbedded() {}
47
48 private:
49 // Overridden from Application:
50 virtual void Initialize(mojo::ApplicationImpl* app) override {
51 shell_ = app->shell();
52 view_manager_client_factory_.reset(
53 new mojo::ViewManagerClientFactory(app->shell(), this));
54 }
55 virtual bool ConfigureIncomingConnection(
56 mojo::ApplicationConnection* connection) override {
57 connection->AddService(view_manager_client_factory_.get());
58 return true;
59 }
60
61 // Overridden from mojo::ViewManagerDelegate:
62 virtual void OnEmbed(
63 mojo::ViewManager* view_manager,
64 mojo::View* root,
65 mojo::ServiceProviderImpl* exported_services,
66 scoped_ptr<mojo::ServiceProvider> imported_services) override {
67 bitmap_uploader_.reset(new mojo::BitmapUploader(root));
68 bitmap_uploader_->Init(shell_);
69 bitmap_uploader_->SetColor(SK_ColorMAGENTA);
70
71 exported_services->AddService(&embeddee_factory_);
72 mojo::ConnectToService(imported_services.get(), &embedder_);
73 embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck,
74 base::Unretained(this)));
75 }
76 virtual void OnViewManagerDisconnected(
77 mojo::ViewManager* view_manager) override {}
78
79 void HelloWorldAck() {
80 printf("HelloWorld() ack'ed\n");
81 }
82
83 mojo::Shell* shell_;
84 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
85 EmbedderPtr embedder_;
86 mojo::InterfaceFactoryImpl<EmbeddeeImpl> embeddee_factory_;
87 scoped_ptr<mojo::BitmapUploader> bitmap_uploader_;
88
89 DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded);
90 };
91
92 } // namespace examples
93
94 MojoResult MojoMain(MojoHandle shell_handle) {
95 mojo::ApplicationRunnerChromium runner(new examples::WMFlowEmbedded);
96 return runner.Run(shell_handle);
97 }
98
OLDNEW
« no previous file with comments | « mojo/examples/wm_flow/app/embedder.mojom ('k') | mojo/examples/wm_flow/embedded/embeddee.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698