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

Side by Side Diff: chrome/browser/renderer_host/text_input_client_message_filter.mm

Issue 6289009: [Mac] Implement the system dictionary popup by implementing NSTextInput methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Clang Created 9 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/renderer_host/text_input_client_message_filter.h"
6
7 #include "base/memory/scoped_nsobject.h"
8 #include "base/string16.h"
9 #include "chrome/browser/renderer_host/text_input_client_mac.h"
10 #include "chrome/common/attributed_string_coder_mac.h"
11 #include "chrome/common/text_input_client_messages.h"
12 #include "content/browser/browser_thread.h"
13 #include "content/browser/renderer_host/render_view_host.h"
14 #include "content/browser/renderer_host/render_widget_host_view.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "ui/base/range/range.h"
17 #include "ui/gfx/rect.h"
18
19 TextInputClientMessageFilter::TextInputClientMessageFilter(int child_id)
20 : BrowserMessageFilter(),
21 child_process_id_(child_id) {
22 }
23
24 TextInputClientMessageFilter::~TextInputClientMessageFilter() {
25 }
26
27 bool TextInputClientMessageFilter::OnMessageReceived(
28 const IPC::Message& message,
29 bool* message_was_ok) {
30 bool handled = true;
31 IPC_BEGIN_MESSAGE_MAP_EX(TextInputClientMessageFilter, message,
32 *message_was_ok)
33 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotCharacterIndexForPoint,
34 OnGotCharacterIndexForPoint)
35 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotFirstRectForRange,
36 OnGotFirstRectForRange)
37 IPC_MESSAGE_HANDLER(TextInputClientReplyMsg_GotStringForRange,
38 OnGotStringFromRange)
39 IPC_MESSAGE_UNHANDLED(handled = false)
40 IPC_END_MESSAGE_MAP_EX()
41 return handled;
42 }
43
44 void TextInputClientMessageFilter::OnGotCharacterIndexForPoint(size_t index) {
45 TextInputClientMac* service = TextInputClientMac::GetInstance();
46 service->SetCharacterIndexAndSignal(index);
47 }
48
49 void TextInputClientMessageFilter::OnGotFirstRectForRange(
50 const gfx::Rect& rect) {
51 TextInputClientMac* service = TextInputClientMac::GetInstance();
52 service->SetFirstRectAndSignal(NSRectFromCGRect(rect.ToCGRect()));
53 }
54
55 void TextInputClientMessageFilter::OnGotStringFromRange(
56 const mac::AttributedStringCoder::EncodedString& encoded_string) {
57 TextInputClientMac* service = TextInputClientMac::GetInstance();
58 NSAttributedString* string =
59 mac::AttributedStringCoder::Decode(&encoded_string);
60 if (![string length])
61 string = nil;
62 service->SetSubstringAndSignal(string);
63 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/text_input_client_message_filter.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698