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

Side by Side Diff: apps/moterm/moterm_main.cc

Issue 1136673004: Moterm part 5: Add moterm itself. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « apps/moterm/BUILD.gn ('k') | apps/moterm/moterm_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This is the "main" for the embeddable Moterm terminal view, which provides
6 // services to the thing embedding it. (This is not very useful as a "top-level"
7 // application.)
8
9 #include "apps/moterm/moterm_view.h"
10 #include "base/logging.h"
5 #include "base/macros.h" 11 #include "base/macros.h"
6 #include "examples/ganesh_app/ganesh_view.h"
7 #include "mojo/application/application_runner_chromium.h" 12 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/public/c/system/main.h" 13 #include "mojo/public/c/system/main.h"
9 #include "mojo/public/cpp/application/application_connection.h" 14 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 15 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_impl.h" 16 #include "mojo/public/cpp/application/application_impl.h"
12 #include "mojo/services/view_manager/public/cpp/view_manager.h" 17 #include "mojo/services/view_manager/public/cpp/view_manager.h"
13 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h" 18 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
14 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" 19 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
15 20
16 namespace examples { 21 namespace {
17 22
18 class GaneshApp : public mojo::ApplicationDelegate, 23 class Moterm : public mojo::ApplicationDelegate,
19 public mojo::ViewManagerDelegate { 24 public mojo::ViewManagerDelegate {
20 public: 25 public:
21 GaneshApp() {} 26 Moterm() : application_impl_() {}
22 ~GaneshApp() override {} 27 ~Moterm() override {}
23 28
24 void Initialize(mojo::ApplicationImpl* app) override { 29 private:
25 shell_ = app->shell(); 30 // |mojo::ApplicationDelegate|:
31 void Initialize(mojo::ApplicationImpl* application_impl) override {
32 DCHECK(!application_impl_);
33 application_impl_ = application_impl;
26 view_manager_client_factory_.reset( 34 view_manager_client_factory_.reset(
27 new mojo::ViewManagerClientFactory(app->shell(), this)); 35 new mojo::ViewManagerClientFactory(application_impl_->shell(), this));
28 } 36 }
29 37
30 bool ConfigureIncomingConnection( 38 bool ConfigureIncomingConnection(
31 mojo::ApplicationConnection* connection) override { 39 mojo::ApplicationConnection* connection) override {
32 connection->AddService(view_manager_client_factory_.get()); 40 connection->AddService(view_manager_client_factory_.get());
33 return true; 41 return true;
34 } 42 }
35 43
44 // |mojo::ViewManagerDelegate|:
36 void OnEmbed(mojo::View* root, 45 void OnEmbed(mojo::View* root,
37 mojo::InterfaceRequest<mojo::ServiceProvider> services, 46 mojo::InterfaceRequest<mojo::ServiceProvider> services,
38 mojo::ServiceProviderPtr exposed_services) override { 47 mojo::ServiceProviderPtr exposed_services) override {
39 new GaneshView(shell_, root); 48 new MotermView(application_impl_->shell(), root, services.Pass());
40 } 49 }
41 50
42 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override { 51 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override {
43 base::MessageLoop::current()->Quit(); 52 base::MessageLoop::current()->Quit();
44 } 53 }
45 54
46 private: 55 mojo::ApplicationImpl* application_impl_;
47 mojo::Shell* shell_;
48 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_; 56 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
49 57
50 DISALLOW_COPY_AND_ASSIGN(GaneshApp); 58 DISALLOW_COPY_AND_ASSIGN(Moterm);
51 }; 59 };
52 60
53 } // namespace examples 61 } // namespace
54 62
55 MojoResult MojoMain(MojoHandle application_request) { 63 MojoResult MojoMain(MojoHandle application_request) {
56 mojo::ApplicationRunnerChromium runner(new examples::GaneshApp); 64 mojo::ApplicationRunnerChromium runner(new Moterm());
57 return runner.Run(application_request); 65 return runner.Run(application_request);
58 } 66 }
OLDNEW
« no previous file with comments | « apps/moterm/BUILD.gn ('k') | apps/moterm/moterm_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698