Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <atlbase.h> | |
| 9 #include <atlcom.h> | |
| 8 #include <msctf.h> | 10 #include <msctf.h> |
| 9 | 11 |
| 12 #include <set> | |
| 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" |
| 13 #include "ui/base/ime/text_input_type.h" | 17 #include "ui/base/ime/text_input_type.h" |
| 14 #include "ui/base/ui_export.h" | 18 #include "ui/base/ui_export.h" |
| 15 | 19 |
| 16 struct ITfDocumentMgr; | 20 struct ITfDocumentMgr; |
| 17 | 21 |
| 18 namespace ui { | 22 namespace ui { |
| 19 | 23 |
| 20 // This is an abstract interface that monitors events associated with TSF and | 24 class TsfEventRouterObserver { |
| 21 // forwards them to the observer. In order to manage the life cycle of this | |
| 22 // object by scoped_refptr and the implementation class of this interface is COM | |
| 23 // class anyway, this interface is derived from IUnknown. | |
| 24 class TsfEventRouter : public IUnknown { | |
| 25 public: | 25 public: |
| 26 class Observer { | 26 TsfEventRouterObserver() {} |
| 27 public: | |
| 28 virtual ~Observer() {} | |
| 29 | 27 |
| 30 // Called when the text contents are updated. | 28 // Called when the text contents are updated. |
| 31 virtual void OnTextUpdated() = 0; | 29 virtual void OnTextUpdated() = 0; |
| 32 | 30 |
| 33 // Called when the number of currently opened candidate windows changes. | 31 // Called when the number of currently opened candidate windows changes. |
| 34 virtual void OnCandidateWindowCountChanged(size_t window_count) = 0; | 32 virtual void OnCandidateWindowCountChanged(size_t window_count) = 0; |
| 35 }; | |
| 36 | 33 |
| 34 protected: | |
| 35 virtual ~TsfEventRouterObserver() {} | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(TsfEventRouterObserver); | |
| 39 }; | |
| 40 | |
| 41 // This class monitores TSF related events and forwards them to given | |
| 42 // |observer|. | |
| 43 class UI_EXPORT TsfEventRouter { | |
| 44 public: | |
| 45 explicit TsfEventRouter(TsfEventRouterObserver* observer); | |
|
Peter Kasting
2012/10/26 01:53:47
Nit: Say whether |observer| can be NULL.
Seigo Nonaka
2012/10/26 02:23:10
Done.
| |
| 37 virtual ~TsfEventRouter(); | 46 virtual ~TsfEventRouter(); |
| 38 | 47 |
| 39 // Sets |manager| to be monitored and |observer| to be notified. |manager| and | 48 // Sets |manager| to be monitored. |manager| and can be NULL. |
|
Peter Kasting
2012/10/26 01:53:47
Nit: Remove "and"
Seigo Nonaka
2012/10/26 02:23:10
Done.
| |
| 40 // |observer| can be NULL. | 49 void SetManager(ITfThreadMgr* manager); |
| 41 virtual void SetManager(ITfThreadMgr* manager, | |
| 42 Observer* observer) = 0; | |
| 43 | 50 |
| 44 // Returns true if the IME is composing texts. | 51 // Returns true if the IME is composing texts. |
|
Peter Kasting
2012/10/26 01:53:47
Nit: texts -> text
Seigo Nonaka
2012/10/26 02:23:10
Done.
| |
| 45 virtual bool IsImeComposing() = 0; | 52 bool IsImeComposing(); |
| 46 | 53 |
| 47 // Factory function, creates a new instance which the caller owns. | 54 // Called when the text contents are updated. |
|
Peter Kasting
2012/10/26 01:53:47
Nit: Called by whom? (2 places)
Seigo Nonaka
2012/10/26 02:23:10
Done.
| |
| 48 static UI_EXPORT TsfEventRouter* Create(); | 55 void OnTextUpdated(); |
| 49 | 56 |
| 50 protected: | 57 // Called when the number of currently opend candidate window changes. |
|
Peter Kasting
2012/10/26 01:53:47
Nit: opend -> opened
Seigo Nonaka
2012/10/26 02:23:10
Done.
| |
| 51 // Create should be used instead. | 58 void OnCandidateWindowCountChanged(size_t window_count); |
| 52 TsfEventRouter(); | 59 |
| 60 private: | |
| 61 class TsfEventRouterDelegate; | |
| 62 | |
| 63 CComObject<TsfEventRouterDelegate>* delegate_; | |
|
Peter Kasting
2012/10/26 01:53:47
This should use CComPtr like you used to, not CCom
Seigo Nonaka
2012/10/26 02:23:10
Sure, done.
On 2012/10/26 01:53:47, Peter Kasting
| |
| 64 | |
| 65 TsfEventRouterObserver* observer_; | |
| 53 | 66 |
| 54 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); | 67 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); |
| 55 }; | 68 }; |
| 56 | 69 |
| 57 } // namespace ui | 70 } // namespace ui |
| 58 | 71 |
| 59 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ | 72 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ |
| OLD | NEW |