| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/browser/views/find_bar_view.h" | 5 #include "chrome/browser/views/find_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/find_bar_controller.h" | 10 #include "chrome/browser/find_bar_controller.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 UpdateForResult(controller->web_contents()->find_result(), std::wstring()); | 472 UpdateForResult(controller->web_contents()->find_result(), std::wstring()); |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 bool FindBarView::HandleKeystroke(views::TextField* sender, UINT message, | 476 bool FindBarView::HandleKeystroke(views::TextField* sender, UINT message, |
| 477 TCHAR key, UINT repeat_count, UINT flags) { | 477 TCHAR key, UINT repeat_count, UINT flags) { |
| 478 // If the dialog is not visible, there is no reason to process keyboard input. | 478 // If the dialog is not visible, there is no reason to process keyboard input. |
| 479 if (!container_->IsVisible()) | 479 if (!container_->IsVisible()) |
| 480 return false; | 480 return false; |
| 481 | 481 |
| 482 // TODO(port): Handle this for other platforms. |
| 483 #if defined(OS_WIN) |
| 484 if (container_->MaybeForwardKeystrokeToWebpage(message, key, flags)) |
| 485 return true; // Handled, we are done! |
| 486 #endif |
| 487 |
| 482 switch (key) { | 488 switch (key) { |
| 483 case VK_RETURN: { | 489 case VK_RETURN: { |
| 484 // Pressing Return/Enter starts the search (unless text box is empty). | 490 // Pressing Return/Enter starts the search (unless text box is empty). |
| 485 std::wstring find_string = find_text_->GetText(); | 491 std::wstring find_string = find_text_->GetText(); |
| 486 if (find_string.length() > 0) { | 492 if (find_string.length() > 0) { |
| 487 // Search forwards for enter, backwards for shift-enter. | 493 // Search forwards for enter, backwards for shift-enter. |
| 488 container_->GetFindBarController()->web_contents()->StartFinding( | 494 container_->GetFindBarController()->web_contents()->StartFinding( |
| 489 find_string, | 495 find_string, |
| 490 GetKeyState(VK_SHIFT) >= 0); | 496 GetKeyState(VK_SHIFT) >= 0); |
| 491 } | 497 } |
| 492 break; | 498 break; |
| 493 } | 499 } |
| 494 #if defined(OS_WIN) | |
| 495 // TODO(port): Handle this for other platforms. | |
| 496 case VK_HOME: | |
| 497 case VK_END: | |
| 498 // Ctrl+Home and Ctrl+End should be forwarded to the page. | |
| 499 if (GetKeyState(VK_CONTROL) >= 0) | |
| 500 return false; // Ctrl not pressed: Abort. Otherwise fall through. | |
| 501 case VK_UP: | |
| 502 case VK_DOWN: | |
| 503 case VK_PRIOR: // Page up | |
| 504 case VK_NEXT: // Page down | |
| 505 container_->ForwardKeystrokeToWebpage(key); | |
| 506 return true; // Message has been handled. No further processing needed. | |
| 507 #endif | |
| 508 } | 500 } |
| 509 | 501 |
| 510 return false; | 502 return false; |
| 511 } | 503 } |
| 512 | 504 |
| 513 void FindBarView::ResetMatchCountBackground() { | 505 void FindBarView::ResetMatchCountBackground() { |
| 514 match_count_text_->set_background( | 506 match_count_text_->set_background( |
| 515 views::Background::CreateSolidBackground(kBackgroundColorMatch)); | 507 views::Background::CreateSolidBackground(kBackgroundColorMatch)); |
| 516 match_count_text_->SetColor(kTextColorMatchCount); | 508 match_count_text_->SetColor(kTextColorMatchCount); |
| 517 } | 509 } |
| 518 | 510 |
| 519 bool FindBarView::FocusForwarderView::OnMousePressed( | 511 bool FindBarView::FocusForwarderView::OnMousePressed( |
| 520 const views::MouseEvent& event) { | 512 const views::MouseEvent& event) { |
| 521 if (view_to_focus_on_mousedown_) { | 513 if (view_to_focus_on_mousedown_) { |
| 522 view_to_focus_on_mousedown_->ClearSelection(); | 514 view_to_focus_on_mousedown_->ClearSelection(); |
| 523 view_to_focus_on_mousedown_->RequestFocus(); | 515 view_to_focus_on_mousedown_->RequestFocus(); |
| 524 } | 516 } |
| 525 return true; | 517 return true; |
| 526 } | 518 } |
| OLD | NEW |