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 "chrome_frame/find_dialog.h" | 5 #include "chrome_frame/find_dialog.h" |
6 | 6 |
7 #include <richedit.h> | 7 #include <richedit.h> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome_frame/chrome_frame_automation.h" | 11 #include "chrome_frame/chrome_frame_automation.h" |
12 | 12 |
13 const int kMaxFindChars = 1024; | 13 const int kMaxFindChars = 1024; |
14 | 14 |
15 HHOOK CFFindDialog::msg_hook_ = NULL; | 15 HHOOK CFFindDialog::msg_hook_ = NULL; |
16 | 16 |
17 CFFindDialog::CFFindDialog() {} | 17 CFFindDialog::CFFindDialog() {} |
18 | 18 |
19 void CFFindDialog::Init(ChromeFrameAutomationClient* automation_client) { | 19 void CFFindDialog::Init(ChromeFrameAutomationClient* automation_client) { |
20 automation_client_ = automation_client; | 20 automation_client_ = automation_client; |
21 } | 21 } |
22 | 22 |
23 LRESULT CFFindDialog::OnDestroy(UINT msg, WPARAM wparam, LPARAM lparam, | 23 LRESULT CFFindDialog::OnDestroy(UINT msg, WPARAM wparam, LPARAM lparam, |
24 BOOL& handled) { | 24 BOOL& handled) { |
25 // In order to cancel the selection when the Find dialog is dismissed, we | 25 // In order to cancel the selection when the Find dialog is dismissed, we |
26 // do a fake search for a string that is unlikely to appear on the page. | 26 // do a fake search for a string that is unlikely to appear on the page. |
27 // TODO(robertshield): Change this to plumb through a StopFinding automation | 27 // TODO(robertshield): Change this to plumb through a StopFinding automation |
28 // message that triggers a ViewMsg_StopFinding. | 28 // message that triggers a ViewMsg_StopFinding. |
29 std::string guid(base::GenerateGUID()); | 29 std::string guid(base::GenerateGUID()); |
30 automation_client_->FindInPage(ASCIIToWide(guid), FWD, CASE_SENSITIVE, false); | 30 automation_client_->FindInPage(base::ASCIIToWide(guid), |
| 31 FWD, CASE_SENSITIVE, false); |
31 | 32 |
32 UninstallMessageHook(); | 33 UninstallMessageHook(); |
33 return 0; | 34 return 0; |
34 } | 35 } |
35 | 36 |
36 LRESULT CFFindDialog::OnFind(WORD wNotifyCode, WORD wID, HWND hWndCtl, | 37 LRESULT CFFindDialog::OnFind(WORD wNotifyCode, WORD wID, HWND hWndCtl, |
37 BOOL& bHandled) { | 38 BOOL& bHandled) { |
38 base::string16 find_text(kMaxFindChars, L'\0'); | 39 base::string16 find_text(kMaxFindChars, L'\0'); |
39 find_text.resize(GetDlgItemText(IDC_FIND_TEXT, &find_text[0], kMaxFindChars)); | 40 find_text.resize(GetDlgItemText(IDC_FIND_TEXT, &find_text[0], kMaxFindChars)); |
40 | 41 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 112 } |
112 | 113 |
113 bool CFFindDialog::UninstallMessageHook() { | 114 bool CFFindDialog::UninstallMessageHook() { |
114 DCHECK(msg_hook_ != NULL); | 115 DCHECK(msg_hook_ != NULL); |
115 BOOL result = ::UnhookWindowsHookEx(msg_hook_); | 116 BOOL result = ::UnhookWindowsHookEx(msg_hook_); |
116 DCHECK(result); | 117 DCHECK(result); |
117 msg_hook_ = NULL; | 118 msg_hook_ = NULL; |
118 | 119 |
119 return result != FALSE; | 120 return result != FALSE; |
120 } | 121 } |
OLD | NEW |