summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/find_bar_view.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 03:43:45 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-21 03:43:45 +0000
commiteea372e5ae883c1a9853086e54b43896aa72df36 (patch)
treef8345aa56206a072496d69554f805fe189483011 /chrome/browser/views/find_bar_view.cc
parentb343f1c73ce201d34fe41037734f57f68dffe2f6 (diff)
downloadchromium_src-eea372e5ae883c1a9853086e54b43896aa72df36.zip
chromium_src-eea372e5ae883c1a9853086e54b43896aa72df36.tar.gz
chromium_src-eea372e5ae883c1a9853086e54b43896aa72df36.tar.bz2
Try to make TextField::Controller implementors cross-platform by abstracting
away the keystroke message that is passed. It turns out implementoars only ever check for enter and escape messages, so I wrote two functions in TextField that will decode the new Keyboard event. This design is not optimal. Ideally we would have something more like the WebInputEvent so that callers can check for anything in a cross-platform way. This was branched off from the original review: http://codereview.chromium.org/113639 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16577 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/find_bar_view.cc')
-rw-r--r--chrome/browser/views/find_bar_view.cc28
1 files changed, 13 insertions, 15 deletions
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index ededa28..063ea63 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -456,31 +456,29 @@ void FindBarView::ContentsChanged(views::TextField* sender,
}
}
-bool FindBarView::HandleKeystroke(views::TextField* sender, UINT message,
- TCHAR key, UINT repeat_count, UINT flags) {
+bool FindBarView::HandleKeystroke(views::TextField* sender,
+ const views::TextField::Keystroke& key) {
// If the dialog is not visible, there is no reason to process keyboard input.
if (!container_->IsVisible())
return false;
// TODO(port): Handle this for other platforms.
#if defined(OS_WIN)
- if (container_->MaybeForwardKeystrokeToWebpage(message, key, flags))
+ if (container_->MaybeForwardKeystrokeToWebpage(key.message, key.key,
+ key.flags))
return true; // Handled, we are done!
- #endif
- switch (key) {
- case VK_RETURN: {
- // Pressing Return/Enter starts the search (unless text box is empty).
- std::wstring find_string = find_text_->GetText();
- if (!find_string.empty()) {
- // Search forwards for enter, backwards for shift-enter.
- container_->GetFindBarController()->tab_contents()->StartFinding(
- find_string,
- GetKeyState(VK_SHIFT) >= 0);
- }
- break;
+ if (views::TextField::IsKeystrokeEnter(key)) {
+ // Pressing Return/Enter starts the search (unless text box is empty).
+ std::wstring find_string = find_text_->GetText();
+ if (!find_string.empty()) {
+ // Search forwards for enter, backwards for shift-enter.
+ container_->GetFindBarController()->tab_contents()->StartFinding(
+ find_string,
+ GetKeyState(VK_SHIFT) >= 0);
}
}
+ #endif
return false;
}