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

Unified Diff: blimp/client/feature/web_input_feature.cc

Issue 1779673003: Added network components for blimp text input feature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: blimp/client/feature/web_input_feature.cc
diff --git a/blimp/client/feature/web_input_feature.cc b/blimp/client/feature/web_input_feature.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a500f3ab66cca911c2e6e2ab00a41f0ca6cfc334
--- /dev/null
+++ b/blimp/client/feature/web_input_feature.cc
@@ -0,0 +1,67 @@
+// Copyright 2016 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 "blimp/client/feature/web_input_feature.h"
+
+#include <string>
+
+#include "blimp/common/create_blimp_message.h"
+#include "blimp/common/proto/blimp_message.pb.h"
+#include "net/base/net_errors.h"
+
+namespace blimp {
+namespace client {
+
+WebInputFeature::WebInputFeature() {}
+
+WebInputFeature::~WebInputFeature() {}
+
+void WebInputFeature::set_outgoing_message_processor(
+ scoped_ptr<BlimpMessageProcessor> processor) {
+ outgoing_message_processor_ = std::move(processor);
+}
+
+void WebInputFeature::SetDelegate(WebInputFeatureDelegate* delegate) {
+ delegate_ = delegate;
+}
+
+void WebInputFeature::SendImeTextToEngine(const std::string& text) {
+ ImeMessage* ime_message;
+ scoped_ptr<BlimpMessage> blimp_message = CreateBlimpMessage(&ime_message);
+ ime_message->set_ime_text(text);
+ ime_message->set_type(ImeMessage::SHOW_TEXT);
+
+ VLOG(0) << "Sending ime text to engine, ";
nyquist 2016/03/10 00:57:13 Should this be VLOG(1) ? Nit: 'IME' and extra spac
+ outgoing_message_processor_->ProcessMessage(std::move(blimp_message),
+ net::CompletionCallback());
+}
+
+void WebInputFeature::ProcessMessage(scoped_ptr<BlimpMessage> message,
+ const net::CompletionCallback& callback) {
+ DCHECK(!callback.is_null());
+ DCHECK(message->type() == BlimpMessage::IME);
+
+ const ImeMessage& ime_message = message->ime();
+ int input_type = ime_message.text_input_type();
+ std::string text = ime_message.ime_text();
+
+ switch (ime_message.type()) {
+ case ImeMessage::SHOW_IME:
+ delegate_->OnImeRequested(true, input_type, text);
+ break;
+ case ImeMessage::HIDE_IME:
+ delegate_->OnImeRequested(false, input_type, text);
+ break;
+ case ImeMessage::SHOW_TEXT:
+ NOTREACHED();
+ break;
+ case ImeMessage::UNKNOWN:
+ NOTREACHED();
+ }
+
+ callback.Run(net::OK);
+}
+
+} // namespace client
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698