Chromium Code Reviews| Index: services/keyboard_native/keyboard_service_impl.cc |
| diff --git a/services/keyboard_native/keyboard_service_impl.cc b/services/keyboard_native/keyboard_service_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1d9b64f13f261fe38f2532af22913ae3f95589c0 |
| --- /dev/null |
| +++ b/services/keyboard_native/keyboard_service_impl.cc |
| @@ -0,0 +1,71 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "services/keyboard_native/keyboard_service_impl.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/logging.h" |
| +#include "mojo/public/c/system/main.h" |
| +#include "mojo/public/cpp/application/application_impl.h" |
| +#include "mojo/public/cpp/application/application_runner.h" |
| +#include "mojo/public/cpp/bindings/error_handler.h" |
| +#include "mojo/public/cpp/system/data_pipe.h" |
| + |
| +namespace keyboard { |
| + |
| +KeyboardServiceImpl::KeyboardServiceImpl( |
| + mojo::InterfaceRequest<KeyboardService> handle) |
| + : strong_binding_(this, handle.Pass()) { |
| +} |
| + |
| +KeyboardServiceImpl::~KeyboardServiceImpl() { |
| +} |
| + |
| +// KeyboardService implementation. |
| +void KeyboardServiceImpl::Show(KeyboardClientPtr client) { |
|
jamesr
2015/05/08 23:45:23
note: i think this is deliberate here but keep in
APW
2015/05/09 00:45:58
Acknowledged.
I will hold on to it in a later cha
|
| + keyboard::CompletionData completionData; |
| + completionData.text = "blah"; |
| + completionData.label = "blahblah"; |
| + client->CommitCompletion(completionData.Clone()); |
| + |
| + keyboard::CorrectionData correctionData; |
| + correctionData.old_text = "old text"; |
| + correctionData.new_text = "new text"; |
| + client->CommitCorrection(correctionData.Clone()); |
| + |
| + client->CommitText("", 0); |
| + client->DeleteSurroundingText(0, 0); |
| + client->SetComposingRegion(0, 0); |
| + client->SetComposingText("", 0); |
| + client->SetSelection(0, 1); |
| +} |
| + |
| +void KeyboardServiceImpl::ShowByRequest() { |
| +} |
| + |
| +void KeyboardServiceImpl::Hide() { |
| +} |
| + |
| +// ApplicationDelegate implementation. |
| +bool KeyboardServiceDelegate::ConfigureIncomingConnection( |
| + mojo::ApplicationConnection* connection) { |
| + connection->AddService<KeyboardService>(this); |
| + return true; |
| +} |
| + |
| +// InterfaceFactory<KeyboardService> implementation. |
| +void KeyboardServiceDelegate::Create( |
| + mojo::ApplicationConnection* connection, |
| + mojo::InterfaceRequest<KeyboardService> request) { |
| + // This object will be deleted automatically because of the use of |
| + // StrongBinding<> for the declaration of |strong_binding_|. |
| + new KeyboardServiceImpl(request.Pass()); |
| +} |
| + |
| +} // namespace keyboard |
| + |
| +MojoResult MojoMain(MojoHandle application_request) { |
| + mojo::ApplicationRunner runner(new keyboard::KeyboardServiceDelegate()); |
| + return runner.Run(application_request); |
| +} |