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 <stdio.h> | |
|
jamesr
2015/05/08 20:55:15
don't think you are using this
APW
2015/05/08 22:09:28
Done.
| |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "mojo/public/c/system/main.h" | |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | |
| 10 #include "mojo/public/cpp/application/application_impl.h" | |
| 11 #include "mojo/public/cpp/application/application_runner.h" | |
| 12 #include "mojo/public/cpp/utility/run_loop.h" | |
| 13 #include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h" | |
| 14 | |
| 15 namespace mojo { | |
|
jamesr
2015/05/08 20:55:15
please put this in the namespace 'examples', not '
APW
2015/05/08 22:09:28
Done.
| |
| 16 namespace examples { | |
| 17 | |
| 18 class KeyboardDelegate : public ApplicationDelegate, | |
| 19 public keyboard::KeyboardClient { | |
|
jamesr
2015/05/08 20:55:15
this 'public' should be aligned with the previous
APW
2015/05/08 22:09:28
Done.
| |
| 20 public: | |
| 21 | |
| 22 keyboard::KeyboardClientPtr mystery_; | |
|
jamesr
2015/05/08 20:55:15
put member vars after functions and in the private
APW
2015/05/08 22:09:28
Done.
| |
| 23 mojo::InterfaceRequest<keyboard::KeyboardClient> request_; | |
| 24 mojo::Binding<keyboard::KeyboardClient>* binding_; | |
| 25 | |
| 26 void Initialize(ApplicationImpl* app) override { | |
|
jamesr
2015/05/08 20:55:16
it's really useful to document what base class a m
APW
2015/05/08 22:09:28
Done.
| |
| 27 app->ConnectToService("mojo:keyboard_native", &keyboard_); | |
| 28 keyboard_->ShowByRequest(); | |
| 29 keyboard_->Hide(); | |
| 30 | |
| 31 request_ = mojo::GetProxy(&mystery_); | |
|
jamesr
2015/05/08 20:55:15
since |request_| is only initialized on this line
APW
2015/05/08 22:09:28
Done.
| |
| 32 binding_ = new mojo::Binding<keyboard::KeyboardClient>(this, | |
|
jamesr
2015/05/08 20:55:16
there's no need to heap allocate |binding_|. you c
APW
2015/05/08 22:09:28
Done.
| |
| 33 request_.Pass()); | |
| 34 | |
| 35 keyboard_->Show(mystery_.Pass()); | |
| 36 } | |
| 37 | |
| 38 void CommitCompletion(keyboard::CompletionDataPtr completion) override { | |
| 39 } | |
| 40 | |
| 41 void CommitCorrection(keyboard::CorrectionDataPtr correction) override { | |
| 42 } | |
| 43 | |
| 44 void CommitText(const mojo::String& text, int32_t newCursorPosition) | |
| 45 override { | |
| 46 } | |
| 47 | |
| 48 void DeleteSurroundingText(int32_t beforeLength, int32_t afterLength) | |
| 49 override { | |
| 50 } | |
| 51 | |
| 52 void SetComposingRegion(int32_t start, int32_t end) override { | |
| 53 } | |
| 54 | |
| 55 void SetComposingText(const mojo::String& text, int32_t newCursorPosition) | |
| 56 override { | |
| 57 } | |
| 58 | |
| 59 void SetSelection(int32_t start, int32_t end) override { | |
| 60 } | |
| 61 | |
| 62 private: | |
| 63 keyboard::KeyboardServicePtr keyboard_; | |
| 64 keyboard::KeyboardClientPtr keyboardClient_; | |
| 65 }; | |
| 66 | |
| 67 } // namespace examples | |
| 68 } // namespace mojo | |
| 69 | |
| 70 MojoResult MojoMain(MojoHandle application_request) { | |
| 71 mojo::ApplicationRunner runner(new mojo::examples::KeyboardDelegate); | |
| 72 return runner.Run(application_request); | |
| 73 } | |
| OLD | NEW |