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

Side by Side Diff: ui/base/ime/win/tsf_event_router.h

Issue 11235023: Redesign: Remove TsfEventRouter interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@ominifix
Patch Set: Use ATL for COM object management Created 8 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ 5 #ifndef UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_
6 #define UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ 6 #define UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_
7 7
8 #include <msctf.h> 8 #include <msctf.h>
9 #include <atlbase.h>
10 #include <atlcom.h>
Peter Kasting 2012/10/24 20:48:11 Nit: alphabetical order
Seigo Nonaka 2012/10/25 14:37:16 Done.
11
12 #include <set>
9 13
10 #include "base/basictypes.h" 14 #include "base/basictypes.h"
11 #include "base/callback.h" 15 #include "base/callback.h"
12 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/win/scoped_comptr.h"
13 #include "ui/base/ime/text_input_type.h" 18 #include "ui/base/ime/text_input_type.h"
14 #include "ui/base/ui_export.h" 19 #include "ui/base/ui_export.h"
15 20
16 struct ITfDocumentMgr; 21 struct ITfDocumentMgr;
17 22
18 namespace ui { 23 namespace ui {
19 24
20 // This is an abstract interface that monitors events associated with TSF and 25 // The implementation class of ITfUIElementSink, whose member functions will be
21 // forwards them to the observer. In order to manage the life cycle of this 26 // called back by TSF when the UI element status is changed, for example when
22 // object by scoped_refptr and the implementation class of this interface is COM 27 // the candidate window is opened or closed. This class also implements
23 // class anyway, this interface is derived from IUnknown. 28 // ITfTextEditSink, whose member function is called back by TSF when the text
24 class TsfEventRouter : public IUnknown { 29 // editting session is finished.
Peter Kasting 2012/10/24 20:48:11 This comment isn't correct, because TsfEventRouter
Seigo Nonaka 2012/10/25 14:37:16 Done.
30 class UI_EXPORT TsfEventRouter {
25 public: 31 public:
26 class Observer { 32 class Observer {
Peter Kasting 2012/10/24 20:48:11 Nit: Use a separate TSFEventRouterObserver class i
Seigo Nonaka 2012/10/25 14:37:16 Done.
27 public: 33 public:
28 virtual ~Observer() {} 34 virtual ~Observer() {}
Peter Kasting 2012/10/24 20:48:11 Nit: Probably should be protected since I doubt we
Seigo Nonaka 2012/10/25 14:37:16 Done.
29 35
30 // Called when the text contents are updated. 36 // Called when the text contents are updated.
31 virtual void OnTextUpdated() = 0; 37 virtual void OnTextUpdated() = 0;
32 38
33 // Called when the number of currently opened candidate windows changes. 39 // Called when the number of currently opened candidate windows changes.
34 virtual void OnCandidateWindowCountChanged(size_t window_count) = 0; 40 virtual void OnCandidateWindowCountChanged(size_t window_count) = 0;
35 }; 41 };
36 42
43 class ATL_NO_VTABLE TsfEventRouterDelegate : public ATL::CComObjectRoot,
cpu_(ooo_6.6-7.5) 2012/10/24 17:40:14 can you use CComObjectRootEx so it is clear what t
Peter Kasting 2012/10/24 20:48:11 Can this class simply be forward-declared here and
Seigo Nonaka 2012/10/25 14:37:16 Yes, we can, done. On 2012/10/24 20:48:11, Peter K
Seigo Nonaka 2012/10/25 14:37:16 Done.
44 public ITfUIElementSink,
45 public ITfTextEditSink {
46 public:
47 BEGIN_COM_MAP(TsfEventRouterDelegate)
48 COM_INTERFACE_ENTRY(ITfUIElementSink)
49 COM_INTERFACE_ENTRY(ITfTextEditSink)
50 END_COM_MAP()
51
52 TsfEventRouterDelegate();
53 ~TsfEventRouterDelegate();
54
55 // ITfTextEditSink override.
Peter Kasting 2012/10/24 20:48:11 Tiny nit: I've been trying to use this style: /
Seigo Nonaka 2012/10/25 14:37:16 Done.
56 virtual STDMETHODIMP OnEndEdit(ITfContext* context,
57 TfEditCookie read_only_cookie,
58 ITfEditRecord* edit_record) OVERRIDE;
59
60 // ITfUiElementSink overrides.
61 virtual STDMETHODIMP BeginUIElement(DWORD element_id, BOOL* is_show);
cpu_(ooo_6.6-7.5) 2012/10/24 17:48:14 if we are going to use this style over STDMETHOD(x
Peter Kasting 2012/10/24 20:48:11 Based on the chromium-dev thread about this, I thi
Seigo Nonaka 2012/10/25 14:37:16 Done.
Seigo Nonaka 2012/10/25 14:37:16 Chose STDMETHOD_(HRESULT, hoge) as Peter suggested
62 virtual STDMETHODIMP UpdateUIElement(DWORD element_id);
63 virtual STDMETHODIMP EndUIElement(DWORD element_id);
64
65 // Sets |manager| to be monitored and |observer| to be notified. |manager|
66 // and |observer| can be NULL.
67 void SetManager(ITfThreadMgr* manager, Observer* observer);
Peter Kasting 2012/10/24 20:48:11 Nit: Seems like this should be SetManagerAndObserv
Seigo Nonaka 2012/10/25 14:37:16 I removed |observer|.
68
69 // Returns true if the IME is composing texts.
Peter Kasting 2012/10/24 20:48:11 Nit: texts -> text
Seigo Nonaka 2012/10/25 14:37:16 Done.
70 bool IsImeComposing();
71
cpu_(ooo_6.6-7.5) 2012/10/24 17:40:14 I don't see any overrides of CComObjectRoot, like
Peter Kasting 2012/10/24 20:48:11 If I understand correctly, this would require that
Seigo Nonaka 2012/10/25 14:37:16 Regarding FinalConstruct/FinalRelease, I introduce
72 private:
73 // Returns true if the given |context| is in composing.
Peter Kasting 2012/10/24 20:48:11 Nit: remove "in"
Seigo Nonaka 2012/10/25 14:37:16 Done.
74 static bool IsImeComposingInternal(ITfContext* context);
75
76 // Returns true if the given |element_id| represents candidate window.
Peter Kasting 2012/10/24 20:48:11 Nit: represents -> represents the
Seigo Nonaka 2012/10/25 14:37:16 Done.
77 bool IsCandidateWindowInternal(DWORD element_id);
78
79 // Associates this class with specified |manager|.
Peter Kasting 2012/10/24 20:48:11 Nit: with -> with the. What about |observer|?
Seigo Nonaka 2012/10/25 14:37:16 Done.
80 void Associate(ITfThreadMgr* thread_manager, Observer* observer);
81
82 // Resets the association, this function is safe to call if there is no
Peter Kasting 2012/10/24 20:48:11 Nit: "association, this" -> "association. This",
Seigo Nonaka 2012/10/25 14:37:16 Done.
83 // associated thread manager.
84 void EnsureDeassociated();
85
86 Observer* observer_;
87
88 // A context associated with this class.
89 base::win::ScopedComPtr<ITfContext> context_;
90
91 // The ITfSource associated with |context_|.
92 base::win::ScopedComPtr<ITfSource> context_source_;
93
94 // The cookie for |context_source_|.
95 DWORD context_source_cookie_;
96
97 // A UiElementMgr associated with this class.
Peter Kasting 2012/10/24 20:48:11 Nit: Ui -> UI
Seigo Nonaka 2012/10/25 14:37:16 Done.
98 base::win::ScopedComPtr<ITfUIElementMgr> ui_element_manager_;
99
100 // The ITfSouce associated with |ui_element_manager_|.
101 base::win::ScopedComPtr<ITfSource> ui_source_;
102
103 // The set of currently opend candidate window ids.
Peter Kasting 2012/10/24 20:48:11 Nit: opend -> opened
Seigo Nonaka 2012/10/25 14:37:16 Done.
104 std::set<DWORD> open_candidate_window_ids_;
105
106 // The cookie for |ui_source_|.
107 DWORD ui_source_cookie_;
108
109 DISALLOW_COPY_AND_ASSIGN(TsfEventRouterDelegate);
110 };
111
112 TsfEventRouter();
37 virtual ~TsfEventRouter(); 113 virtual ~TsfEventRouter();
38 114
39 // Sets |manager| to be monitored and |observer| to be notified. |manager| and 115 // Sets |manager| to be monitored and |observer| to be notified. |manager| and
40 // |observer| can be NULL. 116 // |observer| can be NULL.
41 virtual void SetManager(ITfThreadMgr* manager, 117 void SetManager(ITfThreadMgr* manager, Observer* observer);
42 Observer* observer) = 0;
43 118
44 // Returns true if the IME is composing texts. 119 // Returns true if the IME is composing texts.
45 virtual bool IsImeComposing() = 0; 120 bool IsImeComposing();
46 121
47 // Factory function, creates a new instance which the caller owns. 122 private:
48 static UI_EXPORT TsfEventRouter* Create(); 123 CComPtr<TsfEventRouterDelegate> delegate_;
49
50 protected:
51 // Create should be used instead.
52 TsfEventRouter();
53 124
54 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); 125 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter);
55 }; 126 };
56 127
57 } // namespace ui 128 } // namespace ui
58 129
59 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ 130 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698