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

Side by Side Diff: examples/native_run_app/native_run_app.cc

Issue 2022983003: Roll base to 5e00da80f6adb7082d1c0e88d3274cf87cc43bc5 and tonic to f7acabb8fa6c91124486a41194eac3cd… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 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 terminal client (i.e., a "raw" |mojo.terminal.Terminal| -- e.g., 5 // This is a terminal client (i.e., a "raw" |mojo.terminal.Terminal| -- e.g.,
6 // moterm -- can be asked to talk to this) that prompts the user for a native 6 // moterm -- can be asked to talk to this) that prompts the user for a native
7 // (Linux) binary to run and then does so (via mojo:native_support). 7 // (Linux) binary to run and then does so (via mojo:native_support).
8 // 8 //
9 // E.g., first run mojo:moterm_example_app (embedded by a window manager). Then, 9 // E.g., first run mojo:moterm_example_app (embedded by a window manager). Then,
10 // at the prompt, enter "mojo:native_run_app". At the next prompt, enter "bash" 10 // at the prompt, enter "mojo:native_run_app". At the next prompt, enter "bash"
11 // (or "echo hello mojo"). 11 // (or "echo hello mojo").
12 // 12 //
13 // TODO(vtl): Maybe it should optionally be able to extract the binary path (and 13 // TODO(vtl): Maybe it should optionally be able to extract the binary path (and
14 // args) from the connection URL? 14 // args) from the connection URL?
15 15
16 #include <string.h> 16 #include <string.h>
17 17
18 #include <string> 18 #include <string>
19 #include <utility> 19 #include <utility>
20 #include <vector> 20 #include <vector>
21 21
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/macros.h" 23 #include "base/macros.h"
24 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
25 #include "base/strings/string_util.h"
25 #include "mojo/public/c/system/main.h" 26 #include "mojo/public/c/system/main.h"
26 #include "mojo/public/cpp/application/application_delegate.h" 27 #include "mojo/public/cpp/application/application_delegate.h"
27 #include "mojo/public/cpp/application/application_impl_base.h" 28 #include "mojo/public/cpp/application/application_impl_base.h"
28 #include "mojo/public/cpp/application/connect.h" 29 #include "mojo/public/cpp/application/connect.h"
29 #include "mojo/public/cpp/application/run_application.h" 30 #include "mojo/public/cpp/application/run_application.h"
30 #include "mojo/public/cpp/application/service_provider_impl.h" 31 #include "mojo/public/cpp/application/service_provider_impl.h"
31 #include "mojo/public/cpp/bindings/interface_request.h" 32 #include "mojo/public/cpp/bindings/interface_request.h"
32 #include "mojo/public/cpp/bindings/strong_binding.h" 33 #include "mojo/public/cpp/bindings/strong_binding.h"
33 #include "mojo/services/files/interfaces/files.mojom.h" 34 #include "mojo/services/files/interfaces/files.mojom.h"
34 #include "mojo/services/files/interfaces/ioctl.mojom.h" 35 #include "mojo/services/files/interfaces/ioctl.mojom.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void DidReadFromPrompt(mojo::files::Error error, 89 void DidReadFromPrompt(mojo::files::Error error,
89 mojo::Array<uint8_t> bytes_read) { 90 mojo::Array<uint8_t> bytes_read) {
90 if (error != mojo::files::Error::OK || !bytes_read.size()) { 91 if (error != mojo::files::Error::OK || !bytes_read.size()) {
91 LOG(ERROR) << "Read() error: " << error; 92 LOG(ERROR) << "Read() error: " << error;
92 delete this; 93 delete this;
93 return; 94 return;
94 } 95 }
95 96
96 std::string input(reinterpret_cast<const char*>(&bytes_read[0]), 97 std::string input(reinterpret_cast<const char*>(&bytes_read[0]),
97 bytes_read.size()); 98 bytes_read.size());
98 command_line_.clear(); 99 // TODO(vtl): Are these arguments really what we want? Probably not.
99 base::SplitStringAlongWhitespace(input, &command_line_); 100 command_line_ =
101 base::SplitString(input, base::kWhitespaceASCII, base::KEEP_WHITESPACE,
102 base::SPLIT_WANT_NONEMPTY);
100 103
101 if (command_line_.empty()) { 104 if (command_line_.empty()) {
102 Start(); 105 Start();
103 return; 106 return;
104 } 107 }
105 108
106 // Set the terminal to noncanonical mode. Do so by getting the settings, 109 // Set the terminal to noncanonical mode. Do so by getting the settings,
107 // flipping the flag, and setting them. 110 // flipping the flag, and setting them.
108 // TODO(vtl): Should it do other things? 111 // TODO(vtl): Should it do other things?
109 // TODO(vtl): I wonder if these ioctls shouldn't be done by the 112 // TODO(vtl): I wonder if these ioctls shouldn't be done by the
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 248
246 native_support::ProcessPtr native_support_process_; 249 native_support::ProcessPtr native_support_process_;
247 250
248 DISALLOW_COPY_AND_ASSIGN(NativeRunApp); 251 DISALLOW_COPY_AND_ASSIGN(NativeRunApp);
249 }; 252 };
250 253
251 MojoResult MojoMain(MojoHandle application_request) { 254 MojoResult MojoMain(MojoHandle application_request) {
252 NativeRunApp native_run_app; 255 NativeRunApp native_run_app;
253 return mojo::RunMainApplication(application_request, &native_run_app); 256 return mojo::RunMainApplication(application_request, &native_run_app);
254 } 257 }
OLDNEW
« no previous file with comments | « examples/device_name/java/src/org/chromium/mojo/examples/DeviceName.java ('k') | examples/ui/tile/tile_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698