Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/version.h" | 9 #include "base/version.h" |
| 10 #include "base/win/win_util.h" | 10 #include "base/win/win_util.h" |
| 11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
| 12 #include "chrome/browser/google/google_update_win.h" | 12 #include "chrome/browser/google/google_update_win.h" |
| 13 #include "chrome/browser/lifetime/application_lifetime.h" | 13 #include "chrome/browser/lifetime/application_lifetime.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/webui/help/version_updater.h" | 15 #include "chrome/browser/ui/webui/help/version_updater.h" |
| 16 #include "chrome/common/chrome_version_info.h" | 16 #include "chrome/common/chrome_version_info.h" |
| 17 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
| 18 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 19 #include "chrome/installer/util/browser_distribution.h" | 19 #include "chrome/installer/util/browser_distribution.h" |
| 20 #include "chrome/installer/util/install_util.h" | 20 #include "chrome/installer/util/install_util.h" |
| 21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/user_metrics.h" | |
| 23 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 25 | 24 |
| 26 using base::UserMetricsAction; | |
| 27 using content::BrowserThread; | 25 using content::BrowserThread; |
| 28 | 26 |
| 29 namespace { | 27 namespace { |
| 30 | 28 |
| 31 // Windows implementation of version update functionality, used by the WebUI | 29 // Windows implementation of version update functionality, used by the WebUI |
| 32 // About/Help page. | 30 // About/Help page. |
| 33 class VersionUpdaterWin : public VersionUpdater, | 31 class VersionUpdaterWin : public VersionUpdater, |
| 34 public GoogleUpdateStatusListener { | 32 public GoogleUpdateStatusListener { |
| 35 private: | 33 private: |
| 36 friend class VersionReader; | 34 friend class VersionReader; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 const base::string16& error_message) { | 169 const base::string16& error_message) { |
| 172 // For Chromium builds it would show an error message. | 170 // For Chromium builds it would show an error message. |
| 173 // But it looks weird because in fact there is no error, | 171 // But it looks weird because in fact there is no error, |
| 174 // just the update server is not available for non-official builds. | 172 // just the update server is not available for non-official builds. |
| 175 #if defined(GOOGLE_CHROME_BUILD) | 173 #if defined(GOOGLE_CHROME_BUILD) |
| 176 Status status = UPDATED; | 174 Status status = UPDATED; |
| 177 base::string16 message; | 175 base::string16 message; |
| 178 | 176 |
| 179 switch (result) { | 177 switch (result) { |
| 180 case UPGRADE_CHECK_STARTED: { | 178 case UPGRADE_CHECK_STARTED: { |
| 181 content::RecordAction(UserMetricsAction("UpgradeCheck_Started")); | |
| 182 status = CHECKING; | 179 status = CHECKING; |
| 183 break; | 180 break; |
| 184 } | 181 } |
| 185 case UPGRADE_STARTED: { | 182 case UPGRADE_STARTED: { |
| 186 content::RecordAction(UserMetricsAction("Upgrade_Started")); | |
| 187 status = UPDATING; | 183 status = UPDATING; |
| 188 break; | 184 break; |
| 189 } | 185 } |
| 190 case UPGRADE_IS_AVAILABLE: { | 186 case UPGRADE_IS_AVAILABLE: { |
| 191 content::RecordAction( | |
| 192 UserMetricsAction("UpgradeCheck_UpgradeIsAvailable")); | |
| 193 DCHECK(!google_updater_); // Should have been nulled out already. | 187 DCHECK(!google_updater_); // Should have been nulled out already. |
| 194 CreateGoogleUpdater(); | 188 CreateGoogleUpdater(); |
| 195 UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, base::string16()); | 189 UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, base::string16()); |
| 196 // Specify true to upgrade now. | 190 // Specify true to upgrade now. |
| 197 google_updater_->CheckForUpdate(true, GetElevationParent()); | 191 google_updater_->CheckForUpdate(true, GetElevationParent()); |
| 198 return; | 192 return; |
| 199 } | 193 } |
| 200 case UPGRADE_ALREADY_UP_TO_DATE: { | 194 case UPGRADE_ALREADY_UP_TO_DATE: { |
| 201 // Google Update reported that Chrome is up-to-date. | 195 // Google Update reported that Chrome is up-to-date. |
| 202 // To confirm the updated version is running, the reading | 196 // To confirm the updated version is running, the reading |
| 203 // must be done on the file thread. The rest of this case | 197 // must be done on the file thread. The rest of this case |
| 204 // will be handled within GotInstalledVersion. | 198 // will be handled within GotInstalledVersion. |
| 205 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( | 199 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( |
| 206 &VersionReader::GetVersionFromFileThread, | 200 &VersionReader::GetVersionFromFileThread, |
| 207 new VersionReader(weak_factory_.GetWeakPtr()))); | 201 new VersionReader(weak_factory_.GetWeakPtr()))); |
| 208 return; | 202 return; |
| 209 } | 203 } |
| 210 case UPGRADE_SUCCESSFUL: { | 204 case UPGRADE_SUCCESSFUL: { |
| 211 content::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded")); | |
|
Alexei Svitkine (slow)
2014/10/17 19:00:55
Can you mark all these actions as obsolete in acti
grt (UTC plus 2)
2014/10/18 02:37:35
Done for these and for two that don't seem to have
| |
| 212 status = NEARLY_UPDATED; | 205 status = NEARLY_UPDATED; |
| 213 break; | 206 break; |
| 214 } | 207 } |
| 215 case UPGRADE_ERROR: { | 208 case UPGRADE_ERROR: { |
| 216 content::RecordAction(UserMetricsAction("UpgradeCheck_Error")); | |
| 217 status = FAILED; | 209 status = FAILED; |
| 218 if (error_code == GOOGLE_UPDATE_DISABLED_BY_POLICY) { | 210 if (error_code == GOOGLE_UPDATE_DISABLED_BY_POLICY) { |
| 219 message = | 211 message = |
| 220 l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY); | 212 l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY); |
| 221 } else if (error_code == GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY) { | 213 } else if (error_code == GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY) { |
| 222 message = | 214 message = |
| 223 l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY_MANUAL); | 215 l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY_MANUAL); |
| 224 } else { | 216 } else { |
| 225 message = | 217 message = |
| 226 l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code); | 218 l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 246 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 238 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 247 | 239 |
| 248 // Make sure that the latest version is running and if not, | 240 // Make sure that the latest version is running and if not, |
| 249 // notify the user by setting the status to NEARLY_UPDATED. | 241 // notify the user by setting the status to NEARLY_UPDATED. |
| 250 // | 242 // |
| 251 // The extra version check is necessary on Windows because the application | 243 // The extra version check is necessary on Windows because the application |
| 252 // may be already up to date on disk though the running app is still | 244 // may be already up to date on disk though the running app is still |
| 253 // out of date. | 245 // out of date. |
| 254 chrome::VersionInfo version_info; | 246 chrome::VersionInfo version_info; |
| 255 Version running_version(version_info.Version()); | 247 Version running_version(version_info.Version()); |
| 256 if (!version.IsValid() || version.CompareTo(running_version) <= 0) { | 248 Status status = |
| 257 content::RecordAction( | 249 (!version.IsValid() || version.CompareTo(running_version) <= 0) |
| 258 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); | 250 ? UPDATED |
| 259 callback_.Run(UPDATED, 0, base::string16()); | 251 : NEARLY_UPDATED; |
| 260 } else { | 252 callback_.Run(status, 0, base::string16()); |
| 261 content::RecordAction(UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); | |
| 262 callback_.Run(NEARLY_UPDATED, 0, base::string16()); | |
| 263 } | |
| 264 } | 253 } |
| 265 | 254 |
| 266 void VersionUpdaterWin::CreateGoogleUpdater() { | 255 void VersionUpdaterWin::CreateGoogleUpdater() { |
| 267 ClearGoogleUpdater(); | 256 ClearGoogleUpdater(); |
| 268 google_updater_ = new GoogleUpdate(); | 257 google_updater_ = new GoogleUpdate(); |
| 269 google_updater_->set_status_listener(this); | 258 google_updater_->set_status_listener(this); |
| 270 } | 259 } |
| 271 | 260 |
| 272 void VersionUpdaterWin::ClearGoogleUpdater() { | 261 void VersionUpdaterWin::ClearGoogleUpdater() { |
| 273 if (google_updater_) { | 262 if (google_updater_) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 299 << GetCurrentThreadId(); | 288 << GetCurrentThreadId(); |
| 300 #endif | 289 #endif |
| 301 return window; | 290 return window; |
| 302 } | 291 } |
| 303 | 292 |
| 304 } // namespace | 293 } // namespace |
| 305 | 294 |
| 306 VersionUpdater* VersionUpdater::Create() { | 295 VersionUpdater* VersionUpdater::Create() { |
| 307 return new VersionUpdaterWin; | 296 return new VersionUpdaterWin; |
| 308 } | 297 } |
| OLD | NEW |