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 #include "content/renderer/text_input_client_observer.h" | 5 #include "content/renderer/text_input_client_observer.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "content/common/text_input_client_messages.h" | 8 #include "content/common/text_input_client_messages.h" |
9 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 9 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) { | 29 bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) { |
30 bool handled = true; | 30 bool handled = true; |
31 IPC_BEGIN_MESSAGE_MAP(TextInputClientObserver, message) | 31 IPC_BEGIN_MESSAGE_MAP(TextInputClientObserver, message) |
32 IPC_MESSAGE_HANDLER(TextInputClientMsg_StringAtPoint, | 32 IPC_MESSAGE_HANDLER(TextInputClientMsg_StringAtPoint, |
33 OnStringAtPoint) | 33 OnStringAtPoint) |
34 IPC_MESSAGE_HANDLER(TextInputClientMsg_CharacterIndexForPoint, | 34 IPC_MESSAGE_HANDLER(TextInputClientMsg_CharacterIndexForPoint, |
35 OnCharacterIndexForPoint) | 35 OnCharacterIndexForPoint) |
36 IPC_MESSAGE_HANDLER(TextInputClientMsg_FirstRectForCharacterRange, | 36 IPC_MESSAGE_HANDLER(TextInputClientMsg_FirstRectForCharacterRange, |
37 OnFirstRectForCharacterRange) | 37 OnFirstRectForCharacterRange) |
38 IPC_MESSAGE_HANDLER(TextInputClientMsg_StringForRange, OnStringForRange) | |
39 IPC_MESSAGE_UNHANDLED(handled = false) | 38 IPC_MESSAGE_UNHANDLED(handled = false) |
40 IPC_END_MESSAGE_MAP() | 39 IPC_END_MESSAGE_MAP() |
41 return handled; | 40 return handled; |
42 } | 41 } |
43 | 42 |
44 blink::WebView* TextInputClientObserver::webview() { | 43 blink::WebView* TextInputClientObserver::webview() { |
45 return render_view()->GetWebView(); | 44 return render_view()->GetWebView(); |
46 } | 45 } |
47 | 46 |
48 void TextInputClientObserver::OnStringAtPoint(gfx::Point point) { | 47 void TextInputClientObserver::OnStringAtPoint(gfx::Point point) { |
(...skipping 30 matching lines...) Expand all Loading... |
79 if (frame) { | 78 if (frame) { |
80 blink::WebRect web_rect; | 79 blink::WebRect web_rect; |
81 frame->firstRectForCharacterRange(range.start(), range.length(), | 80 frame->firstRectForCharacterRange(range.start(), range.length(), |
82 web_rect); | 81 web_rect); |
83 rect = web_rect; | 82 rect = web_rect; |
84 } | 83 } |
85 } | 84 } |
86 Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect)); | 85 Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect)); |
87 } | 86 } |
88 | 87 |
89 void TextInputClientObserver::OnStringForRange(gfx::Range range) { | |
90 #if defined(OS_MACOSX) | |
91 NSAttributedString* string = nil; | |
92 blink::WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame(); | |
93 if (frame) { | |
94 string = blink::WebSubstringUtil::attributedSubstringInRange( | |
95 frame, range.start(), range.length()); | |
96 } | |
97 scoped_ptr<const mac::AttributedStringCoder::EncodedString> encoded( | |
98 mac::AttributedStringCoder::Encode(string)); | |
99 Send(new TextInputClientReplyMsg_GotStringForRange(routing_id(), | |
100 *encoded.get())); | |
101 #else | |
102 NOTIMPLEMENTED(); | |
103 #endif | |
104 } | |
105 | |
106 } // namespace content | 88 } // namespace content |
OLD | NEW |