 Chromium Code Reviews
 Chromium Code Reviews Issue 1779673003:
  Added network components for blimp text input feature  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1779673003:
  Added network components for blimp text input feature  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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..7830afa5adfc234fd9c86c282c852ec80c4dcddc | 
| --- /dev/null | 
| +++ b/blimp/client/feature/web_input_feature.cc | 
| @@ -0,0 +1,73 @@ | 
| +// 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_conversions.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, tab_id_); | 
| + ime_message->set_render_widget_id(render_widget_id_); | 
| + ime_message->set_type(ImeMessage::SHOW_TEXT); | 
| + ime_message->set_ime_text(text); | 
| + | 
| + 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); | 
| + | 
| + DCHECK(delegate_ != NULL) << "WebInputFeatureDelegate not set"; | 
| 
Khushal
2016/03/17 10:02:45
nit: nullptr.
 
shaktisahu
2016/03/18 19:08:05
Done.
 | 
| + | 
| + const ImeMessage& ime_message = message->ime(); | 
| + 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
 | 
| + render_widget_id_ = ime_message.render_widget_id(); | 
| + | 
| + switch (ime_message.type()) { | 
| + case ImeMessage::SHOW_IME: | 
| + delegate_->OnShowImeRequested( | 
| + TextInputTypeFromProto(ime_message.text_input_type()), | 
| + ime_message.ime_text()); | 
| + break; | 
| + case ImeMessage::HIDE_IME: | 
| + delegate_->OnHideImeRequested(); | 
| + break; | 
| + case ImeMessage::SHOW_TEXT: | 
| + NOTREACHED(); | 
| + break; | 
| + case ImeMessage::UNKNOWN: | 
| + NOTREACHED(); | 
| + } | 
| + | 
| + callback.Run(net::OK); | 
| +} | 
| + | 
| +} // namespace client | 
| +} // namespace blimp |