Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7621)

Unified Diff: chrome/browser/upgrade_detector.cc

Issue 3032001: Make UpgradeDetector work on the Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/keystone_glue.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/upgrade_detector.cc
===================================================================
--- chrome/browser/upgrade_detector.cc (revision 52487)
+++ chrome/browser/upgrade_detector.cc (working copy)
@@ -22,7 +22,9 @@
#if defined(OS_WIN)
#include "chrome/installer/util/install_util.h"
-#elif defined(OS_LINUX)
+#elif defined(OS_MACOSX)
+#include "chrome/browser/cocoa/keystone_glue.h"
+#elif defined(OS_POSIX)
#include "base/process_util.h"
#include "chrome/installer/util/version.h"
#endif
@@ -43,9 +45,10 @@
// The thread to run the upgrade detection code on. We use FILE for Linux
// because we don't want to block the UI thread while launching a background
-// process and reading its output.
+// process and reading its output; on the Mac, checking for an upgrade
+// requires reading a file.
const ChromeThread::ID kDetectUpgradeTaskID =
-#if defined(OS_LINUX)
+#if defined(OS_POSIX)
ChromeThread::FILE;
#else
ChromeThread::UI;
@@ -71,19 +74,24 @@
virtual void Run() {
DCHECK(ChromeThread::CurrentlyOn(kDetectUpgradeTaskID));
-#if defined(OS_WIN) || defined(OS_LINUX)
using installer::Version;
+ scoped_ptr<Version> installed_version;
#if defined(OS_WIN)
// Get the version of the currently *installed* instance of Chrome,
// which might be newer than the *running* instance if we have been
// upgraded in the background.
- scoped_ptr<Version> installed_version(InstallUtil::GetChromeVersion(false));
+ installed_version.reset(InstallUtil::GetChromeVersion(false));
if (!installed_version.get()) {
// User level Chrome is not installed, check system level.
installed_version.reset(InstallUtil::GetChromeVersion(true));
}
-#elif defined(OS_LINUX)
+#elif defined(OS_MACOSX)
+ installed_version.reset(
+ Version::GetVersionFromString(
+ keystone_glue::CurrentlyInstalledVersion()));
+#elif defined(OS_POSIX)
+ // POSIX but not Mac OS X: Linux, etc.
CommandLine command_line(*CommandLine::ForCurrentProcess());
command_line.AppendSwitch(switches::kProductVersion);
std::string reply;
@@ -92,8 +100,7 @@
return;
}
- scoped_ptr<Version> installed_version(
- Version::GetVersionFromString(ASCIIToUTF16(reply)));
+ installed_version.reset(Version::GetVersionFromString(ASCIIToUTF16(reply)));
#endif
// Get the version of the currently *running* instance of Chrome.
@@ -119,10 +126,6 @@
upgrade_detected_task_);
upgrade_detected_task_ = NULL;
}
-#else // !(defined(OS_WIN) || defined(OS_LINUX))
- DCHECK(kNotifyUserAfterMs >= 0); // Avoid error: var defined but not used.
- NOTIMPLEMENTED();
-#endif
}
private:
@@ -139,13 +142,19 @@
UpgradeDetector::UpgradeDetector()
: ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
notify_upgrade_(false) {
- // Upgrade notifications work on Windows (only Google Chrome) and Linux
- // (chromium and Google Chrome).
-#if (defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)) || defined(OS_LINUX)
- detect_upgrade_timer_.Start(
- base::TimeDelta::FromMilliseconds(kCheckForUpgradeEveryMs),
- this, &UpgradeDetector::CheckForUpgrade);
+ // Windows: only enable upgrade notifications for official builds.
+ // Mac: only enable them if the updater (Keystone) is present.
+ // Linux (and other POSIX): always enable regardless of branding.
+#if (defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)) || defined(OS_POSIX)
+#if defined(OS_MACOSX)
+ if (keystone_glue::KeystoneEnabled())
#endif
+ {
+ detect_upgrade_timer_.Start(
+ base::TimeDelta::FromMilliseconds(kCheckForUpgradeEveryMs),
+ this, &UpgradeDetector::CheckForUpgrade);
+ }
+#endif
}
UpgradeDetector::~UpgradeDetector() {
« no previous file with comments | « chrome/browser/cocoa/keystone_glue.mm ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698