| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BLIMP_CLIENT_FEATURE_IME_FEATURE_H_ | 5 #ifndef BLIMP_CLIENT_FEATURE_IME_FEATURE_H_ |
| 6 #define BLIMP_CLIENT_FEATURE_IME_FEATURE_H_ | 6 #define BLIMP_CLIENT_FEATURE_IME_FEATURE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 ~ImeFeature() override; | 43 ~ImeFeature() override; |
| 44 | 44 |
| 45 // Set the BlimpMessageProcessor that will be used to send BlimpMessage::IME | 45 // Set the BlimpMessageProcessor that will be used to send BlimpMessage::IME |
| 46 // messages to the engine. | 46 // messages to the engine. |
| 47 void set_outgoing_message_processor( | 47 void set_outgoing_message_processor( |
| 48 std::unique_ptr<BlimpMessageProcessor> processor) { | 48 std::unique_ptr<BlimpMessageProcessor> processor) { |
| 49 outgoing_message_processor_ = std::move(processor); | 49 outgoing_message_processor_ = std::move(processor); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Sets a Delegate to be notified of all text input messages. | 52 // Sets a Delegate to be notified of all text input messages. |
| 53 // Passing a null |delegate| causes IME messages to be ignored. | 53 // There must be a valid non-null Delegate set before routing messages |
| 54 // to the ImeFeature for processing, until the last message is processed. |
| 54 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 55 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
| 55 | 56 |
| 56 // Sends text from IME to the blimp engine. | 57 // Sends text from IME to the blimp engine. |
| 57 void OnImeTextEntered(const std::string& text); | 58 void OnImeTextEntered(const std::string& text); |
| 58 | 59 |
| 59 private: | |
| 60 // BlimpMessageProcessor implementation. | 60 // BlimpMessageProcessor implementation. |
| 61 void ProcessMessage(std::unique_ptr<BlimpMessage> message, | 61 void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| 62 const net::CompletionCallback& callback) override; | 62 const net::CompletionCallback& callback) override; |
| 63 | 63 |
| 64 // Delegate for processing the text input related messages. |delegate_| must | 64 private: |
| 65 // remain valid until the last message has been passed to ImeFeature. | 65 // Used to actually show or hide the IME. See notes on |set_delegate|. |
| 66 Delegate* delegate_ = nullptr; | 66 Delegate* delegate_ = nullptr; |
| 67 | 67 |
| 68 // Tab id and render widget id for the input field for which user input is | 68 // Tab id and render widget id for the input field for which user input is |
| 69 // being requested. | 69 // being requested. |
| 70 // The values are cached from the ImeMessage::SHOW_IME message and sent back | 70 // The values are cached from the ImeMessage::SHOW_IME message and sent back |
| 71 // to engine in the subsequent ImeMessage::SET_TEXT message. | 71 // to engine in the subsequent ImeMessage::SET_TEXT message. |
| 72 // The cached values are cleared on receiving ImeMessage::HIDE_IME request. | 72 // The cached values are cleared on receiving ImeMessage::HIDE_IME request. |
| 73 int tab_id_ = -1; | 73 int tab_id_ = -1; |
| 74 int render_widget_id_ = 0; | 74 int render_widget_id_ = 0; |
| 75 | 75 |
| 76 // Used to send BlimpMessage::IME messages to the engine. | 76 // Used to send BlimpMessage::IME messages to the engine. |
| 77 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; | 77 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(ImeFeature); | 79 DISALLOW_COPY_AND_ASSIGN(ImeFeature); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace client | 82 } // namespace client |
| 83 } // namespace blimp | 83 } // namespace blimp |
| 84 | 84 |
| 85 #endif // BLIMP_CLIENT_FEATURE_IME_FEATURE_H_ | 85 #endif // BLIMP_CLIENT_FEATURE_IME_FEATURE_H_ |
| OLD | NEW |