| 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 "chrome/browser/upgrade_detector_impl.h" | 5 #include "chrome/browser/upgrade_detector_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/build_time.h" | 10 #include "base/build_time.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Check if one of the outdated simulation switches was present on the command | 67 // Check if one of the outdated simulation switches was present on the command |
| 68 // line. | 68 // line. |
| 69 bool SimulatingOutdated() { | 69 bool SimulatingOutdated() { |
| 70 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 70 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 71 return cmd_line.HasSwitch(switches::kSimulateOutdated) || | 71 return cmd_line.HasSwitch(switches::kSimulateOutdated) || |
| 72 cmd_line.HasSwitch(switches::kSimulateOutdatedNoAU); | 72 cmd_line.HasSwitch(switches::kSimulateOutdatedNoAU); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Check if elevated recovery simulation switch was present on the command line. |
| 76 bool SimulatingElevatedRecovery() { |
| 77 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 78 return cmd_line.HasSwitch(switches::kSimulateElevatedRecovery); |
| 79 } |
| 80 |
| 75 // Check if any of the testing switches was present on the command line. | 81 // Check if any of the testing switches was present on the command line. |
| 76 bool IsTesting() { | 82 bool IsTesting() { |
| 77 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 83 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 78 return cmd_line.HasSwitch(switches::kSimulateUpgrade) || | 84 return cmd_line.HasSwitch(switches::kSimulateUpgrade) || |
| 79 cmd_line.HasSwitch(switches::kCheckForUpdateIntervalSec) || | 85 cmd_line.HasSwitch(switches::kCheckForUpdateIntervalSec) || |
| 80 cmd_line.HasSwitch(switches::kSimulateCriticalUpdate) || | 86 cmd_line.HasSwitch(switches::kSimulateCriticalUpdate) || |
| 81 SimulatingOutdated(); | 87 SimulatingOutdated() || |
| 88 SimulatingElevatedRecovery(); |
| 82 } | 89 } |
| 83 | 90 |
| 84 // How often to check for an upgrade. | 91 // How often to check for an upgrade. |
| 85 int GetCheckForUpgradeEveryMs() { | 92 int GetCheckForUpgradeEveryMs() { |
| 86 // Check for a value passed via the command line. | 93 // Check for a value passed via the command line. |
| 87 int interval_ms; | 94 int interval_ms; |
| 88 std::string interval = CmdLineInterval(); | 95 std::string interval = CmdLineInterval(); |
| 89 if (!interval.empty() && base::StringToInt(interval, &interval_ms)) | 96 if (!interval.empty() && base::StringToInt(interval, &interval_ms)) |
| 90 return interval_ms * 1000; // Command line value is in seconds. | 97 return interval_ms * 1000; // Command line value is in seconds. |
| 91 | 98 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // of the if statements below: | 206 // of the if statements below: |
| 200 // - kDisableBackgroundNetworking prevents any of the other command line | 207 // - kDisableBackgroundNetworking prevents any of the other command line |
| 201 // switch from being taken into account. | 208 // switch from being taken into account. |
| 202 // - kSimulateUpgrade supersedes critical or outdated upgrade switches. | 209 // - kSimulateUpgrade supersedes critical or outdated upgrade switches. |
| 203 // - kSimulateCriticalUpdate has precedence over kSimulateOutdated. | 210 // - kSimulateCriticalUpdate has precedence over kSimulateOutdated. |
| 204 // - kSimulateOutdatedNoAU has precedence over kSimulateOutdated. | 211 // - kSimulateOutdatedNoAU has precedence over kSimulateOutdated. |
| 205 // - kSimulateOutdated[NoAu] can work on its own, or with a specified date. | 212 // - kSimulateOutdated[NoAu] can work on its own, or with a specified date. |
| 206 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) | 213 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) |
| 207 return; | 214 return; |
| 208 if (command_line.HasSwitch(switches::kSimulateUpgrade)) { | 215 if (command_line.HasSwitch(switches::kSimulateUpgrade)) { |
| 209 UpgradeDetected(UPGRADE_AVAILABLE_REGULAR); | 216 UpgradeStatusChanged(UPGRADE_AVAILABLE_REGULAR); |
| 210 return; | 217 return; |
| 211 } | 218 } |
| 212 if (command_line.HasSwitch(switches::kSimulateCriticalUpdate)) { | 219 if (command_line.HasSwitch(switches::kSimulateCriticalUpdate)) { |
| 213 UpgradeDetected(UPGRADE_AVAILABLE_CRITICAL); | 220 UpgradeStatusChanged(UPGRADE_AVAILABLE_CRITICAL); |
| 221 return; |
| 222 } |
| 223 if (SimulatingElevatedRecovery()) { |
| 224 UpgradeStatusChanged(UPGRADE_NEEDS_ELEVATION); |
| 214 return; | 225 return; |
| 215 } | 226 } |
| 216 if (SimulatingOutdated()) { | 227 if (SimulatingOutdated()) { |
| 217 // The outdated simulation can work without a value, which means outdated | 228 // The outdated simulation can work without a value, which means outdated |
| 218 // now, or with a value that must be a well formed date/time string that | 229 // now, or with a value that must be a well formed date/time string that |
| 219 // overrides the build date. | 230 // overrides the build date. |
| 220 // Also note that to test with a given time/date, until the network time | 231 // Also note that to test with a given time/date, until the network time |
| 221 // tracking moves off of the VariationsService, the "variations-server-url" | 232 // tracking moves off of the VariationsService, the "variations-server-url" |
| 222 // command line switch must also be specified for the service to be | 233 // command line switch must also be specified for the service to be |
| 223 // available on non GOOGLE_CHROME_BUILD. | 234 // available on non GOOGLE_CHROME_BUILD. |
| 224 std::string switch_name; | 235 std::string switch_name; |
| 225 if (command_line.HasSwitch(switches::kSimulateOutdatedNoAU)) { | 236 if (command_line.HasSwitch(switches::kSimulateOutdatedNoAU)) { |
| 226 is_auto_update_enabled_ = false; | 237 is_auto_update_enabled_ = false; |
| 227 switch_name = switches::kSimulateOutdatedNoAU; | 238 switch_name = switches::kSimulateOutdatedNoAU; |
| 228 } else { | 239 } else { |
| 229 switch_name = switches::kSimulateOutdated; | 240 switch_name = switches::kSimulateOutdated; |
| 230 } | 241 } |
| 231 std::string build_date = command_line.GetSwitchValueASCII(switch_name); | 242 std::string build_date = command_line.GetSwitchValueASCII(switch_name); |
| 232 base::Time maybe_build_time; | 243 base::Time maybe_build_time; |
| 233 bool result = base::Time::FromString(build_date.c_str(), &maybe_build_time); | 244 bool result = base::Time::FromString(build_date.c_str(), &maybe_build_time); |
| 234 if (result && !maybe_build_time.is_null()) { | 245 if (result && !maybe_build_time.is_null()) { |
| 235 // We got a valid build date simulation so use it and check for upgrades. | 246 // We got a valid build date simulation so use it and check for upgrades. |
| 236 build_date_ = maybe_build_time; | 247 build_date_ = maybe_build_time; |
| 237 StartTimerForUpgradeCheck(); | 248 StartTimerForUpgradeCheck(); |
| 238 } else { | 249 } else { |
| 239 // Without a valid date, we simulate that we are already outdated... | 250 // Without a valid date, we simulate that we are already outdated... |
| 240 UpgradeDetected( | 251 UpgradeStatusChanged( |
| 241 is_auto_update_enabled_ ? UPGRADE_NEEDED_OUTDATED_INSTALL | 252 is_auto_update_enabled_ ? UPGRADE_NEEDED_OUTDATED_INSTALL |
| 242 : UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU); | 253 : UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU); |
| 243 } | 254 } |
| 244 return; | 255 return; |
| 245 } | 256 } |
| 246 | 257 |
| 247 base::Closure start_upgrade_check_timer_task = | 258 base::Closure start_upgrade_check_timer_task = |
| 248 base::Bind(&UpgradeDetectorImpl::StartTimerForUpgradeCheck, | 259 base::Bind(&UpgradeDetectorImpl::StartTimerForUpgradeCheck, |
| 249 weak_factory_.GetWeakPtr()); | 260 weak_factory_.GetWeakPtr()); |
| 250 | 261 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 301 } |
| 291 | 302 |
| 292 // static | 303 // static |
| 293 base::Version UpgradeDetectorImpl::GetCurrentlyInstalledVersion() { | 304 base::Version UpgradeDetectorImpl::GetCurrentlyInstalledVersion() { |
| 294 return GetCurrentlyInstalledVersionImpl(NULL); | 305 return GetCurrentlyInstalledVersionImpl(NULL); |
| 295 } | 306 } |
| 296 | 307 |
| 297 // static | 308 // static |
| 298 // This task checks the currently running version of Chrome against the | 309 // This task checks the currently running version of Chrome against the |
| 299 // installed version. If the installed version is newer, it calls back | 310 // installed version. If the installed version is newer, it calls back |
| 300 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can | 311 // UpgradeDetectorImpl::UpgradeStatusChanged using a weak pointer so that it can |
| 301 // be interrupted from the UI thread. | 312 // be interrupted from the UI thread. |
| 302 void UpgradeDetectorImpl::DetectUpgradeTask( | 313 void UpgradeDetectorImpl::DetectUpgradeTask( |
| 303 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { | 314 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { |
| 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 305 | 316 |
| 306 Version critical_update; | 317 Version critical_update; |
| 307 Version installed_version = | 318 Version installed_version = |
| 308 GetCurrentlyInstalledVersionImpl(&critical_update); | 319 GetCurrentlyInstalledVersionImpl(&critical_update); |
| 309 | 320 |
| 310 // Get the version of the currently *running* instance of Chrome. | 321 // Get the version of the currently *running* instance of Chrome. |
| 311 chrome::VersionInfo version_info; | 322 chrome::VersionInfo version_info; |
| 312 if (!version_info.is_valid()) { | 323 if (!version_info.is_valid()) { |
| 313 NOTREACHED() << "Failed to get current file version"; | 324 NOTREACHED() << "Failed to get current file version"; |
| 325 NotifyNoUpgrade(upgrade_detector); |
| 314 return; | 326 return; |
| 315 } | 327 } |
| 316 Version running_version(version_info.Version()); | 328 Version running_version(version_info.Version()); |
| 317 if (!running_version.IsValid()) { | 329 if (!running_version.IsValid()) { |
| 318 NOTREACHED(); | 330 NOTREACHED(); |
| 331 NotifyNoUpgrade(upgrade_detector); |
| 319 return; | 332 return; |
| 320 } | 333 } |
| 321 | 334 |
| 322 // |installed_version| may be NULL when the user downgrades on Linux (by | 335 // |installed_version| may be NULL when the user downgrades on Linux (by |
| 323 // switching from dev to beta channel, for example). The user needs a | 336 // switching from dev to beta channel, for example). The user needs a |
| 324 // restart in this case as well. See http://crbug.com/46547 | 337 // restart in this case as well. See http://crbug.com/46547 |
| 325 if (!installed_version.IsValid() || | 338 if (!installed_version.IsValid() || |
| 326 (installed_version.CompareTo(running_version) > 0)) { | 339 (installed_version.CompareTo(running_version) > 0)) { |
| 327 // If a more recent version is available, it might be that we are lacking | 340 // If a more recent version is available, it might be that we are lacking |
| 328 // a critical update, such as a zero-day fix. | 341 // a critical update, such as a zero-day fix. |
| 329 UpgradeAvailable upgrade_available = UPGRADE_AVAILABLE_REGULAR; | 342 UpgradeAvailable upgrade_available = UPGRADE_AVAILABLE_REGULAR; |
| 330 if (critical_update.IsValid() && | 343 if (critical_update.IsValid() && |
| 331 critical_update.CompareTo(running_version) > 0) { | 344 critical_update.CompareTo(running_version) > 0) { |
| 332 upgrade_available = UPGRADE_AVAILABLE_CRITICAL; | 345 upgrade_available = UPGRADE_AVAILABLE_CRITICAL; |
| 333 } | 346 } |
| 334 | |
| 335 // Fire off the upgrade detected task. | 347 // Fire off the upgrade detected task. |
| 336 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 348 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 337 base::Bind(&UpgradeDetectorImpl::UpgradeDetected, | 349 base::Bind(&UpgradeDetectorImpl::UpgradeStatusChanged, |
| 338 upgrade_detector, | 350 upgrade_detector, |
| 339 upgrade_available)); | 351 upgrade_available)); |
| 352 } else { |
| 353 NotifyNoUpgrade(upgrade_detector); |
| 340 } | 354 } |
| 341 } | 355 } |
| 342 | 356 |
| 343 void UpgradeDetectorImpl::StartTimerForUpgradeCheck() { | 357 void UpgradeDetectorImpl::StartTimerForUpgradeCheck() { |
| 344 detect_upgrade_timer_.Start(FROM_HERE, | 358 detect_upgrade_timer_.Start(FROM_HERE, |
| 345 base::TimeDelta::FromMilliseconds(GetCheckForUpgradeEveryMs()), | 359 base::TimeDelta::FromMilliseconds(GetCheckForUpgradeEveryMs()), |
| 346 this, &UpgradeDetectorImpl::CheckForUpgrade); | 360 this, &UpgradeDetectorImpl::CheckForUpgrade); |
| 347 } | 361 } |
| 348 | 362 |
| 349 void UpgradeDetectorImpl::CheckForUpgrade() { | 363 void UpgradeDetectorImpl::CheckForUpgrade() { |
| 350 // Interrupt any (unlikely) unfinished execution of DetectUpgradeTask, or at | 364 // Interrupt any (unlikely) unfinished execution of DetectUpgradeTask, or at |
| 351 // least prevent the callback from being executed, because we will potentially | 365 // least prevent the callback from being executed, because we will potentially |
| 352 // call it from within DetectOutdatedInstall() or will post | 366 // call it from within DetectOutdatedInstall() or will post |
| 353 // DetectUpgradeTask again below anyway. | 367 // DetectUpgradeTask again below anyway. |
| 354 weak_factory_.InvalidateWeakPtrs(); | 368 weak_factory_.InvalidateWeakPtrs(); |
| 355 | 369 |
| 370 // No need to check further if elevation is needed to recover Omaha. |
| 371 if (DetectElevationNeeded()) |
| 372 return; |
| 373 |
| 356 // No need to look for upgrades if the install is outdated. | 374 // No need to look for upgrades if the install is outdated. |
| 357 if (DetectOutdatedInstall()) | 375 if (DetectOutdatedInstall()) |
| 358 return; | 376 return; |
| 359 | 377 |
| 360 // We use FILE as the thread to run the upgrade detection code on all | 378 // We use FILE as the thread to run the upgrade detection code on all |
| 361 // platforms. For Linux, this is because we don't want to block the UI thread | 379 // platforms. For Linux, this is because we don't want to block the UI thread |
| 362 // while launching a background process and reading its output; on the Mac and | 380 // while launching a background process and reading its output; on the Mac and |
| 363 // on Windows checking for an upgrade requires reading a file. | 381 // on Windows checking for an upgrade requires reading a file. |
| 364 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 382 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 365 base::Bind(&UpgradeDetectorImpl::DetectUpgradeTask, | 383 base::Bind(&UpgradeDetectorImpl::DetectUpgradeTask, |
| 366 weak_factory_.GetWeakPtr())); | 384 weak_factory_.GetWeakPtr())); |
| 367 } | 385 } |
| 368 | 386 |
| 387 bool UpgradeDetectorImpl::DetectElevationNeeded() { |
| 388 PrefService* prefs = g_browser_process->local_state(); |
| 389 if (prefs->FindPreference(prefs::kRecoveryComponentNeedsElevation) && |
| 390 prefs->GetBoolean(prefs::kRecoveryComponentNeedsElevation)) { |
| 391 UpgradeStatusChanged(UPGRADE_NEEDS_ELEVATION); |
| 392 return true; |
| 393 } |
| 394 |
| 395 return false; |
| 396 } |
| 397 |
| 369 bool UpgradeDetectorImpl::DetectOutdatedInstall() { | 398 bool UpgradeDetectorImpl::DetectOutdatedInstall() { |
| 370 // Don't show the bubble if we have a brand code that is NOT organic, unless | 399 // Don't show the bubble if we have a brand code that is NOT organic, unless |
| 371 // an outdated build is being simulated by command line switches. | 400 // an outdated build is being simulated by command line switches. |
| 372 static bool simulate_outdated = SimulatingOutdated(); | 401 static bool simulate_outdated = SimulatingOutdated(); |
| 373 if (!simulate_outdated) { | 402 if (!simulate_outdated) { |
| 374 std::string brand; | 403 std::string brand; |
| 375 if (google_brand::GetBrand(&brand) && !google_brand::IsOrganic(brand)) | 404 if (google_brand::GetBrand(&brand) && !google_brand::IsOrganic(brand)) |
| 376 return false; | 405 return false; |
| 377 | 406 |
| 378 #if defined(OS_WIN) | 407 #if defined(OS_WIN) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 395 // machine's current time. | 424 // machine's current time. |
| 396 network_time = base::Time::Now(); | 425 network_time = base::Time::Now(); |
| 397 } | 426 } |
| 398 | 427 |
| 399 if (network_time.is_null() || build_date_.is_null() || | 428 if (network_time.is_null() || build_date_.is_null() || |
| 400 build_date_ > network_time) { | 429 build_date_ > network_time) { |
| 401 NOTREACHED(); | 430 NOTREACHED(); |
| 402 return false; | 431 return false; |
| 403 } | 432 } |
| 404 | 433 |
| 405 if (network_time - build_date_ > | 434 if (simulate_outdated || |
| 435 network_time - build_date_ > |
| 406 base::TimeDelta::FromDays(kOutdatedBuildAgeInDays)) { | 436 base::TimeDelta::FromDays(kOutdatedBuildAgeInDays)) { |
| 407 UpgradeDetected(is_auto_update_enabled_ ? | 437 UpgradeStatusChanged(is_auto_update_enabled_ ? |
| 408 UPGRADE_NEEDED_OUTDATED_INSTALL : | 438 UPGRADE_NEEDED_OUTDATED_INSTALL : |
| 409 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU); | 439 UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU); |
| 410 return true; | 440 return true; |
| 411 } | 441 } |
| 412 // If we simlated an outdated install with a date, we don't want to keep | 442 // If we simlated an outdated install with a date, we don't want to keep |
| 413 // checking for version upgrades, which happens on non-official builds. | 443 // checking for version upgrades, which happens on non-official builds. |
| 414 return simulate_outdated; | 444 return false; |
| 415 } | 445 } |
| 416 | 446 |
| 417 void UpgradeDetectorImpl::UpgradeDetected(UpgradeAvailable upgrade_available) { | 447 void UpgradeDetectorImpl::UpgradeStatusChanged( |
| 448 UpgradeAvailable upgrade_available) { |
| 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 449 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 419 upgrade_available_ = upgrade_available; | 450 upgrade_available_ = upgrade_available; |
| 420 | 451 if (upgrade_available_ == UPGRADE_AVAILABLE_NONE) { |
| 421 // Stop the recurring timer (that is checking for changes). | 452 NotifyUpgradeStatusChanged(); |
| 422 detect_upgrade_timer_.Stop(); | 453 return; |
| 454 } |
| 423 | 455 |
| 424 NotifyUpgradeDetected(); | 456 NotifyUpgradeDetected(); |
| 425 | 457 |
| 426 // Start the repeating timer for notifying the user after a certain period. | 458 // Start the repeating timer for notifying the user after a certain period. |
| 427 // The called function will eventually figure out that enough time has passed | 459 // The called function will eventually figure out that enough time has passed |
| 428 // and stop the timer. | 460 // and stop the timer. |
| 429 int cycle_time = IsTesting() ? | 461 int cycle_time = IsTesting() ? |
| 430 kNotifyCycleTimeForTestingMs : kNotifyCycleTimeMs; | 462 kNotifyCycleTimeForTestingMs : kNotifyCycleTimeMs; |
| 431 upgrade_notification_timer_.Start(FROM_HERE, | 463 upgrade_notification_timer_.Start(FROM_HERE, |
| 432 base::TimeDelta::FromMilliseconds(cycle_time), | 464 base::TimeDelta::FromMilliseconds(cycle_time), |
| 433 this, &UpgradeDetectorImpl::NotifyOnUpgrade); | 465 this, &UpgradeDetectorImpl::NotifyUpgradeStatusChanged); |
| 434 } | 466 } |
| 435 | 467 |
| 436 void UpgradeDetectorImpl::NotifyOnUpgrade() { | 468 void UpgradeDetectorImpl::NotifyNoUpgrade( |
| 469 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { |
| 470 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 471 base::Bind(&UpgradeDetectorImpl::UpgradeStatusChanged, |
| 472 upgrade_detector, |
| 473 UPGRADE_AVAILABLE_NONE)); |
| 474 } |
| 475 |
| 476 void UpgradeDetectorImpl::NotifyUpgradeStatusChanged() { |
| 437 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time(); | 477 base::TimeDelta delta = base::Time::Now() - upgrade_detected_time(); |
| 438 | 478 |
| 439 // We'll make testing more convenient by switching to seconds of waiting | 479 // We'll make testing more convenient by switching to seconds of waiting |
| 440 // instead of days between flipping severity. | 480 // instead of days between flipping severity. |
| 441 bool is_testing = IsTesting(); | 481 bool is_testing = IsTesting(); |
| 442 int64 time_passed = is_testing ? delta.InSeconds() : delta.InHours(); | 482 int64 time_passed = is_testing ? delta.InSeconds() : delta.InHours(); |
| 443 | 483 |
| 444 bool is_critical_or_outdated = upgrade_available_ > UPGRADE_AVAILABLE_REGULAR; | 484 bool is_critical_or_outdated = upgrade_available_ > UPGRADE_AVAILABLE_REGULAR; |
| 445 if (is_unstable_channel_) { | 485 if (is_unstable_channel_) { |
| 446 // There's only one threat level for unstable channels like dev and | 486 // There's only one threat level for unstable channels like dev and |
| (...skipping 27 matching lines...) Expand all Loading... |
| 474 | 514 |
| 475 // We can't get any higher, baby. | 515 // We can't get any higher, baby. |
| 476 upgrade_notification_timer_.Stop(); | 516 upgrade_notification_timer_.Stop(); |
| 477 } else if (time_passed >= kHighThreshold) { | 517 } else if (time_passed >= kHighThreshold) { |
| 478 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_HIGH); | 518 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_HIGH); |
| 479 } else if (time_passed >= kElevatedThreshold) { | 519 } else if (time_passed >= kElevatedThreshold) { |
| 480 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_ELEVATED); | 520 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_ELEVATED); |
| 481 } else if (time_passed >= kLowThreshold) { | 521 } else if (time_passed >= kLowThreshold) { |
| 482 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_LOW); | 522 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_LOW); |
| 483 } else { | 523 } else { |
| 484 return; // Not ready to recommend upgrade. | 524 set_upgrade_notification_stage(UPGRADE_ANNOYANCE_NONE); |
| 485 } | 525 } |
| 486 } | 526 } |
| 487 | 527 |
| 488 NotifyUpgradeRecommended(); | 528 NotifyUpgradeRecommended(); |
| 489 } | 529 } |
| 490 | 530 |
| 491 // static | 531 // static |
| 492 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { | 532 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { |
| 493 return Singleton<UpgradeDetectorImpl>::get(); | 533 return Singleton<UpgradeDetectorImpl>::get(); |
| 494 } | 534 } |
| 495 | 535 |
| 496 // static | 536 // static |
| 497 UpgradeDetector* UpgradeDetector::GetInstance() { | 537 UpgradeDetector* UpgradeDetector::GetInstance() { |
| 498 return UpgradeDetectorImpl::GetInstance(); | 538 return UpgradeDetectorImpl::GetInstance(); |
| 499 } | 539 } |
| OLD | NEW |