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

Side by Side Diff: chrome/browser/find_bar_controller.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/find_bar_controller.h ('k') | chrome/browser/find_bar_host_browsertest.cc » ('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/find_bar_controller.h" 5 #include "chrome/browser/find_bar_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/find_bar.h" 9 #include "chrome/browser/find_bar.h"
10 #include "chrome/browser/tab_contents/navigation_entry.h" 10 #include "chrome/browser/tab_contents/navigation_entry.h"
(...skipping 16 matching lines...) Expand all
27 void FindBarController::Show() { 27 void FindBarController::Show() {
28 // Only show the animation if we're not already showing a find bar for the 28 // Only show the animation if we're not already showing a find bar for the
29 // selected TabContents. 29 // selected TabContents.
30 if (!tab_contents_->find_ui_active()) { 30 if (!tab_contents_->find_ui_active()) {
31 tab_contents_->set_find_ui_active(true); 31 tab_contents_->set_find_ui_active(true);
32 find_bar_->Show(true); 32 find_bar_->Show(true);
33 } 33 }
34 find_bar_->SetFocusAndSelection(); 34 find_bar_->SetFocusAndSelection();
35 } 35 }
36 36
37 void FindBarController::EndFindSession() { 37 void FindBarController::EndFindSession(SelectionAction action) {
38 find_bar_->Hide(true); 38 find_bar_->Hide(true);
39 39
40 // |tab_contents_| can be NULL for a number of reasons, for example when the 40 // |tab_contents_| can be NULL for a number of reasons, for example when the
41 // tab is closing. We must guard against that case. See issue 8030. 41 // tab is closing. We must guard against that case. See issue 8030.
42 if (tab_contents_) { 42 if (tab_contents_) {
43 // When we hide the window, we need to notify the renderer that we are done 43 // When we hide the window, we need to notify the renderer that we are done
44 // for now, so that we can abort the scoping effort and clear all the 44 // for now, so that we can abort the scoping effort and clear all the
45 // tickmarks and highlighting. 45 // tickmarks and highlighting.
46 tab_contents_->StopFinding(false); // false = don't clear selection on 46 tab_contents_->StopFinding(action);
47 // page.
48 find_bar_->ClearResults(tab_contents_->find_result()); 47 find_bar_->ClearResults(tab_contents_->find_result());
49 48
50 // When we get dismissed we restore the focus to where it belongs. 49 // When we get dismissed we restore the focus to where it belongs.
51 find_bar_->RestoreSavedFocus(); 50 find_bar_->RestoreSavedFocus();
52 } 51 }
53 } 52 }
54 53
55 void FindBarController::ChangeTabContents(TabContents* contents) { 54 void FindBarController::ChangeTabContents(TabContents* contents) {
56 if (tab_contents_) { 55 if (tab_contents_) {
57 registrar_.RemoveAll(); 56 registrar_.RemoveAll();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (source_controller == &tab_contents_->controller()) { 131 if (source_controller == &tab_contents_->controller()) {
133 NavigationController::LoadCommittedDetails* commit_details = 132 NavigationController::LoadCommittedDetails* commit_details =
134 Details<NavigationController::LoadCommittedDetails>(details).ptr(); 133 Details<NavigationController::LoadCommittedDetails>(details).ptr();
135 PageTransition::Type transition_type = 134 PageTransition::Type transition_type =
136 commit_details->entry->transition_type(); 135 commit_details->entry->transition_type();
137 // We hide the FindInPage window when the user navigates away, except on 136 // We hide the FindInPage window when the user navigates away, except on
138 // reload. 137 // reload.
139 if (find_bar_->IsFindBarVisible()) { 138 if (find_bar_->IsFindBarVisible()) {
140 if (PageTransition::StripQualifier(transition_type) != 139 if (PageTransition::StripQualifier(transition_type) !=
141 PageTransition::RELOAD) { 140 PageTransition::RELOAD) {
142 EndFindSession(); 141 EndFindSession(kKeepSelection);
143 } else { 142 } else {
144 // On Reload we want to make sure FindNext is converted to a full Find 143 // On Reload we want to make sure FindNext is converted to a full Find
145 // to make sure highlights for inactive matches are repainted. 144 // to make sure highlights for inactive matches are repainted.
146 tab_contents_->set_find_op_aborted(true); 145 tab_contents_->set_find_op_aborted(true);
147 } 146 }
148 } 147 }
149 } 148 }
150 } 149 }
151 } 150 }
152 151
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (find_result.number_of_matches() > -1) { 202 if (find_result.number_of_matches() > -1) {
204 if (last_reported_matchcount_ > 0 && 203 if (last_reported_matchcount_ > 0 &&
205 find_result.number_of_matches() == 1 && 204 find_result.number_of_matches() == 1 &&
206 !find_result.final_update()) 205 !find_result.final_update())
207 return; // Don't let interim result override match count. 206 return; // Don't let interim result override match count.
208 last_reported_matchcount_ = find_result.number_of_matches(); 207 last_reported_matchcount_ = find_result.number_of_matches();
209 } 208 }
210 209
211 find_bar_->UpdateUIForFindResult(find_result, tab_contents_->find_text()); 210 find_bar_->UpdateUIForFindResult(find_result, tab_contents_->find_text());
212 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/find_bar_controller.h ('k') | chrome/browser/find_bar_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698