summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_init.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-09 04:41:30 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-09 04:41:30 +0000
commit19f90bb2135c2094b4a0c9898f3e98ef4ac1a07b (patch)
treea65777b85ff7818ec19b2469a2bdfffd3bbcf3d5 /chrome/browser/browser_init.cc
parent99dbb4b5b1ec5edeb69551febe99eed097c3f995 (diff)
downloadchromium_src-19f90bb2135c2094b4a0c9898f3e98ef4ac1a07b.zip
chromium_src-19f90bb2135c2094b4a0c9898f3e98ef4ac1a07b.tar.gz
chromium_src-19f90bb2135c2094b4a0c9898f3e98ef4ac1a07b.tar.bz2
There was a potential race when showing the default browser info-bar on star-up,
between the info-bar showing and the first navigation. If the first navigation was committed after the bar had been shown, the bar would hide (as it is supposed to hide on navigation). This CL makes the bar linger for few seconds before it is hidden on the next navigation. BUG=11427 TEST=Have a test server that blocks for few seconds before serving a page. Make that your home page (or set "sessino restore" and make that page your last visited page). Make sure Chrome is not the default browser. Start Chrome, the info-bar should appear and stay around. After few seconds have elapsed, navigating to another page should cause the info-bar to disappear. TBR=ben Review URL: http://codereview.chromium.org/113177 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_init.cc')
-rw-r--r--chrome/browser/browser_init.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 5488ef6..d52e683 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -74,7 +74,20 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
explicit DefaultBrowserInfoBarDelegate(TabContents* contents)
: ConfirmInfoBarDelegate(contents),
profile_(contents->profile()),
- action_taken_(false) {
+ action_taken_(false),
+ should_expire_(false),
+ method_factory_(this) {
+ // We want the info-bar to stick-around for few seconds and then be hidden
+ // on the next navigation after that.
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ method_factory_.NewRunnableMethod(
+ &DefaultBrowserInfoBarDelegate::Expire),
+ 8000); // 8 seconds.
+ }
+
+ virtual bool ShouldExpire(
+ const NavigationController::LoadCommittedDetails& details) const {
+ return should_expire_;
}
// Overridden from ConfirmInfoBarDelegate:
@@ -119,6 +132,10 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
return true;
}
+ void Expire() {
+ should_expire_ = true;
+ }
+
private:
// The Profile that we restore sessions from.
Profile* profile_;
@@ -126,6 +143,12 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate {
// Whether the user clicked one of the buttons.
bool action_taken_;
+ // Whether the info-bar should be dismissed on the next navigation.
+ bool should_expire_;
+
+ // Used to delay the expiration of the info-bar.
+ ScopedRunnableMethodFactory<DefaultBrowserInfoBarDelegate> method_factory_;
+
DISALLOW_COPY_AND_ASSIGN(DefaultBrowserInfoBarDelegate);
};