OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/upgrade_detector.h" | 5 #include "chrome/browser/upgrade_detector.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 scoped_ptr<Version> installed_version( | 95 scoped_ptr<Version> installed_version( |
96 Version::GetVersionFromString(ASCIIToUTF16(reply))); | 96 Version::GetVersionFromString(ASCIIToUTF16(reply))); |
97 #endif | 97 #endif |
98 | 98 |
99 // Get the version of the currently *running* instance of Chrome. | 99 // Get the version of the currently *running* instance of Chrome. |
100 scoped_ptr<FileVersionInfo> version(chrome_app::GetChromeVersionInfo()); | 100 scoped_ptr<FileVersionInfo> version(chrome_app::GetChromeVersionInfo()); |
101 if (version.get() == NULL) { | 101 if (version.get() == NULL) { |
102 NOTREACHED() << "Failed to get current file version"; | 102 NOTREACHED() << "Failed to get current file version"; |
103 return; | 103 return; |
104 } | 104 } |
105 scoped_ptr<Version> running_version(Version::GetVersionFromString( | |
106 WideToUTF16(version->file_version()))); | |
107 | 105 |
108 if (installed_version->IsHigherThan(running_version.get())) { | 106 scoped_ptr<Version> running_version( |
| 107 Version::GetVersionFromString(WideToUTF16(version->file_version()))); |
| 108 if (running_version.get() == NULL) { |
| 109 NOTREACHED() << "Failed to parse version info"; |
| 110 return; |
| 111 } |
| 112 |
| 113 // |installed_version| may be NULL when the user downgrades on Linux (by |
| 114 // switching from dev to beta channel, for example). The user needs a |
| 115 // restart in this case as well. See http://crbug.com/46547 |
| 116 if (!installed_version.get() || |
| 117 installed_version->IsHigherThan(running_version.get())) { |
109 ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, | 118 ChromeThread::PostTask(ChromeThread::UI, FROM_HERE, |
110 upgrade_detected_task_); | 119 upgrade_detected_task_); |
111 upgrade_detected_task_ = NULL; | 120 upgrade_detected_task_ = NULL; |
112 } | 121 } |
113 #else // !(defined(OS_WIN) || defined(OS_LINUX)) | 122 #else // !(defined(OS_WIN) || defined(OS_LINUX)) |
114 DCHECK(kNotifyUserAfterMs >= 0); // Avoid error: var defined but not used. | 123 DCHECK(kNotifyUserAfterMs >= 0); // Avoid error: var defined but not used. |
115 NOTIMPLEMENTED(); | 124 NOTIMPLEMENTED(); |
116 #endif | 125 #endif |
117 } | 126 } |
118 | 127 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 177 } |
169 | 178 |
170 void UpgradeDetector::NotifyOnUpgrade() { | 179 void UpgradeDetector::NotifyOnUpgrade() { |
171 notify_upgrade_ = true; | 180 notify_upgrade_ = true; |
172 | 181 |
173 NotificationService::current()->Notify( | 182 NotificationService::current()->Notify( |
174 NotificationType::UPGRADE_RECOMMENDED, | 183 NotificationType::UPGRADE_RECOMMENDED, |
175 Source<UpgradeDetector>(this), | 184 Source<UpgradeDetector>(this), |
176 NotificationService::NoDetails()); | 185 NotificationService::NoDetails()); |
177 } | 186 } |
OLD | NEW |