Chromium Code Reviews| 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/logging.h" | |
| 6 #include "mojo/public/c/system/main.h" | |
| 7 #include "mojo/public/cpp/application/application_delegate.h" | |
| 8 #include "mojo/public/cpp/application/application_impl.h" | |
| 9 #include "mojo/public/cpp/application/application_runner.h" | |
| 10 #include "mojo/public/cpp/utility/run_loop.h" | |
| 11 #include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h" | |
| 12 | |
| 13 namespace examples { | |
| 14 | |
| 15 class KeyboardDelegate : public mojo::ApplicationDelegate, | |
| 16 public keyboard::KeyboardClient { | |
| 17 public: | |
| 18 KeyboardDelegate() : binding_(this) {} | |
|
jamesr
2015/05/08 23:45:23
whenever you have a type with a vtable (i.e. inher
APW
2015/05/09 00:45:58
Done.
| |
| 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 mojo::InterfaceRequest<keyboard::KeyboardClient> request = | |
| 27 mojo::GetProxy(&keyboardClient_); | |
|
jamesr
2015/05/08 23:45:23
i think you still want keyboardClient_ to be a loc
APW
2015/05/09 00:45:58
Done.
| |
| 28 binding_.Bind(request.Pass()); | |
| 29 keyboard_->Show(keyboardClient_.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 newCursorPosition) override {} | |
|
jamesr
2015/05/08 23:45:23
by convention we use hacker_style_for_names in c++
APW
2015/05/09 00:45:58
Done.
| |
| 39 | |
| 40 void DeleteSurroundingText(int32_t beforeLength, | |
| 41 int32_t afterLength) override {} | |
| 42 | |
| 43 void SetComposingRegion(int32_t start, int32_t end) override {} | |
| 44 | |
| 45 void SetComposingText(const mojo::String& text, | |
| 46 int32_t newCursorPosition) 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 keyboard::KeyboardClientPtr keyboardClient_; | |
| 54 }; | |
|
jamesr
2015/05/08 23:45:23
add DISALLOW_COPY_AND_ASSIGN(KeyboardDelegate) to
APW
2015/05/09 00:45:58
Done.
| |
| 55 | |
| 56 } // namespace examples | |
| 57 | |
| 58 MojoResult MojoMain(MojoHandle application_request) { | |
| 59 mojo::ApplicationRunner runner(new examples::KeyboardDelegate); | |
| 60 return runner.Run(application_request); | |
| 61 } | |
| OLD | NEW |