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

Side by Side Diff: content/browser/renderer_host/text_input_manager.h

Issue 1948343002: [reland] Browser Side Text Input State Tracking for OOPIF (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing kenrb@ Comments Created 4 years, 7 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 CONTENT_BROWSER_TEXT_INPUT_MANAGER_H__
Charlie Reis 2016/05/18 20:46:04 nit: Missing RENDERER_HOST
EhsanK 2016/05/24 20:42:46 Uh yes...I moved this file around a lot. Sorry. :)
6 #define CONTENT_BROWSER_TEXT_INPUT_MANAGER_H__
7
8 #include <unordered_map>
9
10 #include "base/observer_list.h"
11 #include "content/browser/renderer_host/render_widget_host_view_base_observer.h"
12 #include "content/common/content_export.h"
13 #include "content/common/text_input_state.h"
14
15 namespace content {
16
17 class RenderWidgetHostViewBase;
18 class TestTextInputManagerObserver;
Charlie Reis 2016/05/18 20:46:04 This shouldn't be needed.
EhsanK 2016/05/24 20:42:45 Done.
19
20 // A class which receives updates of Text Input State from multiple sources and
Charlie Reis 2016/05/18 20:46:04 nit: Remove extra space. Also, let's be consistent
EhsanK 2016/05/24 20:42:45 Acknowledged. I think to be consistent I should ha
21 // decides what the new text input state is. It also notifies the observers when
22 // text input state is updated.
23 class CONTENT_EXPORT TextInputManager
24 : public RenderWidgetHostViewBaseObserver {
Charlie Reis 2016/05/18 20:46:04 It's a bit unfortunate that these two classes need
EhsanK 2016/05/24 20:42:45 I was worried about the observing loop to become c
Charlie Reis 2016/05/26 06:22:03 Thanks-- it's much easier to follow with the obser
25 public:
26 // The top-level tab RWHV should be an observer of TextInputManager to get
Charlie Reis 2016/05/18 20:46:04 nit: The tab's top-level RWHV
EhsanK 2016/05/24 20:42:45 Done.
27 // notifications about changes in TextInputState or other IME related state
28 // for child frames.
29 class CONTENT_EXPORT Observer {
30 public:
31 // Called when the TextInputState for |view| has changed from its previous
32 // value. The change is determined on each platform differently by only
33 // considering the change in the value of a subset of fields in the
34 // TextInputState.
35 virtual void OnTextInputStateUpdated(TextInputManager* text_input_manager,
Charlie Reis 2016/05/18 20:46:04 I'm curious why the |text_input_manager| parameter
EhsanK 2016/05/24 20:42:45 Yes that is all we do for now. The only possible c
Charlie Reis 2016/05/26 06:22:03 I think that only matters when you listen to more
36 RenderWidgetHostViewBase* view) {}
37
38 // Called when a view has called UpdateTextInputState on TextInputManager,
39 // regardless the call having lead to change in TextInputState. In some
Charlie Reis 2016/05/18 20:46:04 nit: regardless of whether the call led to
EhsanK 2016/05/24 20:42:45 Done.
40 // platforms this is necessary as it gives the tab-level |view| the chance
41 // do some other task, e.g., show IME if needed in Aura.
42 virtual void OnTextInputStateUpdateCalled(
Charlie Reis 2016/05/18 20:46:04 Why do we need both this and OnTextInputStateUpdat
EhsanK 2016/05/24 20:42:45 Hmm. I think I took the less efficient solution to
Charlie Reis 2016/05/26 06:22:03 I wouldn't worry about it unless there's a substan
43 TextInputManager* text_input_manager) {}
44
45 // Notifies all the observers that |text_input_manager| is being destroyed.
Charlie Reis 2016/05/18 20:46:04 Let's be consistent with how the other observer me
EhsanK 2016/05/24 20:42:45 Acknowledged.
46 // TODO(ekaramad): All RWHV should get this call, but only the top-level
47 // RWHV for the outermost WebContents should be called on the other observer
48 // methods. We should separate the two classes of observers when resolving
49 // crbug.com/609846.
50 virtual void OnDestroyingTextInputManager(
51 TextInputManager* text_input_manager) {}
52 };
53
54 explicit TextInputManager();
Charlie Reis 2016/05/18 20:46:04 No need for explicit unless you have a single para
EhsanK 2016/05/24 20:42:46 On 2016/05/18 20:46:04, Charlie Reis (slow to repl
55 ~TextInputManager() override;
56
57 // Returns the current text input state corresponding to |active_source_|.
Charlie Reis 2016/05/18 20:46:04 nit: TextInputState (here and below) nit: s/|activ
EhsanK 2016/05/24 20:42:45 Done.
58 // Users of this method should not hold on to the pointer as it might become
59 // dangling if the TextInputManager or |active_view_| might go away.
60 const TextInputState* GetTextInputState();
61
62 // Returns the currently active view. The active view is the last
63 // RenderWidgetHostViewBase which reported a |TextInputState.type| of other
64 // than ui::TEXT_INPUT_TYPE_NONE.
65 RenderWidgetHostViewBase* GetActiveView() const;
Charlie Reis 2016/05/18 20:46:04 Can this ever be null? Looks like active_view_ is
EhsanK 2016/05/24 20:42:45 It is nullptr initially, and whenever we lose focu
66
67 // Updates the text input state for |view|.
68 void UpdateTextInputState(RenderWidgetHostViewBase* view,
69 const TextInputState& state);
70
71 // Registers the given |view| for tracking its TextInputState.
72 // TextInputManager will observe the lifetime of the |view|.
73 void Register(RenderWidgetHostViewBase* view);
74
75 // Clear text input state of |view| and removes TextInputManager from its
76 // observer list. It is important to call this for any RWHV being tracked
77 // before destruction of RWHV or TextInputManager.
Charlie Reis 2016/05/18 20:46:04 "or TextInputManager" -> Should we add a DCHECK th
EhsanK 2016/05/24 20:42:45 It depends whether we want the un-registering to h
Charlie Reis 2016/05/26 06:22:03 Acknowledged.
78 void Unregister(RenderWidgetHostViewBase* view);
79
80 // Returns true if |view| is already registered.
81 bool IsRegisteredView(RenderWidgetHostViewBase* view) const;
Charlie Reis 2016/05/18 20:46:04 nit: IsRegistered (to be consistent with Register
EhsanK 2016/05/24 20:42:45 Done.
82
83 void AddObserver(Observer* observer);
84 void RemoveObserver(Observer* observer);
85
86 private:
87 friend class TestTextInputManagerObserver;
88
89 // RenderWidgetHostViewObserver implementation.
Charlie Reis 2016/05/18 20:46:04 nit: Missing "Base" from name.
EhsanK 2016/05/24 20:42:45 Yes sorry. But I removed this method following the
90 void OnRenderWidgetHostViewBaseDestroyed(
91 RenderWidgetHostViewBase* view) override;
92
93 void NotifyObserversAboutInputStateUpdate(RenderWidgetHostViewBase* view,
94 bool state_changed);
95
96 // The view with active text input state.
97 RenderWidgetHostViewBase* active_view_;
98
99 std::unordered_map<RenderWidgetHostViewBase*, TextInputState>
100 text_input_state_map_;
101
102 base::ObserverList<Observer> observer_list_;
103
104 DISALLOW_COPY_AND_ASSIGN(TextInputManager);
105 };
106 }
107
108 #endif // CONTENT_BROWSER_TEXT_INPUT_MANAGER_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698