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

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

Issue 1976063002: More work on ServiceProviderImpl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sigh Created 4 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/moterm_view.h ('k') | mojo/public/cpp/application/service_provider_impl.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 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 #include "apps/moterm/moterm_view.h" 5 #include "apps/moterm/moterm_view.h"
6 6
7 #ifndef GL_GLEXT_PROTOTYPES 7 #ifndef GL_GLEXT_PROTOTYPES
8 #define GL_GLEXT_PROTOTYPES 8 #define GL_GLEXT_PROTOTYPES
9 #endif 9 #endif
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 advance_width_(0), 51 advance_width_(0),
52 keypad_application_mode_(false) { 52 keypad_application_mode_(false) {
53 // TODO(vtl): |service_provider_impl_|'s ctor doesn't like an invalid request, 53 // TODO(vtl): |service_provider_impl_|'s ctor doesn't like an invalid request,
54 // so we have to conditionally, explicitly bind. 54 // so we have to conditionally, explicitly bind.
55 if (service_provider_request.is_pending()) { 55 if (service_provider_request.is_pending()) {
56 // TODO(vtl): The connection context should probably be plumbed here, which 56 // TODO(vtl): The connection context should probably be plumbed here, which
57 // means that mojo::ui::ViewProviderApp::CreateView() should probably have a 57 // means that mojo::ui::ViewProviderApp::CreateView() should probably have a
58 // connection context argument. 58 // connection context argument.
59 service_provider_impl_.Bind(mojo::ConnectionContext(), 59 service_provider_impl_.Bind(mojo::ConnectionContext(),
60 service_provider_request.Pass()); 60 service_provider_request.Pass());
61 service_provider_impl_.AddService<mojo::terminal::Terminal>(this); 61 service_provider_impl_.AddService<mojo::terminal::Terminal>([this](
62 const mojo::ConnectionContext& connection_context,
63 mojo::InterfaceRequest<mojo::terminal::Terminal> terminal_request) {
64 terminal_bindings_.AddBinding(this, terminal_request.Pass());
65 });
62 } 66 }
63 67
64 regular_typeface_ = skia::AdoptRef(SkTypeface::CreateFromStream( 68 regular_typeface_ = skia::AdoptRef(SkTypeface::CreateFromStream(
65 new SkMemoryStream(font_data::kDejaVuSansMonoRegular.data, 69 new SkMemoryStream(font_data::kDejaVuSansMonoRegular.data,
66 font_data::kDejaVuSansMonoRegular.size))); 70 font_data::kDejaVuSansMonoRegular.size)));
67 71
68 // TODO(vtl): This duplicates some code. 72 // TODO(vtl): This duplicates some code.
69 SkPaint fg_paint; 73 SkPaint fg_paint;
70 fg_paint.setTypeface(regular_typeface_.get()); 74 fg_paint.setTypeface(regular_typeface_.get());
71 fg_paint.setTextSize(16); 75 fg_paint.setTextSize(16);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 130
127 void MotermView::OnDestroyed() { 131 void MotermView::OnDestroyed() {
128 DCHECK(!driver_); 132 DCHECK(!driver_);
129 if (!on_closed_callback_.is_null()) { 133 if (!on_closed_callback_.is_null()) {
130 mojo::Closure callback; 134 mojo::Closure callback;
131 std::swap(callback, on_closed_callback_); 135 std::swap(callback, on_closed_callback_);
132 callback.Run(); 136 callback.Run();
133 } 137 }
134 } 138 }
135 139
136 void MotermView::Create(
137 const mojo::ConnectionContext& connection_context,
138 mojo::InterfaceRequest<mojo::terminal::Terminal> request) {
139 terminal_bindings_.AddBinding(this, request.Pass());
140 }
141
142 void MotermView::Connect( 140 void MotermView::Connect(
143 mojo::InterfaceRequest<mojo::files::File> terminal_file, 141 mojo::InterfaceRequest<mojo::files::File> terminal_file,
144 bool force, 142 bool force,
145 const ConnectCallback& callback) { 143 const ConnectCallback& callback) {
146 if (driver_) { 144 if (driver_) {
147 // We already have a connection. 145 // We already have a connection.
148 if (force) { 146 if (force) {
149 OnClosed(); 147 OnClosed();
150 } else { 148 } else {
151 // TODO(vtl): Is this error code right? 149 // TODO(vtl): Is this error code right?
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 334
337 void MotermView::OnKeyPressed(mojo::EventPtr key_event) { 335 void MotermView::OnKeyPressed(mojo::EventPtr key_event) {
338 std::string input_sequence = 336 std::string input_sequence =
339 GetInputSequenceForKeyPressedEvent(*key_event, keypad_application_mode_); 337 GetInputSequenceForKeyPressedEvent(*key_event, keypad_application_mode_);
340 if (input_sequence.empty()) 338 if (input_sequence.empty())
341 return; 339 return;
342 340
343 if (driver_) 341 if (driver_)
344 driver_->SendData(input_sequence.data(), input_sequence.size()); 342 driver_->SendData(input_sequence.data(), input_sequence.size());
345 } 343 }
OLDNEW
« no previous file with comments | « apps/moterm/moterm_view.h ('k') | mojo/public/cpp/application/service_provider_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698