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

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

Issue 11343017: Move remaining files in content\browser\renderer_host to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac 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 | Annotate | Revision Log
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/memory/scoped_nsobject.h" 10 #include "base/memory/scoped_nsobject.h"
11 #include "base/synchronization/condition_variable.h" 11 #include "base/synchronization/condition_variable.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "ui/gfx/point.h" 14 #include "ui/gfx/point.h"
15 15
16 template <typename T> struct DefaultSingletonTraits; 16 template <typename T> struct DefaultSingletonTraits;
17 17
18 namespace content { 18 namespace content {
19 class RenderWidgetHost; 19 class RenderWidgetHost;
20 }
21 20
22 // This class helps with the Mac OS X dictionary popup. For the design overview, 21 // This class helps with the Mac OS X dictionary popup. For the design overview,
23 // look at this document: 22 // look at this document:
24 // http://dev.chromium.org/developers/design-documents/system-dictionary-pop-u p-architecture 23 // http://dev.chromium.org/developers/design-documents/system-dictionary-pop-u p-architecture
25 // 24 //
26 // This service is used to marshall information for these three methods that are 25 // This service is used to marshall information for these three methods that are
27 // implemented in RenderWidgetHostViewMac: 26 // implemented in RenderWidgetHostViewMac:
28 // -[NSTextInput characterIndexForPoint:] 27 // -[NSTextInput characterIndexForPoint:]
29 // -[NSTextInput attributedSubstringFromRange:] 28 // -[NSTextInput attributedSubstringFromRange:]
30 // -[NSTextInput firstRectForCharacterRange:] 29 // -[NSTextInput firstRectForCharacterRange:]
31 // 30 //
32 // Because these methods are part of a synchronous system API, implementing them 31 // Because these methods are part of a synchronous system API, implementing them
33 // requires getting information from the renderer synchronously. Rather than 32 // requires getting information from the renderer synchronously. Rather than
34 // using an actual sync IPC message, a normal async ViewMsg is used with a lock 33 // using an actual sync IPC message, a normal async ViewMsg is used with a lock
35 // and condition (managed by this service). 34 // and condition (managed by this service).
36 class CONTENT_EXPORT TextInputClientMac { 35 class CONTENT_EXPORT TextInputClientMac {
37 public: 36 public:
38 // Returns the singleton instance. 37 // Returns the singleton instance.
39 static TextInputClientMac* GetInstance(); 38 static TextInputClientMac* GetInstance();
40 39
41 // Each of the three methods mentioned above has an associated pair of methods 40 // Each of the three methods mentioned above has an associated pair of methods
42 // to get data from the renderer. The Get*() methods block the calling thread 41 // to get data from the renderer. The Get*() methods block the calling thread
43 // (always the UI thread) with a short timeout after the async message has 42 // (always the UI thread) with a short timeout after the async message has
44 // been sent to the renderer to lookup the information needed to respond to 43 // been sent to the renderer to lookup the information needed to respond to
45 // the system. The Set*AndSignal() methods store the looked up information in 44 // the system. The Set*AndSignal() methods store the looked up information in
46 // this service and signal the condition to allow the Get*() methods to 45 // this service and signal the condition to allow the Get*() methods to
47 // unlock and return that stored value. 46 // unlock and return that stored value.
48 // 47 //
49 // Returns NSNotFound if the request times out or is not completed. 48 // Returns NSNotFound if the request times out or is not completed.
50 NSUInteger GetCharacterIndexAtPoint(content::RenderWidgetHost* rwh, 49 NSUInteger GetCharacterIndexAtPoint(RenderWidgetHost* rwh, gfx::Point point);
51 gfx::Point point);
52 // Returns nil if the request times out or is completed. 50 // Returns nil if the request times out or is completed.
53 NSAttributedString* GetAttributedSubstringFromRange( 51 NSAttributedString* GetAttributedSubstringFromRange(
54 content::RenderWidgetHost* rwh, NSRange range); 52 RenderWidgetHost* rwh, NSRange range);
55 // Returns NSZeroRect if the request times out or is not completed. The result 53 // Returns NSZeroRect if the request times out or is not completed. The result
56 // is in WebKit coordinates. 54 // is in WebKit coordinates.
57 NSRect GetFirstRectForRange(content::RenderWidgetHost* rwh, NSRange range); 55 NSRect GetFirstRectForRange(RenderWidgetHost* rwh, NSRange range);
58 56
59 // When the renderer sends the ViewHostMsg reply, the RenderMessageFilter will 57 // When the renderer sends the ViewHostMsg reply, the RenderMessageFilter will
60 // call the corresponding method on the IO thread to unlock the condition and 58 // call the corresponding method on the IO thread to unlock the condition and
61 // allow the Get*() methods to continue/return. 59 // allow the Get*() methods to continue/return.
62 void SetCharacterIndexAndSignal(NSUInteger index); 60 void SetCharacterIndexAndSignal(NSUInteger index);
63 void SetFirstRectAndSignal(NSRect first_rect); 61 void SetFirstRectAndSignal(NSRect first_rect);
64 void SetSubstringAndSignal(NSAttributedString* string); 62 void SetSubstringAndSignal(NSAttributedString* string);
65 63
66 private: 64 private:
67 friend struct DefaultSingletonTraits<TextInputClientMac>; 65 friend struct DefaultSingletonTraits<TextInputClientMac>;
(...skipping 12 matching lines...) Expand all
80 NSUInteger character_index_; 78 NSUInteger character_index_;
81 NSRect first_rect_; 79 NSRect first_rect_;
82 scoped_nsobject<NSAttributedString> substring_; 80 scoped_nsobject<NSAttributedString> substring_;
83 81
84 base::Lock lock_; 82 base::Lock lock_;
85 base::ConditionVariable condition_; 83 base::ConditionVariable condition_;
86 84
87 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); 85 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac);
88 }; 86 };
89 87
88 } // namespace content
89
90 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ 90 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/test_render_view_host.h ('k') | content/browser/renderer_host/text_input_client_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698