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

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: Address comments 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 <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
Peter Kasting 2012/10/26 02:31:57 Nit: Remove this blank line
Seigo Nonaka 2012/10/26 02:40:27 Done.
46 // |observer| can be NULL.
Peter Kasting 2012/10/26 02:31:57 Nit: Say why this is important, e.g. does test cod
Seigo Nonaka 2012/10/26 02:40:27 Done.
47 explicit TsfEventRouter(TsfEventRouterObserver* observer);
37 virtual ~TsfEventRouter(); 48 virtual ~TsfEventRouter();
38 49
39 // Sets |manager| to be monitored and |observer| to be notified. |manager| and 50 // Sets |manager| to be monitored. |manager| can be NULL.
40 // |observer| can be NULL. 51 void SetManager(ITfThreadMgr* manager);
41 virtual void SetManager(ITfThreadMgr* manager,
42 Observer* observer) = 0;
43 52
44 // Returns true if the IME is composing texts. 53 // Returns true if the IME is composing text.
45 virtual bool IsImeComposing() = 0; 54 bool IsImeComposing();
46 55
47 // Factory function, creates a new instance which the caller owns. 56 // Called when the text contents are updated, this function is called by
48 static UI_EXPORT TsfEventRouter* Create(); 57 // |delegate_|.
Peter Kasting 2012/10/26 02:31:57 Nit: Slightly less awkward: // Called by the Ts
Seigo Nonaka 2012/10/26 02:40:27 Changed to the latter, thanks. On 2012/10/26 02:3
58 void OnTextUpdated();
49 59
50 protected: 60 // Called when the number of currently opened candidate window changes, this
51 // Create should be used instead. 61 // function is called by |delegate_|.
52 TsfEventRouter(); 62 void OnCandidateWindowCountChanged(size_t window_count);
63
64 private:
65 class TsfEventRouterDelegate;
66
67 CComPtr<TsfEventRouterDelegate> delegate_;
68
69 TsfEventRouterObserver* observer_;
53 70
54 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter); 71 DISALLOW_COPY_AND_ASSIGN(TsfEventRouter);
55 }; 72 };
56 73
57 } // namespace ui 74 } // namespace ui
58 75
59 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_ 76 #endif // UI_BASE_IME_WIN_TSF_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698