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

Side by Side Diff: chrome_frame/find_dialog.cc

Issue 9700053: Correctly handle FindNext from the Find dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dear Greg, Created 8 years, 9 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
« no previous file with comments | « chrome_frame/find_dialog.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 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/utf_string_conversions.h"
10 #include "chrome/common/guid.h"
9 #include "chrome_frame/chrome_frame_automation.h" 11 #include "chrome_frame/chrome_frame_automation.h"
10 12
11 const int kMaxFindChars = 1024; 13 const int kMaxFindChars = 1024;
12 14
13 HHOOK CFFindDialog::msg_hook_ = NULL; 15 HHOOK CFFindDialog::msg_hook_ = NULL;
14 16
15 CFFindDialog::CFFindDialog() {} 17 CFFindDialog::CFFindDialog() {}
16 18
17 void CFFindDialog::Init(ChromeFrameAutomationClient* automation_client) { 19 void CFFindDialog::Init(ChromeFrameAutomationClient* automation_client) {
18 automation_client_ = automation_client; 20 automation_client_ = automation_client;
19 } 21 }
20 22
21 LRESULT CFFindDialog::OnDestroy(UINT msg, WPARAM wparam, LPARAM lparam, 23 LRESULT CFFindDialog::OnDestroy(UINT msg, WPARAM wparam, LPARAM lparam,
22 BOOL& handled) { 24 BOOL& handled) {
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.
27 // TODO(robertshield): Change this to plumb through a StopFinding automation
28 // message that triggers a ViewMsg_StopFinding.
29 std::string guid(guid::GenerateGUID());
30 automation_client_->FindInPage(ASCIIToWide(guid), FWD, CASE_SENSITIVE, false);
31
23 UninstallMessageHook(); 32 UninstallMessageHook();
24 return 0; 33 return 0;
25 } 34 }
26 35
27 LRESULT CFFindDialog::OnFind(WORD wNotifyCode, WORD wID, HWND hWndCtl, 36 LRESULT CFFindDialog::OnFind(WORD wNotifyCode, WORD wID, HWND hWndCtl,
28 BOOL& bHandled) { 37 BOOL& bHandled) {
29 wchar_t buffer[kMaxFindChars + 1]; 38 string16 find_text(kMaxFindChars, L'\0');
30 GetDlgItemText(IDC_FIND_TEXT, buffer, kMaxFindChars); 39 find_text.resize(GetDlgItemText(IDC_FIND_TEXT, &find_text[0], kMaxFindChars));
31 std::wstring find_text(buffer); 40
41 // Repeated searches for the same string should move to the next instance.
42 bool find_next = (find_text == last_find_text_);
43 if (!find_next)
44 last_find_text_ = find_text;
32 45
33 bool match_case = IsDlgButtonChecked(IDC_MATCH_CASE) == BST_CHECKED; 46 bool match_case = IsDlgButtonChecked(IDC_MATCH_CASE) == BST_CHECKED;
34 bool search_down = IsDlgButtonChecked(IDC_DIRECTION_DOWN) == BST_CHECKED; 47 bool search_down = IsDlgButtonChecked(IDC_DIRECTION_DOWN) == BST_CHECKED;
35 48
36 automation_client_->FindInPage(find_text, 49 automation_client_->FindInPage(find_text,
37 search_down ? FWD : BACK, 50 search_down ? FWD : BACK,
38 match_case ? CASE_SENSITIVE : IGNORE_CASE, 51 match_case ? CASE_SENSITIVE : IGNORE_CASE,
39 false); 52 find_next);
40 53
41 return 0; 54 return 0;
42 } 55 }
43 56
44 LRESULT CFFindDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, 57 LRESULT CFFindDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl,
45 BOOL& bHandled) { 58 BOOL& bHandled) {
46 DestroyWindow(); 59 DestroyWindow();
47 return 0; 60 return 0;
48 } 61 }
49 62
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 111 }
99 112
100 bool CFFindDialog::UninstallMessageHook() { 113 bool CFFindDialog::UninstallMessageHook() {
101 DCHECK(msg_hook_ != NULL); 114 DCHECK(msg_hook_ != NULL);
102 BOOL result = ::UnhookWindowsHookEx(msg_hook_); 115 BOOL result = ::UnhookWindowsHookEx(msg_hook_);
103 DCHECK(result); 116 DCHECK(result);
104 msg_hook_ = NULL; 117 msg_hook_ = NULL;
105 118
106 return result != FALSE; 119 return result != FALSE;
107 } 120 }
OLDNEW
« no previous file with comments | « chrome_frame/find_dialog.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698