summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 09:02:28 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 09:02:28 +0000
commite8dd34d01fdb366d9b72c4f9a43fd8152bcf4fe0 (patch)
tree9cc2a3748e5ab40e0633dd5d2af1dc8840140f58
parent4315edf26260ee4b05d0170e890ef017615f3b71 (diff)
downloadchromium_src-e8dd34d01fdb366d9b72c4f9a43fd8152bcf4fe0.zip
chromium_src-e8dd34d01fdb366d9b72c4f9a43fd8152bcf4fe0.tar.gz
chromium_src-e8dd34d01fdb366d9b72c4f9a43fd8152bcf4fe0.tar.bz2
Change the EndSession param from bool to an enum to improve readability.
BUG=126468 TEST=None, should be no functional change and relying on already active automated tests. Review URL: https://chromiumcodereview.appspot.com/10356072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136266 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm10
-rw-r--r--chrome/browser/ui/find_bar/find_bar_controller.cc10
-rw-r--r--chrome/browser/ui/find_bar/find_bar_controller.h26
-rw-r--r--chrome/browser/ui/find_bar/find_bar_host_browsertest.cc35
-rw-r--r--chrome/browser/ui/find_bar/find_tab_helper.cc8
-rw-r--r--chrome/browser/ui/gtk/find_bar_gtk.cc13
-rw-r--r--chrome/browser/ui/views/find_bar_host.cc10
-rw-r--r--chrome/browser/ui/views/find_bar_host_interactive_uitest.cc9
-rw-r--r--chrome/browser/ui/views/find_bar_view.cc5
9 files changed, 78 insertions, 48 deletions
diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm b/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm
index 04ec51b..858a220 100644
--- a/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm
+++ b/chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm
@@ -103,7 +103,8 @@ const float kRightEdgeOffset = 25;
- (IBAction)close:(id)sender {
if (findBarBridge_)
findBarBridge_->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
}
- (IBAction)previousResult:(id)sender {
@@ -181,7 +182,7 @@ const float kRightEdgeOffset = 25;
StartFinding(base::SysNSStringToUTF16(findText), true, false);
} else {
// The textbox is empty so we reset.
- find_tab_helper->StopFinding(FindBarController::kClearSelection);
+ find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage);
[self updateUIForFindResult:find_tab_helper->find_result()
withText:string16()];
}
@@ -205,7 +206,8 @@ const float kRightEdgeOffset = 25;
// Pressing Ctrl-Return
if (findBarBridge_) {
findBarBridge_->GetFindBarController()->EndFindSession(
- FindBarController::kActivateSelection, false);
+ FindBarController::kActivateSelectionOnPage,
+ FindBarController::kClearResultsInFindBox);
}
return YES;
} else if (command == @selector(pageUp:) ||
@@ -528,7 +530,7 @@ const float kRightEdgeOffset = 25;
findBarBridge_->GetFindBarController()->tab_contents();
if (contents) {
FindTabHelper* find_tab_helper = contents->find_tab_helper();
- find_tab_helper->StopFinding(FindBarController::kClearSelection);
+ find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage);
findBarBridge_->ClearResults(find_tab_helper->find_result());
}
}
diff --git a/chrome/browser/ui/find_bar/find_bar_controller.cc b/chrome/browser/ui/find_bar/find_bar_controller.cc
index aaea22d..5be152c 100644
--- a/chrome/browser/ui/find_bar/find_bar_controller.cc
+++ b/chrome/browser/ui/find_bar/find_bar_controller.cc
@@ -51,8 +51,8 @@ void FindBarController::Show() {
find_bar_->SetFocusAndSelection();
}
-void FindBarController::EndFindSession(SelectionAction action,
- bool force_clear) {
+void FindBarController::EndFindSession(SelectionAction selection_action,
+ ResultAction result_action) {
find_bar_->Hide(true);
// |tab_contents_| can be NULL for a number of reasons, for example when the
@@ -63,9 +63,9 @@ void FindBarController::EndFindSession(SelectionAction action,
// When we hide the window, we need to notify the renderer that we are done
// for now, so that we can abort the scoping effort and clear all the
// tickmarks and highlighting.
- find_tab_helper->StopFinding(action);
+ find_tab_helper->StopFinding(selection_action);
- if (action != kKeepSelection || force_clear)
+ if (result_action == kClearResultsInFindBox)
find_bar_->ClearResults(find_tab_helper->find_result());
// When we get dismissed we restore the focus to where it belongs.
@@ -152,7 +152,7 @@ void FindBarController::Observe(int type,
// Find box to disappear if the navigation is just to a fragment
// within the page.
if (commit_details->is_navigation_to_different_page())
- EndFindSession(kKeepSelection, true);
+ 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.
diff --git a/chrome/browser/ui/find_bar/find_bar_controller.h b/chrome/browser/ui/find_bar/find_bar_controller.h
index 6580718..566618b 100644
--- a/chrome/browser/ui/find_bar/find_bar_controller.h
+++ b/chrome/browser/ui/find_bar/find_bar_controller.h
@@ -20,11 +20,20 @@ class TabContentsWrapper;
class FindBarController : public content::NotificationObserver {
public:
- // An enum listing the possible actions to take on a find-in-page selection.
+ // An enum listing the possible actions to take on a find-in-page selection
+ // in the page when ending the find session.
enum SelectionAction {
- kKeepSelection, // Translate the find selection into a normal selection.
- kClearSelection, // Clear the find selection.
- kActivateSelection // Focus and click the selected node (for links).
+ kKeepSelectionOnPage, // Translate the find selection into a normal
+ // selection.
+ kClearSelectionOnPage, // Clear the find selection.
+ kActivateSelectionOnPage // Focus and click the selected node (for links).
+ };
+
+ // An enum listing the possible actions to take on a find-in-page results in
+ // the Find box when ending the find session.
+ enum ResultAction {
+ kClearResultsInFindBox, // Clear search string, ordinal and match count.
+ kKeepResultsInFindBox, // Leave the results untouched.
};
// FindBar takes ownership of |find_bar_view|.
@@ -35,10 +44,11 @@ class FindBarController : public content::NotificationObserver {
// Shows the find bar. Any previous search string will again be visible.
void Show();
- // Ends the current session. |action| specifies what to do with the selection
- // on the page created by the find operation. |force_clear| specifies whether
- // to clear the ordinal and match count from the Find box UI.
- void EndFindSession(SelectionAction action, bool force_clear);
+ // Ends the current session. |selection_action| specifies what to do with the
+ // selection on the page created by the find operation. |results_action|
+ // specifies what to do with the contents of the Find box (after ending).
+ void EndFindSession(SelectionAction selection_action,
+ ResultAction results_action);
// Accessor for the attached TabContentsWrapper.
TabContentsWrapper* tab_contents() const { return tab_contents_; }
diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
index 33e5ca9..3b14b68 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -288,7 +288,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) {
// End the find session, which should set focus to the link.
tab_contents->
- find_tab_helper()->StopFinding(FindBarController::kKeepSelection);
+ find_tab_helper()->StopFinding(FindBarController::kKeepSelectionOnPage);
// Verify that the link is focused.
ASSERT_TRUE(FocusedOnPage(tab_contents->web_contents(), &result));
@@ -308,7 +308,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) {
// End the find session.
tab_contents->
- find_tab_helper()->StopFinding(FindBarController::kKeepSelection);
+ find_tab_helper()->StopFinding(FindBarController::kKeepSelectionOnPage);
// Verify that link2 is not focused.
ASSERT_TRUE(FocusedOnPage(tab_contents->web_contents(), &result));
@@ -384,7 +384,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_EQ(3, ordinal);
// End the find session.
- tab->find_tab_helper()->StopFinding(FindBarController::kKeepSelection);
+ tab->find_tab_helper()->StopFinding(FindBarController::kKeepSelectionOnPage);
}
// This test loads a page with frames and makes sure the ordinal returned makes
@@ -851,7 +851,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) {
// Close the Find box.
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// The accelerator for Escape should be back to what it was before.
EXPECT_EQ(old_target,
@@ -883,7 +884,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) {
browser()->GetSelectedTabContentsWrapper()->find_tab_helper();
// Stop the (non-existing) find operation, and clear the selection (which
// signals the UI is still active).
- find_tab_helper->StopFinding(FindBarController::kClearSelection);
+ find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage);
// Make sure the Find UI flag hasn't been cleared, it must be so that the UI
// still responds to browser window resizing.
ASSERT_TRUE(find_tab_helper->find_ui_active());
@@ -910,7 +911,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) {
// End the Find session, thereby making the next F3 start afresh.
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Simulate F3 while Find box is closed. Should have 1 match.
EXPECT_EQ(1, FindInPageWchar(tab, L"", kFwd, kIgnoreCase, &ordinal));
@@ -945,7 +947,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) {
// Switch back to first tab.
browser()->ActivateTabAt(0, false);
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Simulate F3.
ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal);
EXPECT_EQ(tab1->find_tab_helper()->find_text(), WideToUTF16(L"text"));
@@ -976,7 +979,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulateSameTab) {
// Close the Find box.
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Open the Find box again.
EnsureFindBoxOpen();
@@ -1046,7 +1050,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) {
// Close the Find box.
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Now create a second tab and load the same page.
browser()->AddBlankTab(true);
@@ -1070,7 +1075,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PrepopulatePreserveLast) {
// Close the Find box.
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Re-open the Find box.
// This is a special case: previous search in WebContents used to get cleared
@@ -1114,7 +1120,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
// Close the Find box.
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Open a new incognito window and navigate to the same page.
Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
@@ -1140,7 +1147,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, MAYBE_NoIncognitoPrepopulate) {
// Close the Find box.
incognito_browser->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
// Now open a new tab in the original (non-incognito) browser.
browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED);
@@ -1169,7 +1177,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) {
content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(
&tab->web_contents()->GetController()));
- tab->find_tab_helper()->StopFinding(FindBarController::kActivateSelection);
+ tab->find_tab_helper()->StopFinding(
+ FindBarController::kActivateSelectionOnPage);
observer.Wait();
}
diff --git a/chrome/browser/ui/find_bar/find_tab_helper.cc b/chrome/browser/ui/find_bar/find_tab_helper.cc
index c0b673a..7b9dee1 100644
--- a/chrome/browser/ui/find_bar/find_tab_helper.cc
+++ b/chrome/browser/ui/find_bar/find_tab_helper.cc
@@ -92,7 +92,7 @@ void FindTabHelper::StartFinding(string16 search_string,
void FindTabHelper::StopFinding(
FindBarController::SelectionAction selection_action) {
- if (selection_action == FindBarController::kClearSelection) {
+ if (selection_action == FindBarController::kClearSelectionOnPage) {
// kClearSelection means the find string has been cleared by the user, but
// the UI has not been dismissed. In that case we want to clear the
// previously remembered search (http://crbug.com/42639).
@@ -108,13 +108,13 @@ void FindTabHelper::StopFinding(
content::StopFindAction action;
switch (selection_action) {
- case FindBarController::kClearSelection:
+ case FindBarController::kClearSelectionOnPage:
action = content::STOP_FIND_ACTION_CLEAR_SELECTION;
break;
- case FindBarController::kKeepSelection:
+ case FindBarController::kKeepSelectionOnPage:
action = content::STOP_FIND_ACTION_KEEP_SELECTION;
break;
- case FindBarController::kActivateSelection:
+ case FindBarController::kActivateSelectionOnPage:
action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
break;
default:
diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc
index 1608ef0..08f2734 100644
--- a/chrome/browser/ui/gtk/find_bar_gtk.cc
+++ b/chrome/browser/ui/gtk/find_bar_gtk.cc
@@ -598,7 +598,7 @@ void FindBarGtk::FindEntryTextInContents(bool forward_search) {
false); // Not case sensitive.
} else {
// The textbox is empty so we reset.
- find_tab_helper->StopFinding(FindBarController::kClearSelection);
+ find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage);
UpdateUIForFindResult(find_tab_helper->find_result(), string16());
// Clearing the text box should also clear the prepopulate state so that
@@ -782,14 +782,16 @@ gboolean FindBarGtk::OnKeyPressEvent(GtkWidget* widget, GdkEventKey* event,
return TRUE;
} else if (GDK_Escape == event->keyval) {
find_bar->find_bar_controller_->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
return TRUE;
} else if (GDK_Return == event->keyval ||
GDK_KP_Enter == event->keyval) {
if ((event->state & gtk_accelerator_get_default_mod_mask()) ==
GDK_CONTROL_MASK) {
find_bar->find_bar_controller_->EndFindSession(
- FindBarController::kActivateSelection, false);
+ FindBarController::kActivateSelectionOnPage,
+ FindBarController::kClearResultsInFindBox);
return TRUE;
}
@@ -809,8 +811,9 @@ gboolean FindBarGtk::OnKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event,
void FindBarGtk::OnClicked(GtkWidget* button) {
if (button == close_button_->widget()) {
- find_bar_controller_->EndFindSession(FindBarController::kKeepSelection,
- false);
+ find_bar_controller_->EndFindSession(
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
} else if (button == find_previous_button_->widget() ||
button == find_next_button_->widget()) {
FindEntryTextInContents(button == find_next_button_->widget());
diff --git a/chrome/browser/ui/views/find_bar_host.cc b/chrome/browser/ui/views/find_bar_host.cc
index a351526..7eb4651 100644
--- a/chrome/browser/ui/views/find_bar_host.cc
+++ b/chrome/browser/ui/views/find_bar_host.cc
@@ -174,15 +174,17 @@ bool FindBarHost::AcceleratorPressed(const ui::Accelerator& accelerator) {
ui::KeyboardCode key = accelerator.key_code();
if (key == ui::VKEY_RETURN && accelerator.IsCtrlDown()) {
// Ctrl+Enter closes the Find session and navigates any link that is active.
- find_bar_controller_->EndFindSession(FindBarController::kActivateSelection,
- false);
+ find_bar_controller_->EndFindSession(
+ FindBarController::kActivateSelectionOnPage,
+ FindBarController::kClearResultsInFindBox);
return true;
} else if (key == ui::VKEY_ESCAPE) {
// This will end the Find session and hide the window, causing it to loose
// focus and in the process unregister us as the handler for the Escape
// accelerator through the OnWillChangeFocus event.
- find_bar_controller_->EndFindSession(FindBarController::kKeepSelection,
- false);
+ find_bar_controller_->EndFindSession(
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
return true;
} else {
NOTREACHED() << "Unknown accelerator";
diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
index 183cba77..822f7f8 100644
--- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc
@@ -120,7 +120,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
@@ -133,7 +134,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
ui_test_utils::FindInPage(browser()->GetSelectedTabContentsWrapper(),
ASCIIToUTF16("a"), true, false, NULL);
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
// Focus the location bar, open and close the find box, focus should return to
@@ -146,7 +148,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) {
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
browser()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
location_bar_focus_view_id_));
}
diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc
index 3845444..8b9b97a 100644
--- a/chrome/browser/ui/views/find_bar_view.cc
+++ b/chrome/browser/ui/views/find_bar_view.cc
@@ -371,7 +371,8 @@ void FindBarView::ButtonPressed(
break;
case CLOSE_TAG:
find_bar_host()->GetFindBarController()->EndFindSession(
- FindBarController::kKeepSelection, false);
+ FindBarController::kKeepSelectionOnPage,
+ FindBarController::kKeepResultsInFindBox);
break;
default:
NOTREACHED() << L"Unknown button";
@@ -401,7 +402,7 @@ void FindBarView::ContentsChanged(views::Textfield* sender,
// The last two params here are forward (true) and case sensitive (false).
find_tab_helper->StartFinding(new_contents, true, false);
} else {
- find_tab_helper->StopFinding(FindBarController::kClearSelection);
+ find_tab_helper->StopFinding(FindBarController::kClearSelectionOnPage);
UpdateForResult(find_tab_helper->find_result(), string16());
find_bar_host()->MoveWindowIfNecessary(gfx::Rect(), false);