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

Side by Side Diff: blimp/client/feature/ime_feature.h

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 #ifndef BLIMP_CLIENT_FEATURE_IME_FEATURE_H_
6 #define BLIMP_CLIENT_FEATURE_IME_FEATURE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/macros.h"
12 #include "blimp/client/blimp_client_export.h"
13 #include "blimp/net/blimp_message_processor.h"
14 #include "ui/base/ime/text_input_type.h"
15
16 namespace blimp {
17 namespace client {
18
19 // Handles all incoming and outgoing protobuf messages for text input of type
20 // BlimpMessage::IME.
21 // Upon receiving a text input request from the engine, the ImeFeature caches
22 // the |tab_id_| and |render_widget_id_| for the request and
23 // delegates the request to ImeFeatureDelegate which then opens up the IME.
24 // After user is done typing, the text is passed back to ImeFeature, which then
25 // sends the text to the engine over network along with the same |tab_id_| and
26 // |render_widget_id_|.
Wez 2016/03/18 20:51:28 nit: What happens if the Engine sends a new reques
27 class BLIMP_CLIENT_EXPORT ImeFeature : public BlimpMessageProcessor {
Wez 2016/03/18 20:51:28 This should be ImeClientFeature, since there will
shaktisahu 2016/03/22 19:44:19 Hmm, not sure if this sounds good. By the way, on
28 public:
29 // A delegate to be notified of text input events.
Wez 2016/03/18 20:51:28 nit: I think you mean "text input requests"?
shaktisahu 2016/03/22 19:44:19 Done.
30 class ImeFeatureDelegate {
31 public:
32 virtual void OnShowImeRequested(ui::TextInputType input_type,
33 const std::string& text) = 0;
34 virtual void OnHideImeRequested() = 0;
35 };
36
37 ImeFeature();
38 ~ImeFeature() override;
39
40 // Set the BlimpMessageProcessor that will be used to send BlimpMessage::IME
41 // messages to the engine.
42 void set_outgoing_message_processor(
43 scoped_ptr<BlimpMessageProcessor> processor);
44
45 // Sets a ImeFeatureDelegate to be notified of all text input messages.
46 void SetDelegate(ImeFeatureDelegate* delegate);
Wez 2016/03/18 20:51:28 Could/should this be a constructor parameter? nit
shaktisahu 2016/03/22 19:44:20 Can't be a constructor param since ImeFeature outl
Wez 2016/03/22 21:43:38 IIUC you're saying it's valid to pass a NULL |dele
47
48 // Sends text from IME to the blimp engine.
49 void SendImeTextToEngine(const std::string& text);
Wez 2016/03/18 20:51:28 This class doesn't really have a concept of the "E
shaktisahu 2016/03/22 19:44:19 Done.
50
51 private:
52 // BlimpMessageProcessor implementation.
53 void ProcessMessage(scoped_ptr<BlimpMessage> message,
54 const net::CompletionCallback& callback) override;
55
56 ImeFeatureDelegate* delegate_;
Wez 2016/03/18 20:51:28 nit: You can in-line initialize this to nullptr.
shaktisahu 2016/03/22 19:44:19 Done.
Wez 2016/03/22 21:43:37 Doesn't look done!
57
58 // Tab id and render widget id for the input field for which user input is
59 // being requested.
60 // The values are cached from the ImeMessage::SHOW_IME message and sent back
61 // to engine in ImeMessage::SET_TEXT message.
62 // The cached values are not cleared, since they are overwritten with the new
63 // value at the beginning of every text input request.
64 int tab_id_;
65 int render_widget_id_;
Wez 2016/03/18 20:51:28 nit: Similarly, suggest inline initializing these
shaktisahu 2016/03/22 19:44:20 Done.
66
67 // Used to send BlimpMessage::IME messages to the engine.
68 scoped_ptr<BlimpMessageProcessor> outgoing_message_processor_;
69
70 DISALLOW_COPY_AND_ASSIGN(ImeFeature);
71 };
72
73 } // namespace client
74 } // namespace blimp
75
76 #endif // BLIMP_CLIENT_FEATURE_IME_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698