summaryrefslogtreecommitdiffstats
path: root/chrome/browser/translate
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 06:51:15 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 06:51:15 +0000
commitc7e136fc8a564f1a30ef6214e4f2b5d598cfbe94 (patch)
tree147504d5e33aabc8c91d3be94ddec28f13eaead5 /chrome/browser/translate
parentbd209fefecce23870a49ad6e848625f6eee7e66c (diff)
downloadchromium_src-c7e136fc8a564f1a30ef6214e4f2b5d598cfbe94.zip
chromium_src-c7e136fc8a564f1a30ef6214e4f2b5d598cfbe94.tar.gz
chromium_src-c7e136fc8a564f1a30ef6214e4f2b5d598cfbe94.tar.bz2
Hide translate infobar on programmatic navigation.
In Google news, you can change the UI language through a popup menu [which does so by submitting a form programmatically]. The translation infobar wasn't being refreshed in this situation because the page navigation being performed is programmatic. Infobar hiding on navigation, goes through TabContents::ExpireInfoBars() which has an early return if the navigation just performed wasn't initiated by the user. After this, the code loops through the list of infobars and calls ShouldExpire() on each one to determine if it can be closed. This CL removes the early return and moves the code to determine dismissal to the ShouldExpire() method of the infobar delegates, thus allowing the translate infobar to indicate that it can be dismissed on page navigation. BUG=70261 TEST=See bug. Review URL: http://codereview.chromium.org/6883299 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85731 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/translate')
-rw-r--r--chrome/browser/translate/translate_infobar_delegate.cc10
-rw-r--r--chrome/browser/translate/translate_infobar_delegate.h4
-rw-r--r--chrome/browser/translate/translate_manager_browsertest.cc7
3 files changed, 13 insertions, 8 deletions
diff --git a/chrome/browser/translate/translate_infobar_delegate.cc b/chrome/browser/translate/translate_infobar_delegate.cc
index 3c39bce..76e6a4b 100644
--- a/chrome/browser/translate/translate_infobar_delegate.cc
+++ b/chrome/browser/translate/translate_infobar_delegate.cc
@@ -353,6 +353,16 @@ TranslateInfoBarDelegate::TranslateInfoBarDelegate(
}
}
+bool TranslateInfoBarDelegate::ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const {
+ // Note: we allow closing this infobar even if the main frame navigation
+ // was programmatic and not initiated by the user - crbug.com/70261 .
+ if (!details.is_user_initiated_main_frame_load() && !details.is_main_frame)
+ return false;
+
+ return InfoBarDelegate::ShouldExpireInternal(details);
+}
+
void TranslateInfoBarDelegate::InfoBarDismissed() {
if (type_ != BEFORE_TRANSLATE)
return;
diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h
index 03c196e..4ba31e6 100644
--- a/chrome/browser/translate/translate_infobar_delegate.h
+++ b/chrome/browser/translate/translate_infobar_delegate.h
@@ -9,7 +9,7 @@
#include <string>
#include <vector>
-#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
+#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/translate/translate_prefs.h"
#include "chrome/common/translate_errors.h"
@@ -163,6 +163,8 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
virtual void InfoBarDismissed() OVERRIDE;
virtual gfx::Image* GetIcon() const OVERRIDE;
virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE;
+ virtual bool ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const;
virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE;
// Gets the host of the page being translated, or an empty string if no URL is
diff --git a/chrome/browser/translate/translate_manager_browsertest.cc b/chrome/browser/translate/translate_manager_browsertest.cc
index 797b2c6..e6da867 100644
--- a/chrome/browser/translate/translate_manager_browsertest.cc
+++ b/chrome/browser/translate/translate_manager_browsertest.cc
@@ -722,13 +722,6 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
- // Navigate in page, the same infobar should still be shown.
- ClearRemovedInfoBars();
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), "fr",
- true);
- EXPECT_FALSE(InfoBarRemoved());
- EXPECT_EQ(infobar, GetTranslateInfoBar());
-
// Navigate out of page, a new infobar should show.
// See note in TranslateCloseInfoBarInPageNavigation test on why it is
// important to navigate to a page in a different language for this test.