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

Side by Side Diff: chrome/browser/views/find_bar_view.cc

Issue 660137: Allow users to close the find session and activate the current link via ctrl-... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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/browser/views/find_bar_host_interactive_uitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | 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) 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 "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (event.IsMouseEvent()) { 399 if (event.IsMouseEvent()) {
400 // If mouse event, we move the focus back to the text-field, so that the 400 // If mouse event, we move the focus back to the text-field, so that the
401 // user doesn't have to click on the text field to change the search. We 401 // user doesn't have to click on the text field to change the search. We
402 // don't want to do this for keyboard clicks on the button, since the 402 // don't want to do this for keyboard clicks on the button, since the
403 // user is more likely to press FindNext again than change the search 403 // user is more likely to press FindNext again than change the search
404 // query. 404 // query.
405 find_text_->RequestFocus(); 405 find_text_->RequestFocus();
406 } 406 }
407 break; 407 break;
408 case CLOSE_TAG: 408 case CLOSE_TAG:
409 find_bar_host()->GetFindBarController()->EndFindSession(); 409 find_bar_host()->GetFindBarController()->EndFindSession(
410 FindBarController::kKeepSelection);
410 break; 411 break;
411 default: 412 default:
412 NOTREACHED() << L"Unknown button"; 413 NOTREACHED() << L"Unknown button";
413 break; 414 break;
414 } 415 }
415 } 416 }
416 417
417 //////////////////////////////////////////////////////////////////////////////// 418 ////////////////////////////////////////////////////////////////////////////////
418 // FindBarView, views::Textfield::Controller implementation: 419 // FindBarView, views::Textfield::Controller implementation:
419 420
420 void FindBarView::ContentsChanged(views::Textfield* sender, 421 void FindBarView::ContentsChanged(views::Textfield* sender,
421 const string16& new_contents) { 422 const string16& new_contents) {
422 FindBarController* controller = find_bar_host()->GetFindBarController(); 423 FindBarController* controller = find_bar_host()->GetFindBarController();
423 DCHECK(controller); 424 DCHECK(controller);
424 // We must guard against a NULL tab_contents, which can happen if the text 425 // We must guard against a NULL tab_contents, which can happen if the text
425 // in the Find box is changed right after the tab is destroyed. Otherwise, it 426 // in the Find box is changed right after the tab is destroyed. Otherwise, it
426 // can lead to crashes, as exposed by automation testing in issue 8048. 427 // can lead to crashes, as exposed by automation testing in issue 8048.
427 if (!controller->tab_contents()) 428 if (!controller->tab_contents())
428 return; 429 return;
429 430
430 // When the user changes something in the text box we check the contents and 431 // When the user changes something in the text box we check the contents and
431 // if the textbox contains something we set it as the new search string and 432 // if the textbox contains something we set it as the new search string and
432 // initiate search (even though old searches might be in progress). 433 // initiate search (even though old searches might be in progress).
433 if (!new_contents.empty()) { 434 if (!new_contents.empty()) {
434 // The last two params here are forward (true) and case sensitive (false). 435 // The last two params here are forward (true) and case sensitive (false).
435 controller->tab_contents()->StartFinding(new_contents, true, false); 436 controller->tab_contents()->StartFinding(new_contents, true, false);
436 } else { 437 } else {
437 // The textbox is empty so we reset. true = clear selection on page. 438 controller->tab_contents()->StopFinding(FindBarController::kClearSelection);
438 controller->tab_contents()->StopFinding(true);
439 UpdateForResult(controller->tab_contents()->find_result(), string16()); 439 UpdateForResult(controller->tab_contents()->find_result(), string16());
440 } 440 }
441 } 441 }
442 442
443 bool FindBarView::HandleKeystroke(views::Textfield* sender, 443 bool FindBarView::HandleKeystroke(views::Textfield* sender,
444 const views::Textfield::Keystroke& key) { 444 const views::Textfield::Keystroke& key) {
445 // If the dialog is not visible, there is no reason to process keyboard input. 445 // If the dialog is not visible, there is no reason to process keyboard input.
446 if (!host()->IsVisible()) 446 if (!host()->IsVisible())
447 return false; 447 return false;
448 448
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 void FindBarView::ThemeChanged() { 492 void FindBarView::ThemeChanged() {
493 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 493 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
494 if (GetThemeProvider()) { 494 if (GetThemeProvider()) {
495 close_button_->SetBackground( 495 close_button_->SetBackground(
496 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), 496 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT),
497 rb.GetBitmapNamed(IDR_CLOSE_BAR), 497 rb.GetBitmapNamed(IDR_CLOSE_BAR),
498 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); 498 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK));
499 } 499 }
500 } 500 }
OLDNEW
« no previous file with comments | « chrome/browser/views/find_bar_host_interactive_uitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698