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

Side by Side Diff: examples/keyboard_client/keyboard_client.cc

Issue 1139453002: Initial native keyboard proof of concept. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Linkage fixes. Created 5 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
OLDNEW
(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 mojo::InterfaceRequest<keyboard::KeyboardClient> request =
28 mojo::GetProxy(&keyboard_client);
jamesr 2015/05/11 17:50:56 two tips (you don't have to change the code but FY
29 binding_.Bind(request.Pass());
30 keyboard_->Show(keyboard_client.Pass());
31 }
32
33 // keyboard::KeyboardClient implementation.
34 void CommitCompletion(keyboard::CompletionDataPtr completion) override {}
35
36 void CommitCorrection(keyboard::CorrectionDataPtr correction) override {}
37
38 void CommitText(const mojo::String& text,
39 int32_t new_cursor_position) override {}
40
41 void DeleteSurroundingText(int32_t before_length,
42 int32_t after_length) override {}
43
44 void SetComposingRegion(int32_t start, int32_t end) override {}
45
46 void SetComposingText(const mojo::String& text,
47 int32_t new_cursor_position) override {}
48
49 void SetSelection(int32_t start, int32_t end) override {}
50
51 private:
52 mojo::Binding<keyboard::KeyboardClient> binding_;
53 keyboard::KeyboardServicePtr keyboard_;
54
55 DISALLOW_COPY_AND_ASSIGN(KeyboardDelegate);
56 };
57
58 } // namespace examples
59
60 MojoResult MojoMain(MojoHandle application_request) {
61 mojo::ApplicationRunner runner(new examples::KeyboardDelegate);
62 return runner.Run(application_request);
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698