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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/base/ime/win/tsf_event_router.h
diff --git a/ui/base/ime/win/tsf_event_router.h b/ui/base/ime/win/tsf_event_router.h
index 39bb6dd2d54f7bde5d76dc93c2b661775907f6e9..9c2c62bf3254933dfbd690189b8eb48def6a6393 100644
--- a/ui/base/ime/win/tsf_event_router.h
+++ b/ui/base/ime/win/tsf_event_router.h
@@ -6,10 +6,15 @@
#define UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_
#include <msctf.h>
+#include <atlbase.h>
+#include <atlcom.h>
Peter Kasting 2012/10/24 20:48:11 Nit: alphabetical order
Seigo Nonaka 2012/10/25 14:37:16 Done.
+
+#include <set>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/win/scoped_comptr.h"
#include "ui/base/ime/text_input_type.h"
#include "ui/base/ui_export.h"
@@ -17,11 +22,12 @@ struct ITfDocumentMgr;
namespace ui {
-// This is an abstract interface that monitors events associated with TSF and
-// forwards them to the observer. In order to manage the life cycle of this
-// object by scoped_refptr and the implementation class of this interface is COM
-// class anyway, this interface is derived from IUnknown.
-class TsfEventRouter : public IUnknown {
+// The implementation class of ITfUIElementSink, whose member functions will be
+// called back by TSF when the UI element status is changed, for example when
+// the candidate window is opened or closed. This class also implements
+// ITfTextEditSink, whose member function is called back by TSF when the text
+// 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.
+class UI_EXPORT TsfEventRouter {
public:
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.
public:
@@ -34,22 +40,87 @@ class TsfEventRouter : public IUnknown {
virtual void OnCandidateWindowCountChanged(size_t window_count) = 0;
};
+ 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.
+ public ITfUIElementSink,
+ public ITfTextEditSink {
+ public:
+ BEGIN_COM_MAP(TsfEventRouterDelegate)
+ COM_INTERFACE_ENTRY(ITfUIElementSink)
+ COM_INTERFACE_ENTRY(ITfTextEditSink)
+ END_COM_MAP()
+
+ TsfEventRouterDelegate();
+ ~TsfEventRouterDelegate();
+
+ // 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.
+ virtual STDMETHODIMP OnEndEdit(ITfContext* context,
+ TfEditCookie read_only_cookie,
+ ITfEditRecord* edit_record) OVERRIDE;
+
+ // ITfUiElementSink overrides.
+ 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
+ virtual STDMETHODIMP UpdateUIElement(DWORD element_id);
+ virtual STDMETHODIMP EndUIElement(DWORD element_id);
+
+ // Sets |manager| to be monitored and |observer| to be notified. |manager|
+ // and |observer| can be NULL.
+ 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|.
+
+ // 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.
+ bool IsImeComposing();
+
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
+ private:
+ // 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.
+ static bool IsImeComposingInternal(ITfContext* context);
+
+ // 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.
+ bool IsCandidateWindowInternal(DWORD element_id);
+
+ // 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.
+ void Associate(ITfThreadMgr* thread_manager, Observer* observer);
+
+ // 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.
+ // associated thread manager.
+ void EnsureDeassociated();
+
+ Observer* observer_;
+
+ // A context associated with this class.
+ base::win::ScopedComPtr<ITfContext> context_;
+
+ // The ITfSource associated with |context_|.
+ base::win::ScopedComPtr<ITfSource> context_source_;
+
+ // The cookie for |context_source_|.
+ DWORD context_source_cookie_;
+
+ // 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.
+ base::win::ScopedComPtr<ITfUIElementMgr> ui_element_manager_;
+
+ // The ITfSouce associated with |ui_element_manager_|.
+ base::win::ScopedComPtr<ITfSource> ui_source_;
+
+ // 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.
+ std::set<DWORD> open_candidate_window_ids_;
+
+ // The cookie for |ui_source_|.
+ DWORD ui_source_cookie_;
+
+ DISALLOW_COPY_AND_ASSIGN(TsfEventRouterDelegate);
+ };
+
+ TsfEventRouter();
virtual ~TsfEventRouter();
// Sets |manager| to be monitored and |observer| to be notified. |manager| and
// |observer| can be NULL.
- virtual void SetManager(ITfThreadMgr* manager,
- Observer* observer) = 0;
+ void SetManager(ITfThreadMgr* manager, Observer* observer);
// Returns true if the IME is composing texts.
- virtual bool IsImeComposing() = 0;
-
- // Factory function, creates a new instance which the caller owns.
- static UI_EXPORT TsfEventRouter* Create();
+ bool IsImeComposing();
- protected:
- // Create should be used instead.
- TsfEventRouter();
+ private:
+ CComPtr<TsfEventRouterDelegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(TsfEventRouter);
};

Powered by Google App Engine
This is Rietveld 408576698