Skip to content

Commit

Permalink
Close the find bar when we reloads the page or we navigate to new page.
Browse files Browse the repository at this point in the history
As we are reloading the page then it should reset context and find bar should get disappeared.

BUG=19311,410160

Review URL: https://codereview.chromium.org/532143002

Cr-Commit-Position: refs/heads/master@{#293860}
  • Loading branch information
deepak.m1 authored and Commit bot committed Sep 9, 2014
1 parent 79359ce commit c13b604
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Daniel Trebbien <dtrebbien@gmail.com>
David Benjamin <davidben@mit.edu>
David Erceg <erceg.david@gmail.com>
David Futcher <david.mike.futcher@gmail.com>
Deepak Mittal <deepak.m1@samsung.com>
Deepak Singla <deepak.sa@samsung.com>
Derek Halman <d.halman@gmail.com>
Devlin Cronin <rdevlin.cronin@gmail.com>
Expand Down
22 changes: 6 additions & 16 deletions chrome/browser/ui/find_bar/find_bar_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,12 @@ void FindBarController::Observe(int type,
content::Details<content::LoadCommittedDetails>(details).ptr();
content::PageTransition transition_type =
commit_details->entry->GetTransitionType();
// We hide the FindInPage window when the user navigates away, except on
// reload (and when clicking on anchors within web pages).
if (find_bar_->IsFindBarVisible()) {
if (content::PageTransitionStripQualifier(transition_type) !=
content::PAGE_TRANSITION_RELOAD) {
// This is a new navigation (not reload), but we still don't want the
// Find box to disappear if the navigation is just to a fragment
// within the page.
if (commit_details->is_navigation_to_different_page())
EndFindSession(kKeepSelectionOnPage, kClearResultsInFindBox);
} else {
// On Reload we want to make sure FindNext is converted to a full Find
// to make sure highlights for inactive matches are repainted.
find_tab_helper->set_find_op_aborted(true);
}
}
// Hide the find bar on reload or navigation.
if (find_bar_->IsFindBarVisible() &&
(content::PageTransitionStripQualifier(transition_type) ==
content::PAGE_TRANSITION_RELOAD ||
commit_details->is_navigation_to_different_page()))
EndFindSession(kKeepSelectionOnPage, kClearResultsInFindBox);
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,9 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_EQ(1, ordinal);
}

IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
// Verify that the find bar is hidden on reload and navigation.
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
HideFindBarOnNavigateAndReload) {
// First we navigate to our special focus tracking page.
GURL url = GetURL(kSimple);
GURL url2 = GetURL(kFramePage);
Expand All @@ -854,19 +856,25 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
EXPECT_TRUE(fully_visible);

// Reload the tab and make sure Find window doesn't go away.
// Reload and make sure the find window goes away.
content::WindowedNotificationObserver observer(
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&browser()->tab_strip_model()->GetActiveWebContents()->
GetController()));
chrome::Reload(browser(), CURRENT_TAB);
observer.Wait();
EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
EXPECT_FALSE(fully_visible);

// Open the find bar again.
chrome::ShowFindBar(browser());

// Make sure it is open.
EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
EXPECT_TRUE(fully_visible);

// Navigate and make sure the Find window goes away.
// Navigate and make sure the find window goes away.
ui_test_utils::NavigateToURL(browser(), url2);

EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
Expand Down

0 comments on commit c13b604

Please sign in to comment.