OLD | NEW |
1 // Copyright 2015 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 a simple example application (with an embeddable view), which embeds | 5 // This is a simple example application (with an embeddable view), which embeds |
6 // the Moterm view, uses it to prompt the user, etc. | 6 // the Moterm view, uses it to prompt the user, etc. |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "mojo/services/terminal/public/interfaces/terminal_client.mojom.h" | 29 #include "mojo/services/terminal/public/interfaces/terminal_client.mojom.h" |
30 #include "mojo/services/view_manager/public/cpp/view.h" | 30 #include "mojo/services/view_manager/public/cpp/view.h" |
31 #include "mojo/services/view_manager/public/cpp/view_manager.h" | 31 #include "mojo/services/view_manager/public/cpp/view_manager.h" |
32 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h" | 32 #include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h" |
33 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" | 33 #include "mojo/services/view_manager/public/cpp/view_manager_delegate.h" |
34 #include "mojo/services/view_manager/public/cpp/view_observer.h" | 34 #include "mojo/services/view_manager/public/cpp/view_observer.h" |
35 | 35 |
36 // Kind of like |fputs()| (doesn't wait for result). | 36 // Kind of like |fputs()| (doesn't wait for result). |
37 void Fputs(mojo::files::File* file, const char* s) { | 37 void Fputs(mojo::files::File* file, const char* s) { |
38 size_t length = strlen(s); | 38 size_t length = strlen(s); |
39 mojo::Array<uint8_t> a(length); | 39 auto a = mojo::Array<uint8_t>::New(length); |
40 memcpy(&a[0], s, length); | 40 memcpy(&a[0], s, length); |
41 | 41 |
42 file->Write(a.Pass(), 0, mojo::files::Whence::FROM_CURRENT, | 42 file->Write(a.Pass(), 0, mojo::files::Whence::FROM_CURRENT, |
43 mojo::files::File::WriteCallback()); | 43 mojo::files::File::WriteCallback()); |
44 } | 44 } |
45 | 45 |
46 class MotermExampleAppView : public mojo::ViewObserver { | 46 class MotermExampleAppView : public mojo::ViewObserver { |
47 public: | 47 public: |
48 explicit MotermExampleAppView(mojo::Shell* shell, mojo::View* view) | 48 explicit MotermExampleAppView(mojo::Shell* shell, mojo::View* view) |
49 : shell_(shell), view_(view), moterm_view_(), weak_factory_(this) { | 49 : shell_(shell), view_(view), moterm_view_(), weak_factory_(this) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 mojo::ApplicationImpl* application_impl_; | 195 mojo::ApplicationImpl* application_impl_; |
196 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_; | 196 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_; |
197 | 197 |
198 DISALLOW_COPY_AND_ASSIGN(MotermExampleApp); | 198 DISALLOW_COPY_AND_ASSIGN(MotermExampleApp); |
199 }; | 199 }; |
200 | 200 |
201 MojoResult MojoMain(MojoHandle application_request) { | 201 MojoResult MojoMain(MojoHandle application_request) { |
202 mojo::ApplicationRunnerChromium runner(new MotermExampleApp()); | 202 mojo::ApplicationRunnerChromium runner(new MotermExampleApp()); |
203 return runner.Run(application_request); | 203 return runner.Run(application_request); |
204 } | 204 } |
OLD | NEW |