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

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: 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
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..b210904ab5e7ec544855f76ab8378dde28e247f8
--- /dev/null
+++ b/examples/keyboard_client/keyboard_client.cc
@@ -0,0 +1,73 @@
+// 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 <stdio.h>
jamesr 2015/05/08 20:55:15 don't think you are using this
APW 2015/05/08 22:09:28 Done.
+
+#include "base/logging.h"
+#include "mojo/public/c/system/main.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/public/cpp/utility/run_loop.h"
+#include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h"
+
+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.
+namespace examples {
+
+class KeyboardDelegate : public ApplicationDelegate,
+ 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.
+ public:
+
+ 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.
+ mojo::InterfaceRequest<keyboard::KeyboardClient> request_;
+ mojo::Binding<keyboard::KeyboardClient>* binding_;
+
+ 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.
+ app->ConnectToService("mojo:keyboard_native", &keyboard_);
+ keyboard_->ShowByRequest();
+ keyboard_->Hide();
+
+ 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.
+ 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.
+ request_.Pass());
+
+ keyboard_->Show(mystery_.Pass());
+ }
+
+ void CommitCompletion(keyboard::CompletionDataPtr completion) override {
+ }
+
+ void CommitCorrection(keyboard::CorrectionDataPtr correction) override {
+ }
+
+ void CommitText(const mojo::String& text, int32_t newCursorPosition)
+ override {
+ }
+
+ void DeleteSurroundingText(int32_t beforeLength, int32_t afterLength)
+ override {
+ }
+
+ void SetComposingRegion(int32_t start, int32_t end) override {
+ }
+
+ void SetComposingText(const mojo::String& text, int32_t newCursorPosition)
+ override {
+ }
+
+ void SetSelection(int32_t start, int32_t end) override {
+ }
+
+ private:
+ keyboard::KeyboardServicePtr keyboard_;
+ keyboard::KeyboardClientPtr keyboardClient_;
+};
+
+} // namespace examples
+} // namespace mojo
+
+MojoResult MojoMain(MojoHandle application_request) {
+ mojo::ApplicationRunner runner(new mojo::examples::KeyboardDelegate);
+ return runner.Run(application_request);
+}

Powered by Google App Engine
This is Rietveld 408576698