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

Side by Side Diff: content/browser/renderer_host/text_input_client_mac.h

Issue 1318483007: Implement "Look Up In Dictionary" context menu item asynchronously. (OS X) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review comments. Created 5 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 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 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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // When the renderer sends the ViewHostMsg reply, the RenderMessageFilter will 67 // When the renderer sends the ViewHostMsg reply, the RenderMessageFilter will
68 // call the corresponding method on the IO thread to unlock the condition and 68 // call the corresponding method on the IO thread to unlock the condition and
69 // allow the Get*() methods to continue/return. 69 // allow the Get*() methods to continue/return.
70 void SetCharacterIndexAndSignal(NSUInteger index); 70 void SetCharacterIndexAndSignal(NSUInteger index);
71 void SetFirstRectAndSignal(NSRect first_rect); 71 void SetFirstRectAndSignal(NSRect first_rect);
72 void SetSubstringAndSignal(NSAttributedString* string); 72 void SetSubstringAndSignal(NSAttributedString* string);
73 73
74 // This async method is invoked from RenderWidgetHostViewCocoa's 74 // This async method is invoked from RenderWidgetHostViewCocoa's
75 // -quickLookWithEvent:, when the user taps a word using 3 fingers. 75 // -quickLookWithEvent:, when the user taps a word using 3 fingers.
76 // The reply callback will be invoked from the IO thread, the caller is 76 // The reply callback will be invoked from the IO thread; the caller is
77 // responsible for bouncing to the main thread if necessary. 77 // responsible for bouncing to the main thread if necessary.
78 // The callback parameters provide the attributed word under the point and 78 // The callback parameters provide the attributed word under the point and
79 // the lower left baseline point of the text. 79 // the lower left baseline point of the text.
80 void GetStringAtPoint(RenderWidgetHost* rwh, 80 void GetStringAtPoint(RenderWidgetHost* rwh,
81 gfx::Point point, 81 gfx::Point point,
82 void (^replyHandler)(NSAttributedString*, NSPoint)); 82 void (^reply_handler)(NSAttributedString*, NSPoint));
83
83 // This is called on the IO thread when we get the renderer's reply for 84 // This is called on the IO thread when we get the renderer's reply for
84 // GetStringAtPoint. 85 // GetStringAtPoint.
85 void GetStringAtPointReply(NSAttributedString*, NSPoint); 86 void GetStringAtPointReply(NSAttributedString* string, NSPoint point);
87
88 // This async method is invoked when browser tries to retreive the text for
89 // certain range and doesn't want to wait for the reply from blink.
90 // The reply callback will be invoked from the IO thread; the caller is
91 // responsible for bouncing to the main thread if necessary.
92 // The callback parameters provide the attributed word under the point and
93 // the lower left baseline point of the text.
94 void GetStringFromRange(RenderWidgetHost* rwh,
95 NSRange range,
96 void (^reply_handler)(NSAttributedString*, NSPoint));
97
98 // This is called on the IO thread when we get the renderer's reply for
99 // GetStringFromRange.
100 void GetStringFromRangeReply(NSAttributedString* string, NSPoint point);
86 101
87 private: 102 private:
88 friend struct base::DefaultSingletonTraits<TextInputClientMac>; 103 friend struct base::DefaultSingletonTraits<TextInputClientMac>;
89 TextInputClientMac(); 104 TextInputClientMac();
90 ~TextInputClientMac(); 105 ~TextInputClientMac();
91 106
92 // The critical sections that the Condition guards are in Get*() methods. 107 // The critical sections that the Condition guards are in Get*() methods.
93 // These methods lock the internal condition for use before the asynchronous 108 // These methods lock the internal condition for use before the asynchronous
94 // message is sent to the renderer to lookup the required information. These 109 // message is sent to the renderer to lookup the required information. These
95 // are only used on the UI thread. 110 // are only used on the UI thread.
96 void BeforeRequest(); 111 void BeforeRequest();
97 // Called at the end of a critical section. This will release the lock and 112 // Called at the end of a critical section. This will release the lock and
98 // condition. 113 // condition.
99 void AfterRequest(); 114 void AfterRequest();
100 115
101 NSUInteger character_index_; 116 NSUInteger character_index_;
102 NSRect first_rect_; 117 NSRect first_rect_;
103 base::scoped_nsobject<NSAttributedString> substring_; 118 base::scoped_nsobject<NSAttributedString> substring_;
104 119
105 base::Lock lock_; 120 base::Lock lock_;
106 base::ConditionVariable condition_; 121 base::ConditionVariable condition_;
107 122
108 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)> replyHandler_; 123 // The callback when received IPC TextInputClientReplyMsg_GotStringAtPoint.
124 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)>
125 replyForPointHandler_;
126
127 // The callback when received IPC TextInputClientReplyMsg_GotStringForRange.
128 base::mac::ScopedBlock<void(^)(NSAttributedString*, NSPoint)>
129 replyForRangeHandler_;
109 130
110 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); 131 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac);
111 }; 132 };
112 133
113 } // namespace content 134 } // namespace content
114 135
115 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ 136 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698