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

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: Added proto coverters for TextInputType 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_conversions.h"
11 #include "blimp/common/proto/blimp_message.pb.h"
12 #include "net/base/net_errors.h"
13
14 namespace blimp {
15 namespace client {
16
17 WebInputFeature::WebInputFeature() {}
18
19 WebInputFeature::~WebInputFeature() {}
20
21 void WebInputFeature::set_outgoing_message_processor(
22 scoped_ptr<BlimpMessageProcessor> processor) {
23 outgoing_message_processor_ = std::move(processor);
24 }
25
26 void WebInputFeature::SetDelegate(WebInputFeatureDelegate* delegate) {
27 delegate_ = delegate;
28 }
29
30 void WebInputFeature::SendImeTextToEngine(const std::string& text) {
31 ImeMessage* ime_message;
32 scoped_ptr<BlimpMessage> blimp_message =
33 CreateBlimpMessage(&ime_message, tab_id_);
34 ime_message->set_render_widget_id(render_widget_id_);
35 ime_message->set_type(ImeMessage::SHOW_TEXT);
36 ime_message->set_ime_text(text);
37
38 outgoing_message_processor_->ProcessMessage(std::move(blimp_message),
39 net::CompletionCallback());
40 }
41
42 void WebInputFeature::ProcessMessage(scoped_ptr<BlimpMessage> message,
43 const net::CompletionCallback& callback) {
44 DCHECK(!callback.is_null());
45 DCHECK(message->type() == BlimpMessage::IME);
46
47 DCHECK(delegate_ != NULL) << "WebInputFeatureDelegate not set";
Khushal 2016/03/17 10:02:45 nit: nullptr.
shaktisahu 2016/03/18 19:08:05 Done.
48
49 const ImeMessage& ime_message = message->ime();
50 tab_id_ = message->target_tab_id();
David Trainor- moved to gerrit 2016/03/17 21:53:29 Should we ever clear these? If so, what's the con
51 render_widget_id_ = ime_message.render_widget_id();
52
53 switch (ime_message.type()) {
54 case ImeMessage::SHOW_IME:
55 delegate_->OnShowImeRequested(
56 TextInputTypeFromProto(ime_message.text_input_type()),
57 ime_message.ime_text());
58 break;
59 case ImeMessage::HIDE_IME:
60 delegate_->OnHideImeRequested();
61 break;
62 case ImeMessage::SHOW_TEXT:
63 NOTREACHED();
64 break;
65 case ImeMessage::UNKNOWN:
66 NOTREACHED();
67 }
68
69 callback.Run(net::OK);
70 }
71
72 } // namespace client
73 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698