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

Unified 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: Addressed comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « examples/keyboard_client/BUILD.gn ('k') | services/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/keyboard_client/keyboard_client.cc
diff --git a/examples/keyboard_client/keyboard_client.cc b/examples/keyboard_client/keyboard_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5496138a547e1ce2b04cd430adb66b7824b80bbd
--- /dev/null
+++ b/examples/keyboard_client/keyboard_client.cc
@@ -0,0 +1,62 @@
+// 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 "base/macros.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/application/application_impl.h"
+#include "mojo/public/cpp/application/application_runner.h"
+#include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h"
+
+namespace examples {
+
+class KeyboardDelegate : public mojo::ApplicationDelegate,
+ public keyboard::KeyboardClient {
+ public:
+ KeyboardDelegate() : binding_(this) {}
+
+ ~KeyboardDelegate() override {}
+
+ // mojo::ApplicationDelegate implementation.
+ void Initialize(mojo::ApplicationImpl* app) override {
+ app->ConnectToService("mojo:keyboard_native", &keyboard_);
+ keyboard_->ShowByRequest();
+ keyboard_->Hide();
+
+ keyboard::KeyboardClientPtr keyboard_client;
+ auto request = mojo::GetProxy(&keyboard_client);
+ binding_.Bind(request.Pass());
+ keyboard_->Show(keyboard_client.Pass());
+ }
+
+ // keyboard::KeyboardClient implementation.
+ void CommitCompletion(keyboard::CompletionDataPtr completion) override {}
+
+ void CommitCorrection(keyboard::CorrectionDataPtr correction) override {}
+
+ void CommitText(const mojo::String& text,
+ int32_t new_cursor_position) override {}
+
+ void DeleteSurroundingText(int32_t before_length,
+ int32_t after_length) override {}
+
+ void SetComposingRegion(int32_t start, int32_t end) override {}
+
+ void SetComposingText(const mojo::String& text,
+ int32_t new_cursor_position) override {}
+
+ void SetSelection(int32_t start, int32_t end) override {}
+
+ private:
+ mojo::Binding<keyboard::KeyboardClient> binding_;
+ keyboard::KeyboardServicePtr keyboard_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeyboardDelegate);
+};
+
+} // namespace examples
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunner runner(new examples::KeyboardDelegate);
+ return runner.Run(application_request);
+}
« no previous file with comments | « examples/keyboard_client/BUILD.gn ('k') | services/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698