diff options
author | vasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-26 12:42:09 +0000 |
---|---|---|
committer | vasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-26 12:42:09 +0000 |
commit | c08433271bb53515c7ebb4a83171eac63bef1283 (patch) | |
tree | 04ab51b51da080c302933cdaf34e164ee537d1b5 /chrome/browser/ui | |
parent | d692a7c804728a3b83bfe8c40d10d95a6e30cace (diff) | |
download | chromium_src-c08433271bb53515c7ebb4a83171eac63bef1283.zip chromium_src-c08433271bb53515c7ebb4a83171eac63bef1283.tar.gz chromium_src-c08433271bb53515c7ebb4a83171eac63bef1283.tar.bz2 |
This is a follow-up to https://chromiumcodereview.appspot.com/16305010/. To eradicate the discrepancy between find bar text and actual search term we'll always search for current find bar text on Mac. This is correct because find bar updates itself whenever the find pboard changes.
The test strengthened to reproduce the bug.
BUG=272291
TBR=estade@chromium.org
Review URL: https://chromiumcodereview.appspot.com/22796022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/browser_commands.cc | 17 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm | 8 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_bar.h | 6 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_bar_host_browsertest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/find_bar_gtk.cc | 10 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/find_bar_gtk.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/find_bar_host.cc | 8 | ||||
-rw-r--r-- | chrome/browser/ui/views/find_bar_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/find_bar_host_interactive_uitest.cc | 3 |
10 files changed, 33 insertions, 33 deletions
diff --git a/chrome/browser/ui/browser_commands.cc b/chrome/browser/ui/browser_commands.cc index 46ce8f1..48c7076 100644 --- a/chrome/browser/ui/browser_commands.cc +++ b/chrome/browser/ui/browser_commands.cc @@ -41,6 +41,7 @@ #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/chrome_pages.h" +#include "chrome/browser/ui/find_bar/find_bar.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" @@ -71,10 +72,6 @@ #include "net/base/escape.h" #include "webkit/common/user_agent/user_agent_util.h" -#if defined(OS_MACOSX) -#include "ui/base/cocoa/find_pasteboard.h" -#endif - #if defined(OS_WIN) #include "chrome/browser/ui/metro_pin_tab_helper_win.h" #include "win8/util/win8_util.h" @@ -829,12 +826,12 @@ void FindInPage(Browser* browser, bool find_next, bool forward_direction) { FindTabHelper* find_helper = FindTabHelper::FromWebContents( browser->tab_strip_model()->GetActiveWebContents()); #if defined(OS_MACOSX) - // We always want to search for the contents of the find pasteboard on OS X. - // But Incognito window doesn't write to the find pboard. Therefore, its own - // find text has higher priority. - if (!browser->profile()->IsOffTheRecord() || - find_helper->find_text().empty()) - find_text = GetFindPboardText(); + // We always want to search for the current contents of the find bar on + // OS X. For regular profile it's always the current find pboard. For + // Incognito window it's the newest value of the find pboard content and + // user-typed text. + FindBar* find_bar = browser->GetFindBarController()->find_bar(); + find_text = find_bar->GetFindText(); #endif find_helper->StartFinding(find_text, forward_direction, false); } diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h index 1a3b60a..9a50da8 100644 --- a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h +++ b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h @@ -59,6 +59,7 @@ class FindBarBridge : public FindBar, virtual void ClearResults(const FindNotificationDetails& results) OVERRIDE; virtual void StopAnimation() OVERRIDE; virtual void SetFindText(const string16& find_text) OVERRIDE; + virtual string16 GetFindText() OVERRIDE; virtual void UpdateUIForFindResult(const FindNotificationDetails& result, const string16& find_text) OVERRIDE; virtual void AudibleAlert() OVERRIDE; @@ -72,7 +73,6 @@ class FindBarBridge : public FindBar, // Methods from FindBarTesting. virtual bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) OVERRIDE; - virtual string16 GetFindText() OVERRIDE; virtual string16 GetFindSelectedText() OVERRIDE; virtual string16 GetMatchCountText() OVERRIDE; virtual int GetWidth() OVERRIDE; diff --git a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm index 1e0e184..a33fbd3 100644 --- a/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm +++ b/chrome/browser/ui/cocoa/find_bar/find_bar_bridge.mm @@ -56,6 +56,10 @@ void FindBarBridge::SetFindText(const string16& find_text) { [cocoa_controller_ setFindText:base::SysUTF16ToNSString(find_text)]; } +string16 FindBarBridge::GetFindText() { + return base::SysNSStringToUTF16([cocoa_controller_ findText]); +} + void FindBarBridge::UpdateUIForFindResult(const FindNotificationDetails& result, const string16& find_text) { [cocoa_controller_ updateUIForFindResult:result withText:find_text]; @@ -109,10 +113,6 @@ bool FindBarBridge::GetFindBarWindowInfo(gfx::Point* position, return window_visible; } -string16 FindBarBridge::GetFindText() { - return base::SysNSStringToUTF16([cocoa_controller_ findText]); -} - string16 FindBarBridge::GetFindSelectedText() { // This function is currently only used in Views. NOTIMPLEMENTED(); diff --git a/chrome/browser/ui/find_bar/find_bar.h b/chrome/browser/ui/find_bar/find_bar.h index e34b62a..5ca9231 100644 --- a/chrome/browser/ui/find_bar/find_bar.h +++ b/chrome/browser/ui/find_bar/find_bar.h @@ -55,6 +55,9 @@ class FindBar { // Set the text in the find box. virtual void SetFindText(const string16& find_text) = 0; + // Gets the search string currently visible in the find box. + virtual string16 GetFindText() = 0; + // Updates the FindBar with the find result details contained within the // specified |result|. virtual void UpdateUIForFindResult(const FindNotificationDetails& result, @@ -93,9 +96,6 @@ class FindBarTesting { virtual bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) = 0; - // Gets the search string currently visible in the Find box. - virtual string16 GetFindText() = 0; - // Gets the search string currently selected in the Find box. virtual string16 GetFindSelectedText() = 0; 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 103960c..2ceeb88 100644 --- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc +++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc @@ -91,8 +91,7 @@ class FindInPageControllerTest : public InProcessBrowserTest { } string16 GetFindBarTextForBrowser(Browser* browser) { - FindBarTesting* find_bar = - browser->GetFindBarController()->find_bar()->GetFindBarTesting(); + FindBar* find_bar = browser->GetFindBarController()->find_bar(); return find_bar->GetFindText(); } @@ -1568,6 +1567,11 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, IncognitoFindNextSecret) { EXPECT_EQ(ASCIIToUTF16("1 of 2"), GetFindBarMatchCountTextForBrowser(browser_incognito)); + // Close the find bar. + FindTabHelper* find_tab_helper = + FindTabHelper::FromWebContents(web_contents_incognito); + find_tab_helper->StopFinding(FindBarController::kActivateSelectionOnPage); + // Cmd + G triggers IDC_FIND_NEXT command. Thus we test FindInPage() // method from browser_commands.cc. FindInPageWchar() bypasses it. EXPECT_TRUE(chrome::ExecuteCommand(browser_incognito, IDC_FIND_NEXT)); diff --git a/chrome/browser/ui/gtk/find_bar_gtk.cc b/chrome/browser/ui/gtk/find_bar_gtk.cc index ba9071c..9f512f9 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.cc +++ b/chrome/browser/ui/gtk/find_bar_gtk.cc @@ -377,6 +377,11 @@ void FindBarGtk::SetFindText(const string16& find_text) { ignore_changed_signal_ = false; } +string16 FindBarGtk::GetFindText() { + std::string contents(gtk_entry_get_text(GTK_ENTRY(text_entry_))); + return UTF8ToUTF16(contents); +} + void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result, const string16& find_text) { selection_rect_ = result.selection_rect(); @@ -572,11 +577,6 @@ bool FindBarGtk::GetFindBarWindowInfo(gfx::Point* position, return true; } -string16 FindBarGtk::GetFindText() { - std::string contents(gtk_entry_get_text(GTK_ENTRY(text_entry_))); - return UTF8ToUTF16(contents); -} - string16 FindBarGtk::GetFindSelectedText() { gint cursor_pos; gint selection_bound; diff --git a/chrome/browser/ui/gtk/find_bar_gtk.h b/chrome/browser/ui/gtk/find_bar_gtk.h index 2c90616..11973c6 100644 --- a/chrome/browser/ui/gtk/find_bar_gtk.h +++ b/chrome/browser/ui/gtk/find_bar_gtk.h @@ -51,6 +51,7 @@ class FindBarGtk : public FindBar, virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect, bool no_redraw) OVERRIDE; virtual void SetFindText(const string16& find_text) OVERRIDE; + virtual string16 GetFindText() OVERRIDE; virtual void UpdateUIForFindResult(const FindNotificationDetails& result, const string16& find_text) OVERRIDE; virtual void AudibleAlert() OVERRIDE; @@ -63,7 +64,6 @@ class FindBarGtk : public FindBar, // Methods from FindBarTesting. virtual bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) OVERRIDE; - virtual string16 GetFindText() OVERRIDE; virtual string16 GetFindSelectedText() OVERRIDE; virtual string16 GetMatchCountText() OVERRIDE; virtual int GetWidth() OVERRIDE; diff --git a/chrome/browser/ui/views/find_bar_host.cc b/chrome/browser/ui/views/find_bar_host.cc index a369196..3f7233a 100644 --- a/chrome/browser/ui/views/find_bar_host.cc +++ b/chrome/browser/ui/views/find_bar_host.cc @@ -134,6 +134,10 @@ void FindBarHost::SetFindText(const string16& find_text) { find_bar_view()->SetFindText(find_text); } +string16 FindBarHost::GetFindText() { + return find_bar_view()->GetFindText(); +} + void FindBarHost::UpdateUIForFindResult(const FindNotificationDetails& result, const string16& find_text) { // Make sure match count is clear. It may get set again in UpdateForResult @@ -235,10 +239,6 @@ bool FindBarHost::GetFindBarWindowInfo(gfx::Point* position, return true; } -string16 FindBarHost::GetFindText() { - return find_bar_view()->GetFindText(); -} - string16 FindBarHost::GetFindSelectedText() { return find_bar_view()->GetFindSelectedText(); } diff --git a/chrome/browser/ui/views/find_bar_host.h b/chrome/browser/ui/views/find_bar_host.h index 5781f55..ad6595e 100644 --- a/chrome/browser/ui/views/find_bar_host.h +++ b/chrome/browser/ui/views/find_bar_host.h @@ -57,6 +57,7 @@ class FindBarHost : public DropdownBarHost, virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect, bool no_redraw) OVERRIDE; virtual void SetFindText(const string16& find_text) OVERRIDE; + virtual string16 GetFindText() OVERRIDE; virtual void UpdateUIForFindResult(const FindNotificationDetails& result, const string16& find_text) OVERRIDE; virtual void AudibleAlert() OVERRIDE; @@ -73,7 +74,6 @@ class FindBarHost : public DropdownBarHost, // FindBarTesting implementation: virtual bool GetFindBarWindowInfo(gfx::Point* position, bool* fully_visible) OVERRIDE; - virtual string16 GetFindText() OVERRIDE; virtual string16 GetFindSelectedText() OVERRIDE; virtual string16 GetMatchCountText() OVERRIDE; virtual int GetWidth() OVERRIDE; 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 11103c1..251ed6d 100644 --- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc @@ -39,8 +39,7 @@ class FindInPageTest : public InProcessBrowserTest { } string16 GetFindBarText() { - FindBarTesting* find_bar = - browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); + FindBar* find_bar = browser()->GetFindBarController()->find_bar(); return find_bar->GetFindText(); } |