OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/macros.h" |
| 6 #include "mojo/public/cpp/application/application_delegate.h" |
| 7 #include "mojo/public/cpp/application/application_impl.h" |
| 8 #include "mojo/public/cpp/application/application_runner.h" |
| 9 #include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h" |
| 10 |
| 11 namespace examples { |
| 12 |
| 13 class KeyboardDelegate : public mojo::ApplicationDelegate, |
| 14 public keyboard::KeyboardClient { |
| 15 public: |
| 16 KeyboardDelegate() : binding_(this) {} |
| 17 |
| 18 ~KeyboardDelegate() override {} |
| 19 |
| 20 // mojo::ApplicationDelegate implementation. |
| 21 void Initialize(mojo::ApplicationImpl* app) override { |
| 22 app->ConnectToService("mojo:keyboard_native", &keyboard_); |
| 23 keyboard_->ShowByRequest(); |
| 24 keyboard_->Hide(); |
| 25 |
| 26 keyboard::KeyboardClientPtr keyboard_client; |
| 27 auto request = mojo::GetProxy(&keyboard_client); |
| 28 binding_.Bind(request.Pass()); |
| 29 keyboard_->Show(keyboard_client.Pass()); |
| 30 } |
| 31 |
| 32 // keyboard::KeyboardClient implementation. |
| 33 void CommitCompletion(keyboard::CompletionDataPtr completion) override {} |
| 34 |
| 35 void CommitCorrection(keyboard::CorrectionDataPtr correction) override {} |
| 36 |
| 37 void CommitText(const mojo::String& text, |
| 38 int32_t new_cursor_position) override {} |
| 39 |
| 40 void DeleteSurroundingText(int32_t before_length, |
| 41 int32_t after_length) override {} |
| 42 |
| 43 void SetComposingRegion(int32_t start, int32_t end) override {} |
| 44 |
| 45 void SetComposingText(const mojo::String& text, |
| 46 int32_t new_cursor_position) override {} |
| 47 |
| 48 void SetSelection(int32_t start, int32_t end) override {} |
| 49 |
| 50 private: |
| 51 mojo::Binding<keyboard::KeyboardClient> binding_; |
| 52 keyboard::KeyboardServicePtr keyboard_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(KeyboardDelegate); |
| 55 }; |
| 56 |
| 57 } // namespace examples |
| 58 |
| 59 MojoResult MojoMain(MojoHandle application_request) { |
| 60 mojo::ApplicationRunner runner(new examples::KeyboardDelegate); |
| 61 return runner.Run(application_request); |
| 62 } |
OLD | NEW |