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

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

Issue 514063003: Update view_manager and window_manager to make use of content handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@viewman2
Patch Set: rebase Created 6 years, 3 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
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/examples/wm_flow/app/embedder.mojom.h" 6 #include "mojo/examples/wm_flow/app/embedder.mojom.h"
7 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h" 7 #include "mojo/examples/wm_flow/embedded/embeddee.mojom.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/cpp/application/application_delegate.h" 9 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 DISALLOW_COPY_AND_ASSIGN(EmbeddeeImpl); 35 DISALLOW_COPY_AND_ASSIGN(EmbeddeeImpl);
36 }; 36 };
37 37
38 } // namespace 38 } // namespace
39 39
40 class WMFlowEmbedded : public mojo::ApplicationDelegate, 40 class WMFlowEmbedded : public mojo::ApplicationDelegate,
41 public mojo::ViewManagerDelegate { 41 public mojo::ViewManagerDelegate {
42 public: 42 public:
43 WMFlowEmbedded() 43 WMFlowEmbedded() {}
44 : view_manager_client_factory_(this) {}
45 virtual ~WMFlowEmbedded() {} 44 virtual ~WMFlowEmbedded() {}
46 45
47 private: 46 private:
48 // Overridden from Application: 47 // Overridden from Application:
49 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { 48 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
49 view_manager_client_factory_.reset(
50 new mojo::ViewManagerClientFactory(app->shell(), this));
50 } 51 }
51 virtual bool ConfigureIncomingConnection( 52 virtual bool ConfigureIncomingConnection(
52 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 53 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
53 connection->AddService(&view_manager_client_factory_); 54 connection->AddService(view_manager_client_factory_.get());
54 return true; 55 return true;
55 } 56 }
56 57
57 // Overridden from mojo::ViewManagerDelegate: 58 // Overridden from mojo::ViewManagerDelegate:
58 virtual void OnEmbed( 59 virtual void OnEmbed(
59 mojo::ViewManager* view_manager, 60 mojo::ViewManager* view_manager,
60 mojo::View* root, 61 mojo::View* root,
61 mojo::ServiceProviderImpl* exported_services, 62 mojo::ServiceProviderImpl* exported_services,
62 scoped_ptr<mojo::ServiceProvider> imported_services) MOJO_OVERRIDE { 63 scoped_ptr<mojo::ServiceProvider> imported_services) MOJO_OVERRIDE {
63 root->SetColor(SK_ColorMAGENTA); 64 root->SetColor(SK_ColorMAGENTA);
64 65
65 exported_services->AddService(&embeddee_factory_); 66 exported_services->AddService(&embeddee_factory_);
66 mojo::ConnectToService(imported_services.get(), &embedder_); 67 mojo::ConnectToService(imported_services.get(), &embedder_);
67 embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck, 68 embedder_->HelloWorld(base::Bind(&WMFlowEmbedded::HelloWorldAck,
68 base::Unretained(this))); 69 base::Unretained(this)));
69 } 70 }
70 virtual void OnViewManagerDisconnected( 71 virtual void OnViewManagerDisconnected(
71 mojo::ViewManager* view_manager) MOJO_OVERRIDE {} 72 mojo::ViewManager* view_manager) MOJO_OVERRIDE {}
72 73
73 void HelloWorldAck() { 74 void HelloWorldAck() {
74 printf("HelloWorld() ack'ed\n"); 75 printf("HelloWorld() ack'ed\n");
75 } 76 }
76 77
77 mojo::ViewManagerClientFactory view_manager_client_factory_; 78 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
78 EmbedderPtr embedder_; 79 EmbedderPtr embedder_;
79 mojo::InterfaceFactoryImpl<EmbeddeeImpl> embeddee_factory_; 80 mojo::InterfaceFactoryImpl<EmbeddeeImpl> embeddee_factory_;
80 81
81 DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded); 82 DISALLOW_COPY_AND_ASSIGN(WMFlowEmbedded);
82 }; 83 };
83 84
84 } // namespace examples 85 } // namespace examples
85 86
86 namespace mojo { 87 namespace mojo {
87 88
88 // static 89 // static
89 ApplicationDelegate* ApplicationDelegate::Create() { 90 ApplicationDelegate* ApplicationDelegate::Create() {
90 return new examples::WMFlowEmbedded; 91 return new examples::WMFlowEmbedded;
91 } 92 }
92 93
93 } // namespace 94 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698