| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // we close and reopen the Find box it doesn't show the search we just | 496 // we close and reopen the Find box it doesn't show the search we just |
| 497 // deleted. We can't do this on ChromeOS yet because we get ContentsChanged | 497 // deleted. We can't do this on ChromeOS yet because we get ContentsChanged |
| 498 // sent for a lot more things than just the user nulling out the search | 498 // sent for a lot more things than just the user nulling out the search |
| 499 // terms. See http://crbug.com/45372. | 499 // terms. See http://crbug.com/45372. |
| 500 FindBarState* find_bar_state = | 500 FindBarState* find_bar_state = |
| 501 controller->tab_contents()->profile()->GetFindBarState(); | 501 controller->tab_contents()->profile()->GetFindBarState(); |
| 502 find_bar_state->set_last_prepopulate_text(string16()); | 502 find_bar_state->set_last_prepopulate_text(string16()); |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 bool FindBarView::HandleKeystroke(views::Textfield* sender, | 506 bool FindBarView::HandleKeyEvent(views::Textfield* sender, |
| 507 const views::Textfield::Keystroke& key) { | 507 const views::KeyEvent& key_event) { |
| 508 // If the dialog is not visible, there is no reason to process keyboard input. | 508 // If the dialog is not visible, there is no reason to process keyboard input. |
| 509 if (!host()->IsVisible()) | 509 if (!host()->IsVisible()) |
| 510 return false; | 510 return false; |
| 511 | 511 |
| 512 if (find_bar_host()->MaybeForwardKeystrokeToWebpage(key)) | 512 if (find_bar_host()->MaybeForwardKeyEventToWebpage(key_event)) |
| 513 return true; // Handled, we are done! | 513 return true; // Handled, we are done! |
| 514 | 514 |
| 515 if (key.GetKeyboardCode() == app::VKEY_RETURN) { | 515 if (key_event.GetKeyCode() == app::VKEY_RETURN) { |
| 516 // Pressing Return/Enter starts the search (unless text box is empty). | 516 // Pressing Return/Enter starts the search (unless text box is empty). |
| 517 string16 find_string = find_text_->text(); | 517 string16 find_string = find_text_->text(); |
| 518 if (!find_string.empty()) { | 518 if (!find_string.empty()) { |
| 519 // Search forwards for enter, backwards for shift-enter. | 519 // Search forwards for enter, backwards for shift-enter. |
| 520 find_bar_host()->GetFindBarController()->tab_contents()->StartFinding( | 520 find_bar_host()->GetFindBarController()->tab_contents()->StartFinding( |
| 521 find_string, | 521 find_string, |
| 522 !key.IsShiftHeld(), | 522 !key_event.IsShiftDown(), |
| 523 false); // Not case sensitive. | 523 false); // Not case sensitive. |
| 524 } | 524 } |
| 525 } | 525 } |
| 526 | 526 |
| 527 return false; | 527 return false; |
| 528 } | 528 } |
| 529 | 529 |
| 530 void FindBarView::UpdateMatchCountAppearance(bool no_match) { | 530 void FindBarView::UpdateMatchCountAppearance(bool no_match) { |
| 531 if (no_match) { | 531 if (no_match) { |
| 532 match_count_text_->set_background( | 532 match_count_text_->set_background( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 | 565 |
| 566 void FindBarView::OnThemeChanged() { | 566 void FindBarView::OnThemeChanged() { |
| 567 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 567 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 568 if (GetThemeProvider()) { | 568 if (GetThemeProvider()) { |
| 569 close_button_->SetBackground( | 569 close_button_->SetBackground( |
| 570 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), | 570 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), |
| 571 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 571 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
| 572 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 572 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
| 573 } | 573 } |
| 574 } | 574 } |
| OLD | NEW |