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

Side by Side Diff: mojo/examples/wm_flow/app/app.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: git cl format 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/c/system/main.h" 8 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // This app starts its life via Connect() rather than by being embed, so it does 46 // This app starts its life via Connect() rather than by being embed, so it does
47 // not start with a connection to the ViewManager service. It has to obtain a 47 // not start with a connection to the ViewManager service. It has to obtain a
48 // connection by connecting to the ViewManagerInit service and asking to be 48 // connection by connecting to the ViewManagerInit service and asking to be
49 // embed without a view context. 49 // embed without a view context.
50 class WMFlowApp : public mojo::ApplicationDelegate, 50 class WMFlowApp : public mojo::ApplicationDelegate,
51 public mojo::ViewManagerDelegate, 51 public mojo::ViewManagerDelegate,
52 public mojo::ViewObserver { 52 public mojo::ViewObserver {
53 public: 53 public:
54 WMFlowApp() 54 WMFlowApp()
55 : embed_count_(0), 55 : embed_count_(0),
56 view_manager_client_factory_(this),
57 app_(NULL) {} 56 app_(NULL) {}
58 virtual ~WMFlowApp() {} 57 virtual ~WMFlowApp() {}
59 58
60 private: 59 private:
61 // Overridden from Application: 60 // Overridden from Application:
62 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE { 61 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
62 view_manager_client_factory_.reset(
63 new mojo::ViewManagerClientFactory(app->shell(), this));
63 app_ = app; 64 app_ = app;
64 OpenNewWindow(); 65 OpenNewWindow();
65 OpenNewWindow(); 66 OpenNewWindow();
66 OpenNewWindow(); 67 OpenNewWindow();
67 } 68 }
68 virtual bool ConfigureIncomingConnection( 69 virtual bool ConfigureIncomingConnection(
69 mojo::ApplicationConnection* connection) MOJO_OVERRIDE { 70 mojo::ApplicationConnection* connection) MOJO_OVERRIDE {
70 connection->AddService(&view_manager_client_factory_); 71 connection->AddService(view_manager_client_factory_.get());
71 return true; 72 return true;
72 } 73 }
73 74
74 void OnConnect(bool success) {} 75 void OnConnect(bool success) {}
75 76
76 // Overridden from mojo::ViewManagerDelegate: 77 // Overridden from mojo::ViewManagerDelegate:
77 virtual void OnEmbed( 78 virtual void OnEmbed(
78 mojo::ViewManager* view_manager, 79 mojo::ViewManager* view_manager,
79 mojo::View* root, 80 mojo::View* root,
80 mojo::ServiceProviderImpl* exported_services, 81 mojo::ServiceProviderImpl* exported_services,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 121
121 void OpenNewWindow() { 122 void OpenNewWindow() {
122 mojo::ViewManagerInitServicePtr init_svc; 123 mojo::ViewManagerInitServicePtr init_svc;
123 app_->ConnectToService("mojo:mojo_view_manager", &init_svc); 124 app_->ConnectToService("mojo:mojo_view_manager", &init_svc);
124 mojo::ServiceProviderPtr sp; 125 mojo::ServiceProviderPtr sp;
125 init_svc->Embed("mojo:mojo_wm_flow_app", sp.Pass(), 126 init_svc->Embed("mojo:mojo_wm_flow_app", sp.Pass(),
126 base::Bind(&ConnectCallback)); 127 base::Bind(&ConnectCallback));
127 } 128 }
128 129
129 int embed_count_; 130 int embed_count_;
130 mojo::ViewManagerClientFactory view_manager_client_factory_; 131 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
131 mojo::InterfaceFactoryImpl<EmbedderImpl> embedder_factory_; 132 mojo::InterfaceFactoryImpl<EmbedderImpl> embedder_factory_;
132 EmbeddeePtr embeddee_; 133 EmbeddeePtr embeddee_;
133 mojo::ApplicationImpl* app_; 134 mojo::ApplicationImpl* app_;
134 135
135 DISALLOW_COPY_AND_ASSIGN(WMFlowApp); 136 DISALLOW_COPY_AND_ASSIGN(WMFlowApp);
136 }; 137 };
137 138
138 } // namespace examples 139 } // namespace examples
139 140
140 MojoResult MojoMain(MojoHandle shell_handle) { 141 MojoResult MojoMain(MojoHandle shell_handle) {
141 mojo::ApplicationRunnerChromium runner(new examples::WMFlowApp); 142 mojo::ApplicationRunnerChromium runner(new examples::WMFlowApp);
142 return runner.Run(shell_handle); 143 return runner.Run(shell_handle);
143 } 144 }
OLDNEW
« no previous file with comments | « mojo/examples/window_manager/window_manager.cc ('k') | mojo/examples/wm_flow/embedded/embedded.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698