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

Side by Side Diff: blimp/client/feature/ime_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 unit tests and addressed comments 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/ime_feature.h>
6 #include <string>
7
8 #include "blimp/common/create_blimp_message.h"
9 #include "blimp/common/proto/blimp_message.pb.h"
10 #include "blimp/net/input_message_converter.h"
11 #include "net/base/net_errors.h"
12
13 namespace blimp {
14 namespace client {
15
16 ImeFeature::ImeFeature() {}
Wez 2016/03/18 20:51:28 As noted in the header, there are POD members of t
shaktisahu 2016/03/22 19:44:19 Done.
17
18 ImeFeature::~ImeFeature() {}
19
20 void ImeFeature::set_outgoing_message_processor(
21 scoped_ptr<BlimpMessageProcessor> processor) {
22 outgoing_message_processor_ = std::move(processor);
Wez 2016/03/18 20:51:27 nit: Since this is a "simple" setter you could imp
shaktisahu 2016/03/22 19:44:19 Done.
23 }
24
25 void ImeFeature::SetDelegate(ImeFeatureDelegate* delegate) {
Wez 2016/03/18 20:51:28 Similarly, since this is a simple setter, it could
shaktisahu 2016/03/22 19:44:19 Done.
26 delegate_ = delegate;
27 }
28
29 void ImeFeature::SendImeTextToEngine(const std::string& text) {
Wez 2016/03/18 20:51:28 I'd suggest DCHECK()ing that the tab & widget Ids
shaktisahu 2016/03/22 19:44:19 Done.
30 ImeMessage* ime_message;
31 scoped_ptr<BlimpMessage> blimp_message =
32 CreateBlimpMessage(&ime_message, tab_id_);
33 ime_message->set_render_widget_id(render_widget_id_);
34 ime_message->set_type(ImeMessage::SET_TEXT);
35 ime_message->set_ime_text(text);
36
37 outgoing_message_processor_->ProcessMessage(std::move(blimp_message),
38 net::CompletionCallback());
39 }
40
41 void ImeFeature::ProcessMessage(scoped_ptr<BlimpMessage> message,
42 const net::CompletionCallback& callback) {
43 DCHECK(!callback.is_null());
44 DCHECK(message->type() == BlimpMessage::IME);
Wez 2016/03/18 20:51:27 As noted below, if the Engine sends bad data, call
shaktisahu 2016/03/22 19:44:19 Done.
Wez 2016/03/22 21:43:37 Ah, sorry; forgot that the demultiplexer should ne
shaktisahu 2016/03/22 23:45:42 Done.
shaktisahu 2016/03/22 23:45:42 Done.
45
46 DCHECK(delegate_) << "ImeFeatureDelegate not set";
Wez 2016/03/18 20:51:27 nit: The message following the DCHECK seems redund
shaktisahu 2016/03/22 19:44:19 Done.
47
48 const ImeMessage& ime_message = message->ime();
49 tab_id_ = message->target_tab_id();
50 render_widget_id_ = ime_message.render_widget_id();
Wez 2016/03/18 20:51:28 When you receive a hide request you're basically s
shaktisahu 2016/03/22 19:44:19 Done.
51
52 switch (ime_message.type()) {
53 case ImeMessage::SHOW_IME:
Wez 2016/03/18 20:51:28 Suggest adding a check that the tab & widget Ids a
shaktisahu 2016/03/22 19:44:19 Done.
Wez 2016/03/22 21:43:37 Looks like you've added a check for the sender spe
shaktisahu 2016/03/22 23:45:42 Actually, there might be a case where we might hav
54 delegate_->OnShowImeRequested(
55 InputMessageConverter::TextInputTypeFromProto(
56 ime_message.text_input_type()),
57 ime_message.ime_text());
58 break;
59 case ImeMessage::HIDE_IME:
60 delegate_->OnHideImeRequested();
Wez 2016/03/18 20:51:27 Suggesting DCHECKing that the tab & widget Ids are
shaktisahu 2016/03/22 19:44:19 Actually, tab and widget ids can be invalid here.
Wez 2016/03/22 21:43:37 So if the tab_id_ and render_widget_id_ are invali
shaktisahu 2016/03/22 23:45:42 Same as above comment. I would still prefer to mak
61 break;
62 case ImeMessage::SET_TEXT:
Wez 2016/03/18 20:51:27 nit: No need for a separate code block for this an
shaktisahu 2016/03/22 19:44:19 Done.
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