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

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

Issue 2034383003: Removed exposed_services from mojom definitions. (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 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 class MotermExampleAppView { 46 class MotermExampleAppView {
47 public: 47 public:
48 MotermExampleAppView( 48 MotermExampleAppView(
49 mojo::Shell* shell, 49 mojo::Shell* shell,
50 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) 50 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request)
51 : shell_(shell), weak_factory_(this) { 51 : shell_(shell), weak_factory_(this) {
52 // Connect to the moterm app. 52 // Connect to the moterm app.
53 LOG(INFO) << "Connecting to moterm"; 53 LOG(INFO) << "Connecting to moterm";
54 mojo::ServiceProviderPtr moterm_app; 54 mojo::ServiceProviderPtr moterm_app;
55 shell->ConnectToApplication("mojo:moterm", GetProxy(&moterm_app), nullptr); 55 shell->ConnectToApplication("mojo:moterm", GetProxy(&moterm_app));
56 56
57 // Create the moterm view and pass it back to the client directly. 57 // Create the moterm view and pass it back to the client directly.
58 mojo::ConnectToService(moterm_app.get(), GetProxy(&moterm_view_provider_)); 58 mojo::ConnectToService(moterm_app.get(), GetProxy(&moterm_view_provider_));
59 mojo::ServiceProviderPtr moterm_service_provider; 59 mojo::ServiceProviderPtr moterm_service_provider;
60 moterm_view_provider_->CreateView(view_owner_request.Pass(), 60 moterm_view_provider_->CreateView(view_owner_request.Pass(),
61 GetProxy(&moterm_service_provider)); 61 GetProxy(&moterm_service_provider));
62 62
63 // Connect to the moterm terminal service associated with the view 63 // Connect to the moterm terminal service associated with the view
64 // we just created. 64 // we just created.
65 mojo::ConnectToService(moterm_service_provider.get(), 65 mojo::ConnectToService(moterm_service_provider.get(),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 Fputs(moterm_file_.get(), "\nError: no destination URL given\n"); 121 Fputs(moterm_file_.get(), "\nError: no destination URL given\n");
122 StartPrompt(false); 122 StartPrompt(false);
123 return; 123 return;
124 } 124 }
125 125
126 Fputs(moterm_file_.get(), 126 Fputs(moterm_file_.get(),
127 base::StringPrintf("\nGoing to %s ...\n", dest_url.c_str()).c_str()); 127 base::StringPrintf("\nGoing to %s ...\n", dest_url.c_str()).c_str());
128 moterm_file_.reset(); 128 moterm_file_.reset();
129 129
130 mojo::ServiceProviderPtr dest_sp; 130 mojo::ServiceProviderPtr dest_sp;
131 shell_->ConnectToApplication(dest_url, GetProxy(&dest_sp), nullptr); 131 shell_->ConnectToApplication(dest_url, GetProxy(&dest_sp));
132 mojo::terminal::TerminalClientPtr dest_terminal_client; 132 mojo::terminal::TerminalClientPtr dest_terminal_client;
133 mojo::ConnectToService(dest_sp.get(), GetProxy(&dest_terminal_client)); 133 mojo::ConnectToService(dest_sp.get(), GetProxy(&dest_terminal_client));
134 moterm_terminal_->ConnectToClient( 134 moterm_terminal_->ConnectToClient(
135 std::move(dest_terminal_client), true, 135 std::move(dest_terminal_client), true,
136 base::Bind(&MotermExampleAppView::OnDestinationDone, 136 base::Bind(&MotermExampleAppView::OnDestinationDone,
137 weak_factory_.GetWeakPtr())); 137 weak_factory_.GetWeakPtr()));
138 } 138 }
139 void OnDestinationDone(mojo::files::Error error) { 139 void OnDestinationDone(mojo::files::Error error) {
140 // We should always succeed. (It'll only fail on synchronous failures, which 140 // We should always succeed. (It'll only fail on synchronous failures, which
141 // only occur when it's busy.) 141 // only occur when it's busy.)
(...skipping 28 matching lines...) Expand all
170 170
171 private: 171 private:
172 DISALLOW_COPY_AND_ASSIGN(MotermExampleApp); 172 DISALLOW_COPY_AND_ASSIGN(MotermExampleApp);
173 }; 173 };
174 174
175 MojoResult MojoMain(MojoHandle application_request) { 175 MojoResult MojoMain(MojoHandle application_request) {
176 mojo::ScopedChromiumInit init; 176 mojo::ScopedChromiumInit init;
177 MotermExampleApp moterm_example_app; 177 MotermExampleApp moterm_example_app;
178 return mojo::RunApplication(application_request, &moterm_example_app); 178 return mojo::RunApplication(application_request, &moterm_example_app);
179 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698