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

Side by Side Diff: blimp/client/core/contents/ime_feature.cc

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 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/core/contents/ime_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 "blimp/net/input_message_converter.h"
12 #include "net/base/net_errors.h"
13
14 namespace blimp {
15 namespace client {
16
17 ImeFeature::WebInputRequest::WebInputRequest()
18 : input_type(ui::TEXT_INPUT_TYPE_NONE) {}
19
20 ImeFeature::WebInputRequest::~WebInputRequest() = default;
21
22 ImeFeature::WebInputResponse::WebInputResponse() : submit(false) {}
23
24 ImeFeature::ImeFeature() : weak_factory_(this) {}
25
26 ImeFeature::~ImeFeature() {}
27
28 void ImeFeature::OnImeTextEntered(int tab_id,
29 int render_widget_id,
30 const WebInputResponse& response) {
31 DCHECK_LE(0, tab_id);
32 DCHECK_LT(0, render_widget_id);
33
34 ImeMessage* ime_message;
35 std::unique_ptr<BlimpMessage> blimp_message =
36 CreateBlimpMessage(&ime_message, tab_id);
37 ime_message->set_render_widget_id(render_widget_id);
38 ime_message->set_type(ImeMessage::SET_TEXT);
39 ime_message->set_ime_text(response.text);
40 ime_message->set_auto_submit(response.submit);
41
42 outgoing_message_processor_->ProcessMessage(std::move(blimp_message),
43 net::CompletionCallback());
44 }
45
46 void ImeFeature::ProcessMessage(std::unique_ptr<BlimpMessage> message,
47 const net::CompletionCallback& callback) {
48 DCHECK(!callback.is_null());
49 DCHECK_EQ(BlimpMessage::kIme, message->feature_case());
50
51 DCHECK(delegate_);
52
53 const ImeMessage& ime_message = message->ime();
54
55 switch (ime_message.type()) {
56 case ImeMessage::SHOW_IME:
57 if (!message->has_target_tab_id() || message->target_tab_id() < 0 ||
58 ime_message.render_widget_id() <= 0) {
59 callback.Run(net::ERR_INVALID_ARGUMENT);
60 return;
61 }
62 {
63 WebInputRequest request;
64 request.input_type = InputMessageConverter::TextInputTypeFromProto(
65 ime_message.text_input_type());
66 request.text = ime_message.ime_text();
67 request.show_ime_callback = base::Bind(
68 &ImeFeature::OnImeTextEntered, weak_factory_.GetWeakPtr(),
69 message->target_tab_id(), ime_message.render_widget_id());
70
71 delegate_->OnShowImeRequested(request);
72 }
73 break;
74 case ImeMessage::HIDE_IME:
75 delegate_->OnHideImeRequested();
76 break;
77 case ImeMessage::SET_TEXT:
78 case ImeMessage::UNKNOWN:
79 NOTREACHED();
80 callback.Run(net::ERR_UNEXPECTED);
81 return;
82 }
83
84 callback.Run(net::OK);
85 }
86
87 } // namespace client
88 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/ime_feature.h ('k') | blimp/client/core/contents/ime_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698