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 #import "content/browser/renderer_host/text_input_client_mac.h" | 5 #import "content/browser/renderer_host/text_input_client_mac.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // static | 31 // static |
32 TextInputClientMac* TextInputClientMac::GetInstance() { | 32 TextInputClientMac* TextInputClientMac::GetInstance() { |
33 return base::Singleton<TextInputClientMac>::get(); | 33 return base::Singleton<TextInputClientMac>::get(); |
34 } | 34 } |
35 | 35 |
36 void TextInputClientMac::GetStringAtPoint( | 36 void TextInputClientMac::GetStringAtPoint( |
37 RenderWidgetHost* rwh, | 37 RenderWidgetHost* rwh, |
38 gfx::Point point, | 38 gfx::Point point, |
39 void (^reply_handler)(NSAttributedString*, NSPoint)) { | 39 void (^reply_handler)(NSAttributedString*, NSPoint)) { |
| 40 // TODO(ekaramad): In principle, we are using the same handler regardless of |
| 41 // the |rwh| which requested this. We should track the callbacks for each |
| 42 // |rwh| individually so that one slow RWH will not end up clearing the |
| 43 // callback for another (https://crbug.com/643233). |
40 DCHECK(replyForPointHandler_.get() == nil); | 44 DCHECK(replyForPointHandler_.get() == nil); |
41 replyForPointHandler_.reset(reply_handler, base::scoped_policy::RETAIN); | 45 replyForPointHandler_.reset(reply_handler, base::scoped_policy::RETAIN); |
42 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); | 46 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |
43 rwhi->Send(new TextInputClientMsg_StringAtPoint(rwhi->GetRoutingID(), point)); | 47 rwhi->Send(new TextInputClientMsg_StringAtPoint(rwhi->GetRoutingID(), point)); |
44 } | 48 } |
45 | 49 |
46 void TextInputClientMac::GetStringAtPointReply(NSAttributedString* string, | 50 void TextInputClientMac::GetStringAtPointReply(NSAttributedString* string, |
47 NSPoint point) { | 51 NSPoint point) { |
48 if (replyForPointHandler_.get()) { | 52 if (replyForPointHandler_.get()) { |
49 replyForPointHandler_.get()(string, point); | 53 replyForPointHandler_.get()(string, point); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 140 |
137 character_index_ = NSNotFound; | 141 character_index_ = NSNotFound; |
138 first_rect_ = NSZeroRect; | 142 first_rect_ = NSZeroRect; |
139 } | 143 } |
140 | 144 |
141 void TextInputClientMac::AfterRequest() { | 145 void TextInputClientMac::AfterRequest() { |
142 lock_.Release(); | 146 lock_.Release(); |
143 } | 147 } |
144 | 148 |
145 } // namespace content | 149 } // namespace content |
OLD | NEW |