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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "blimp/client/feature/web_input_feature.h"
6
7 #include <string>
8
9 #include "blimp/common/create_blimp_message.h"
10 #include "blimp/common/proto/blimp_message.pb.h"
11 #include "net/base/net_errors.h"
12
13 namespace blimp {
14 namespace client {
15
16 WebInputFeature::WebInputFeature() {}
17
18 WebInputFeature::~WebInputFeature() {}
19
20 void WebInputFeature::set_outgoing_message_processor(
21 scoped_ptr<BlimpMessageProcessor> processor) {
22 outgoing_message_processor_ = std::move(processor);
23 }
24
25 void WebInputFeature::SetDelegate(WebInputFeatureDelegate* delegate) {
26 delegate_ = delegate;
27 }
28
29 void WebInputFeature::SendImeTextToEngine(const std::string& text) {
30 ImeMessage* ime_message;
31 scoped_ptr<BlimpMessage> blimp_message = CreateBlimpMessage(&ime_message);
32 ime_message->set_ime_text(text);
33 ime_message->set_type(ImeMessage::SHOW_TEXT);
34
35 VLOG(0) << "Sending ime text to engine, ";
nyquist 2016/03/10 00:57:13 Should this be VLOG(1) ? Nit: 'IME' and extra spac
36 outgoing_message_processor_->ProcessMessage(std::move(blimp_message),
37 net::CompletionCallback());
38 }
39
40 void WebInputFeature::ProcessMessage(scoped_ptr<BlimpMessage> message,
41 const net::CompletionCallback& callback) {
42 DCHECK(!callback.is_null());
43 DCHECK(message->type() == BlimpMessage::IME);
44
45 const ImeMessage& ime_message = message->ime();
46 int input_type = ime_message.text_input_type();
47 std::string text = ime_message.ime_text();
48
49 switch (ime_message.type()) {
50 case ImeMessage::SHOW_IME:
51 delegate_->OnImeRequested(true, input_type, text);
52 break;
53 case ImeMessage::HIDE_IME:
54 delegate_->OnImeRequested(false, input_type, text);
55 break;
56 case ImeMessage::SHOW_TEXT:
57 NOTREACHED();
58 break;
59 case ImeMessage::UNKNOWN:
60 NOTREACHED();
61 }
62
63 callback.Run(net::OK);
64 }
65
66 } // namespace client
67 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698