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 CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
12 #include "base/synchronization/condition_variable.h" | 12 #include "base/synchronization/condition_variable.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "ui/gfx/geometry/point.h" | 15 #include "ui/gfx/geometry/point.h" |
16 | 16 |
17 template <typename T> struct DefaultSingletonTraits; | 17 namespace base { |
| 18 template <typename T> |
| 19 struct DefaultSingletonTraits; |
| 20 } // namespace base |
18 | 21 |
19 namespace content { | 22 namespace content { |
20 class RenderWidgetHost; | 23 class RenderWidgetHost; |
21 | 24 |
22 // This class helps with the Mac OS X dictionary popup. For the design overview, | 25 // This class helps with the Mac OS X dictionary popup. For the design overview, |
23 // look at this document: | 26 // look at this document: |
24 // http://dev.chromium.org/developers/design-documents/system-dictionary-pop-u
p-architecture | 27 // http://dev.chromium.org/developers/design-documents/system-dictionary-pop-u
p-architecture |
25 // | 28 // |
26 // This service is used to marshall information for these three methods that are | 29 // This service is used to marshall information for these three methods that are |
27 // implemented in RenderWidgetHostViewMac: | 30 // implemented in RenderWidgetHostViewMac: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // The callback parameters provide the attributed word under the point and | 78 // The callback parameters provide the attributed word under the point and |
76 // the lower left baseline point of the text. | 79 // the lower left baseline point of the text. |
77 void GetStringAtPoint(RenderWidgetHost* rwh, | 80 void GetStringAtPoint(RenderWidgetHost* rwh, |
78 gfx::Point point, | 81 gfx::Point point, |
79 void (^replyHandler)(NSAttributedString*, NSPoint)); | 82 void (^replyHandler)(NSAttributedString*, NSPoint)); |
80 // This is called on the IO thread when we get the renderer's reply for | 83 // This is called on the IO thread when we get the renderer's reply for |
81 // GetStringAtPoint. | 84 // GetStringAtPoint. |
82 void GetStringAtPointReply(NSAttributedString*, NSPoint); | 85 void GetStringAtPointReply(NSAttributedString*, NSPoint); |
83 | 86 |
84 private: | 87 private: |
85 friend struct DefaultSingletonTraits<TextInputClientMac>; | 88 friend struct base::DefaultSingletonTraits<TextInputClientMac>; |
86 TextInputClientMac(); | 89 TextInputClientMac(); |
87 ~TextInputClientMac(); | 90 ~TextInputClientMac(); |
88 | 91 |
89 // The critical sections that the Condition guards are in Get*() methods. | 92 // The critical sections that the Condition guards are in Get*() methods. |
90 // These methods lock the internal condition for use before the asynchronous | 93 // These methods lock the internal condition for use before the asynchronous |
91 // message is sent to the renderer to lookup the required information. These | 94 // message is sent to the renderer to lookup the required information. These |
92 // are only used on the UI thread. | 95 // are only used on the UI thread. |
93 void BeforeRequest(); | 96 void BeforeRequest(); |
94 // Called at the end of a critical section. This will release the lock and | 97 // Called at the end of a critical section. This will release the lock and |
95 // condition. | 98 // condition. |
96 void AfterRequest(); | 99 void AfterRequest(); |
97 | 100 |
98 NSUInteger character_index_; | 101 NSUInteger character_index_; |
99 NSRect first_rect_; | 102 NSRect first_rect_; |
100 base::scoped_nsobject<NSAttributedString> substring_; | 103 base::scoped_nsobject<NSAttributedString> substring_; |
101 | 104 |
102 base::Lock lock_; | 105 base::Lock lock_; |
103 base::ConditionVariable condition_; | 106 base::ConditionVariable condition_; |
104 | 107 |
105 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> replyHandler_; | 108 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> replyHandler_; |
106 | 109 |
107 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); | 110 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); |
108 }; | 111 }; |
109 | 112 |
110 } // namespace content | 113 } // namespace content |
111 | 114 |
112 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ | 115 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ |
OLD | NEW |