| 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/ui/webui/help/version_updater_mac.h" | 5 #include "chrome/browser/ui/webui/help/version_updater_mac.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/lifetime/application_lifetime.h" | 9 #include "chrome/browser/lifetime/application_lifetime.h" |
| 10 #import "chrome/browser/mac/keystone_glue.h" | 10 #import "chrome/browser/mac/keystone_glue.h" |
| 11 #include "chrome/browser/mac/system_bitness.h" |
| 11 #include "grit/chromium_strings.h" | 12 #include "grit/chromium_strings.h" |
| 12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 14 | 15 |
| 15 // KeystoneObserver is a simple notification observer for Keystone status | 16 // KeystoneObserver is a simple notification observer for Keystone status |
| 16 // updates. It will be created and managed by VersionUpdaterMac. | 17 // updates. It will be created and managed by VersionUpdaterMac. |
| 17 @interface KeystoneObserver : NSObject { | 18 @interface KeystoneObserver : NSObject { |
| 18 @private | 19 @private |
| 19 VersionUpdaterMac* versionUpdater_; // Weak. | 20 VersionUpdaterMac* versionUpdater_; // Weak. |
| 20 } | 21 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 versionUpdater_->UpdateStatus([notification userInfo]); | 51 versionUpdater_->UpdateStatus([notification userInfo]); |
| 51 } | 52 } |
| 52 | 53 |
| 53 @end // @implementation KeystoneObserver | 54 @end // @implementation KeystoneObserver |
| 54 | 55 |
| 55 | 56 |
| 56 VersionUpdater* VersionUpdater::Create() { | 57 VersionUpdater* VersionUpdater::Create() { |
| 57 return new VersionUpdaterMac; | 58 return new VersionUpdaterMac; |
| 58 } | 59 } |
| 59 | 60 |
| 60 VersionUpdaterMac::VersionUpdaterMac() { | 61 VersionUpdaterMac::VersionUpdaterMac() |
| 61 keystone_observer_.reset([[KeystoneObserver alloc] initWithUpdater:this]); | 62 : show_promote_button_(false), |
| 63 keystone_observer_([[KeystoneObserver alloc] initWithUpdater:this]) { |
| 62 } | 64 } |
| 63 | 65 |
| 64 VersionUpdaterMac::~VersionUpdaterMac() { | 66 VersionUpdaterMac::~VersionUpdaterMac() { |
| 65 } | 67 } |
| 66 | 68 |
| 67 void VersionUpdaterMac::CheckForUpdate( | 69 void VersionUpdaterMac::CheckForUpdate( |
| 68 const StatusCallback& status_callback, | 70 const StatusCallback& status_callback, |
| 69 const PromoteCallback& promote_callback) { | 71 const PromoteCallback& promote_callback) { |
| 70 // Copy the callbacks, we will re-use this for the remaining lifetime | 72 // Copy the callbacks, we will re-use this for the remaining lifetime |
| 71 // of this object. | 73 // of this object. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 if (!promote_callback_.is_null()) { | 217 if (!promote_callback_.is_null()) { |
| 216 PromotionState promotion_state = PROMOTE_HIDDEN; | 218 PromotionState promotion_state = PROMOTE_HIDDEN; |
| 217 if (show_promote_button_) | 219 if (show_promote_button_) |
| 218 promotion_state = enable_promote_button ? PROMOTE_ENABLED | 220 promotion_state = enable_promote_button ? PROMOTE_ENABLED |
| 219 : PROMOTE_DISABLED; | 221 : PROMOTE_DISABLED; |
| 220 promote_callback_.Run(promotion_state); | 222 promote_callback_.Run(promotion_state); |
| 221 } | 223 } |
| 222 } | 224 } |
| 223 | 225 |
| 224 void VersionUpdaterMac::UpdateShowPromoteButton() { | 226 void VersionUpdaterMac::UpdateShowPromoteButton() { |
| 227 if (chrome::Has32BitOnlyCPU() && chrome::Is32BitEndOfTheLine()) { |
| 228 // Promotion is moot upon reaching the end of the line. |
| 229 show_promote_button_ = false; |
| 230 return; |
| 231 } |
| 232 |
| 225 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; | 233 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; |
| 226 AutoupdateStatus recent_status = [keystone_glue recentStatus]; | 234 AutoupdateStatus recent_status = [keystone_glue recentStatus]; |
| 227 if (recent_status == kAutoupdateRegistering || | 235 if (recent_status == kAutoupdateRegistering || |
| 228 recent_status == kAutoupdateRegisterFailed || | 236 recent_status == kAutoupdateRegisterFailed || |
| 229 recent_status == kAutoupdatePromoted) { | 237 recent_status == kAutoupdatePromoted) { |
| 230 // Promotion isn't possible at this point. | 238 // Promotion isn't possible at this point. |
| 231 show_promote_button_ = false; | 239 show_promote_button_ = false; |
| 232 } else if (recent_status == kAutoupdatePromoting || | 240 } else if (recent_status == kAutoupdatePromoting || |
| 233 recent_status == kAutoupdatePromoteFailed) { | 241 recent_status == kAutoupdatePromoteFailed) { |
| 234 // Show promotion UI because the user either just clicked that button or | 242 // Show promotion UI because the user either just clicked that button or |
| 235 // because the user should be able to click it again. | 243 // because the user should be able to click it again. |
| 236 show_promote_button_ = true; | 244 show_promote_button_ = true; |
| 237 } else { | 245 } else { |
| 238 // Show the promote button if promotion is a possibility. | 246 // Show the promote button if promotion is a possibility. |
| 239 show_promote_button_ = [keystone_glue wantsPromotion]; | 247 show_promote_button_ = [keystone_glue wantsPromotion]; |
| 240 } | 248 } |
| 241 } | 249 } |
| OLD | NEW |