summaryrefslogtreecommitdiffstats
path: root/chrome/browser/upgrade_detector.h
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-26 20:11:54 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-26 20:11:54 +0000
commitb1b7394fa3880dab9f9bd0cfc40ea8c614f0b49e (patch)
treed6e9f57d10714b67c4c7fbed0e874d4e337f406e /chrome/browser/upgrade_detector.h
parenta8e4a8fa39604cd309e1e3d62cf9c552dcfe541d (diff)
downloadchromium_src-b1b7394fa3880dab9f9bd0cfc40ea8c614f0b49e.zip
chromium_src-b1b7394fa3880dab9f9bd0cfc40ea8c614f0b49e.tar.gz
chromium_src-b1b7394fa3880dab9f9bd0cfc40ea8c614f0b49e.tar.bz2
Implement upgrade notifications.
When we detect that the installed version is newer than the version you are running we show a little throbbing orange dot over the wrench menu. If you open the wrench menu and close it again, the throbbing will stop. However, if you look at the contents of the wrench menu you'll notice that the About box menu item has been removed and in its place is a menu item "Update Chrome Now" with a bright orange icon to draw your attention to it. Clicking on the icon shows a dialog box asking whether you want to restart Chrome. If you do, the browser restarts with your session restored (even if you have Session Restore turned off). Known issues: - Currently this is Windows only. We'll have to port this to Linux and do something differnet for Mac (which doesn't have the wrench menu). - Showing an icon in front of Update Chrome causes the checkbox for the bookmark bar menu to go away. Given that we will soon redesign the menus I'm not going to spend much time trying to fix it. BUG=27941 TEST=Wait for Chrome to be upgraded in the background, an orange dot should appear over the wrench menu and if you select Update Chrome your session should be retained. Review URL: http://codereview.chromium.org/2225003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/upgrade_detector.h')
-rw-r--r--chrome/browser/upgrade_detector.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome/browser/upgrade_detector.h b/chrome/browser/upgrade_detector.h
new file mode 100644
index 0000000..9a7da11
--- /dev/null
+++ b/chrome/browser/upgrade_detector.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UPGRADE_DETECTOR_H_
+#define CHROME_BROWSER_UPGRADE_DETECTOR_H_
+
+#include "base/singleton.h"
+#include "base/timer.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// UpgradeDetector
+//
+// This class is a singleton class that monitors when an upgrade happens in the
+// background. We basically ask Omaha what it thinks the latest version is and
+// if our version is lower we send out a notification upon:
+// a) Detecting an upgrade and...
+// b) When we think the user should be notified about the upgrade.
+// The latter happens much later, since we don't want to be too annoying.
+//
+class UpgradeDetector {
+ public:
+ ~UpgradeDetector();
+
+ bool notify_upgrade() { return notify_upgrade_; }
+
+ private:
+ UpgradeDetector();
+ friend struct DefaultSingletonTraits<UpgradeDetector>;
+
+ // Checks with Omaha if we have the latest version. If not, sends out a
+ // notification and starts a one shot timer to wait until notifying the
+ // user.
+ void CheckForUpgrade();
+
+ // The function that sends out a notification (after a certain time has
+ // elapsed) that lets the rest of the UI know we should start notifying the
+ // user that a new version is available.
+ void NotifyOnUpgrade();
+
+ // We periodically check to see if Chrome has been upgraded.
+ base::RepeatingTimer<UpgradeDetector> detect_upgrade_timer_;
+
+ // After we detect an upgrade we wait a set time before notifying the user.
+ base::OneShotTimer<UpgradeDetector> upgrade_notification_timer_;
+
+ // Whether we have detected an upgrade happening while we were running.
+ bool upgrade_detected_;
+
+ // Whether we have waited long enough after detecting an upgrade (to see
+ // is we should start nagging about upgrading).
+ bool notify_upgrade_;
+
+ DISALLOW_COPY_AND_ASSIGN(UpgradeDetector);
+};
+
+#endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_