| 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/browser/renderer_host/text_input_client_message_filter.h" | 5 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 9 #include "content/browser/renderer_host/text_input_client_mac.h" | 9 #include "content/browser/renderer_host/text_input_client_mac.h" |
| 10 #include "content/common/text_input_client_messages.h" | 10 #include "content/common/text_input_client_messages.h" |
| 11 #include "content/public/browser/render_widget_host_view.h" | 11 #include "content/public/browser/render_widget_host_view.h" |
| 12 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.h" |
| 13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 14 #include "ui/gfx/range/range.h" | 14 #include "ui/gfx/range/range.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 TextInputClientMessageFilter::TextInputClientMessageFilter(int child_id) | 18 TextInputClientMessageFilter::TextInputClientMessageFilter(int child_id) |
| 19 : BrowserMessageFilter(TextInputClientMsgStart), | 19 : BrowserMessageFilter(TextInputClientMsgStart), |
| 20 child_process_id_(child_id) { | 20 child_process_id_(child_id) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool TextInputClientMessageFilter::OnMessageReceived( | 23 bool TextInputClientMessageFilter::OnMessageReceived( |
| 24 const IPC::Message& message, | 24 const IPC::Message& message) { |
| 25 bool* message_was_ok) { | |
| 26 bool handled = true; | 25 bool handled = true; |
| 27 IPC_BEGIN_MESSAGE_MAP_EX(TextInputClientMessageFilter, message, | 26 IPC_BEGIN_MESSAGE_MAP(TextInputClientMessageFilter, message) |
| 28 *message_was_ok) | |
| 29 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotStringAtPoint, | 27 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotStringAtPoint, |
| 30 OnGotStringAtPoint) | 28 OnGotStringAtPoint) |
| 31 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotCharacterIndexForPoint, | 29 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotCharacterIndexForPoint, |
| 32 OnGotCharacterIndexForPoint) | 30 OnGotCharacterIndexForPoint) |
| 33 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotFirstRectForRange, | 31 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotFirstRectForRange, |
| 34 OnGotFirstRectForRange) | 32 OnGotFirstRectForRange) |
| 35 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotStringForRange, | 33 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotStringForRange, |
| 36 OnGotStringFromRange) | 34 OnGotStringFromRange) |
| 37 IPC_MESSAGE_UNHANDLED(handled = false) | 35 IPC_MESSAGE_UNHANDLED(handled = false) |
| 38 IPC_END_MESSAGE_MAP_EX() | 36 IPC_END_MESSAGE_MAP() |
| 39 return handled; | 37 return handled; |
| 40 } | 38 } |
| 41 | 39 |
| 42 TextInputClientMessageFilter::~TextInputClientMessageFilter() {} | 40 TextInputClientMessageFilter::~TextInputClientMessageFilter() {} |
| 43 | 41 |
| 44 void TextInputClientMessageFilter::OnGotStringAtPoint( | 42 void TextInputClientMessageFilter::OnGotStringAtPoint( |
| 45 const mac::AttributedStringCoder::EncodedString& encoded_string, | 43 const mac::AttributedStringCoder::EncodedString& encoded_string, |
| 46 const gfx::Point& point) { | 44 const gfx::Point& point) { |
| 47 TextInputClientMac* service = TextInputClientMac::GetInstance(); | 45 TextInputClientMac* service = TextInputClientMac::GetInstance(); |
| 48 NSAttributedString* string = | 46 NSAttributedString* string = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 const mac::AttributedStringCoder::EncodedString& encoded_string) { | 68 const mac::AttributedStringCoder::EncodedString& encoded_string) { |
| 71 TextInputClientMac* service = TextInputClientMac::GetInstance(); | 69 TextInputClientMac* service = TextInputClientMac::GetInstance(); |
| 72 NSAttributedString* string = | 70 NSAttributedString* string = |
| 73 mac::AttributedStringCoder::Decode(&encoded_string); | 71 mac::AttributedStringCoder::Decode(&encoded_string); |
| 74 if (![string length]) | 72 if (![string length]) |
| 75 string = nil; | 73 string = nil; |
| 76 service->SetSubstringAndSignal(string); | 74 service->SetSubstringAndSignal(string); |
| 77 } | 75 } |
| 78 | 76 |
| 79 } // namespace content | 77 } // namespace content |
| OLD | NEW |