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

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

Issue 9600036: Move Render(View|Widget)Host and associated classes to content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/gfx/point.h" 13 #include "ui/gfx/point.h"
14 14
15 template <typename T> struct DefaultSingletonTraits; 15 template <typename T> struct DefaultSingletonTraits;
16 16
17 namespace content {
17 class RenderWidgetHost; 18 class RenderWidgetHost;
19 }
18 20
19 // 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,
20 // look at this document: 22 // look at this document:
21 // 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
22 // 24 //
23 // 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
24 // implemented in RenderWidgetHostViewMac: 26 // implemented in RenderWidgetHostViewMac:
25 // -[NSTextInput characterIndexForPoint:] 27 // -[NSTextInput characterIndexForPoint:]
26 // -[NSTextInput attributedSubstringFromRange:] 28 // -[NSTextInput attributedSubstringFromRange:]
27 // -[NSTextInput firstRectForCharacterRange:] 29 // -[NSTextInput firstRectForCharacterRange:]
28 // 30 //
29 // 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
30 // requires getting information from the renderer synchronously. Rather than 32 // requires getting information from the renderer synchronously. Rather than
31 // 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
32 // and condition (managed by this service). 34 // and condition (managed by this service).
33 class TextInputClientMac { 35 class TextInputClientMac {
34 public: 36 public:
35 // Returns the singleton instance. 37 // Returns the singleton instance.
36 static TextInputClientMac* GetInstance(); 38 static TextInputClientMac* GetInstance();
37 39
38 // 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
39 // 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
40 // (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
41 // 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
42 // 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
43 // 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
44 // unlock and return that stored value. 46 // unlock and return that stored value.
45 // 47 //
46 // Returns NSNotFound if the request times out or is not completed. 48 // Returns NSNotFound if the request times out or is not completed.
47 NSUInteger GetCharacterIndexAtPoint(RenderWidgetHost* rwh, gfx::Point point); 49 NSUInteger GetCharacterIndexAtPoint(content::RenderWidgetHost* rwh,
50 gfx::Point point);
48 // Returns nil if the request times out or is completed. 51 // Returns nil if the request times out or is completed.
49 NSAttributedString* GetAttributedSubstringFromRange(RenderWidgetHost* rwh, 52 NSAttributedString* GetAttributedSubstringFromRange(
50 NSRange range); 53 content::RenderWidgetHost* rwh, NSRange range);
51 // Returns NSZeroRect if the request times out or is not completed. The result 54 // Returns NSZeroRect if the request times out or is not completed. The result
52 // is in WebKit coordinates. 55 // is in WebKit coordinates.
53 NSRect GetFirstRectForRange(RenderWidgetHost* rwh, NSRange range); 56 NSRect GetFirstRectForRange(content::RenderWidgetHost* rwh, NSRange range);
54 57
55 // When the renderer sends the ViewHostMsg reply, the RenderMessageFilter will 58 // When the renderer sends the ViewHostMsg reply, the RenderMessageFilter will
56 // call the corresponding method on the IO thread to unlock the condition and 59 // call the corresponding method on the IO thread to unlock the condition and
57 // allow the Get*() methods to continue/return. 60 // allow the Get*() methods to continue/return.
58 void SetCharacterIndexAndSignal(NSUInteger index); 61 void SetCharacterIndexAndSignal(NSUInteger index);
59 void SetFirstRectAndSignal(NSRect first_rect); 62 void SetFirstRectAndSignal(NSRect first_rect);
60 void SetSubstringAndSignal(NSAttributedString* string); 63 void SetSubstringAndSignal(NSAttributedString* string);
61 64
62 private: 65 private:
63 friend struct DefaultSingletonTraits<TextInputClientMac>; 66 friend struct DefaultSingletonTraits<TextInputClientMac>;
(...skipping 13 matching lines...) Expand all
77 NSRect first_rect_; 80 NSRect first_rect_;
78 scoped_nsobject<NSAttributedString> substring_; 81 scoped_nsobject<NSAttributedString> substring_;
79 82
80 base::Lock lock_; 83 base::Lock lock_;
81 base::ConditionVariable condition_; 84 base::ConditionVariable condition_;
82 85
83 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac); 86 DISALLOW_COPY_AND_ASSIGN(TextInputClientMac);
84 }; 87 };
85 88
86 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_ 89 #endif // CONTENT_BROWSER_RENDERER_HOST_TEXT_INPUT_CLIENT_MAC_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/test_render_view_host.cc ('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