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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void VersionUpdaterMac::CheckForUpdate( | 69 void VersionUpdaterMac::CheckForUpdate( |
70 const StatusCallback& status_callback, | 70 const StatusCallback& status_callback, |
71 const PromoteCallback& promote_callback) { | 71 const PromoteCallback& promote_callback) { |
72 // 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 |
73 // of this object. | 73 // of this object. |
74 status_callback_ = status_callback; | 74 status_callback_ = status_callback; |
75 promote_callback_ = promote_callback; | 75 promote_callback_ = promote_callback; |
76 | 76 |
77 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; | 77 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; |
78 if (keystone_glue && ![keystone_glue isOnReadOnlyFilesystem]) { | 78 if (keystone_glue && ![keystone_glue isOnReadOnlyFilesystem]) { |
79 AutoupdateStatus recent_status = [keystone_glue recentStatus]; | 79 keystone_glue::AutoupdateStatus recent_status = |
| 80 [keystone_glue recentStatus]; |
80 if ([keystone_glue asyncOperationPending] || | 81 if ([keystone_glue asyncOperationPending] || |
81 recent_status == kAutoupdateRegisterFailed || | 82 recent_status == keystone_glue::kAutoupdateRegisterFailed || |
82 recent_status == kAutoupdateNeedsPromotion) { | 83 recent_status == keystone_glue::kAutoupdateNeedsPromotion) { |
83 // If an asynchronous update operation is currently pending, such as a | 84 // If an asynchronous update operation is currently pending, such as a |
84 // check for updates or an update installation attempt, set the status | 85 // check for updates or an update installation attempt, set the status |
85 // up correspondingly without launching a new update check. | 86 // up correspondingly without launching a new update check. |
86 // | 87 // |
87 // If registration failed, no other operations make sense, so just go | 88 // If registration failed, no other operations make sense, so just go |
88 // straight to the error. | 89 // straight to the error. |
89 UpdateStatus([[keystone_glue recentNotification] userInfo]); | 90 UpdateStatus([[keystone_glue recentNotification] userInfo]); |
90 } else { | 91 } else { |
91 // Launch a new update check, even if one was already completed, because | 92 // Launch a new update check, even if one was already completed, because |
92 // a new update may be available or a new update may have been installed | 93 // a new update may be available or a new update may have been installed |
(...skipping 30 matching lines...) Expand all Loading... |
123 // and UpdateStatus() will be called again indicating first that | 124 // and UpdateStatus() will be called again indicating first that |
124 // registration is in progress and subsequently that it has completed. | 125 // registration is in progress and subsequently that it has completed. |
125 } | 126 } |
126 | 127 |
127 void VersionUpdaterMac::RelaunchBrowser() const { | 128 void VersionUpdaterMac::RelaunchBrowser() const { |
128 // Tell the Broweser to restart if possible. | 129 // Tell the Broweser to restart if possible. |
129 chrome::AttemptRestart(); | 130 chrome::AttemptRestart(); |
130 } | 131 } |
131 | 132 |
132 void VersionUpdaterMac::UpdateStatus(NSDictionary* dictionary) { | 133 void VersionUpdaterMac::UpdateStatus(NSDictionary* dictionary) { |
133 AutoupdateStatus keystone_status = static_cast<AutoupdateStatus>( | 134 keystone_glue::AutoupdateStatus keystone_status = |
134 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); | 135 static_cast<keystone_glue::AutoupdateStatus>( |
| 136 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); |
135 | 137 |
136 bool enable_promote_button = true; | 138 bool enable_promote_button = true; |
137 base::string16 message; | 139 base::string16 message; |
138 | 140 |
139 Status status; | 141 Status status; |
140 switch (keystone_status) { | 142 switch (keystone_status) { |
141 case kAutoupdateRegistering: | 143 case keystone_glue::kAutoupdateRegistering: |
142 case kAutoupdateChecking: | 144 case keystone_glue::kAutoupdateChecking: |
143 status = CHECKING; | 145 status = CHECKING; |
144 enable_promote_button = false; | 146 enable_promote_button = false; |
145 break; | 147 break; |
146 | 148 |
147 case kAutoupdateRegistered: | 149 case keystone_glue::kAutoupdateRegistered: |
148 case kAutoupdatePromoted: | 150 case keystone_glue::kAutoupdatePromoted: |
149 UpdateShowPromoteButton(); | 151 UpdateShowPromoteButton(); |
150 // Go straight into an update check. Return immediately, this routine | 152 // Go straight into an update check. Return immediately, this routine |
151 // will be re-entered shortly with kAutoupdateChecking. | 153 // will be re-entered shortly with kAutoupdateChecking. |
152 [[KeystoneGlue defaultKeystoneGlue] checkForUpdate]; | 154 [[KeystoneGlue defaultKeystoneGlue] checkForUpdate]; |
153 return; | 155 return; |
154 | 156 |
155 case kAutoupdateCurrent: | 157 case keystone_glue::kAutoupdateCurrent: |
156 status = UPDATED; | 158 status = UPDATED; |
157 break; | 159 break; |
158 | 160 |
159 case kAutoupdateAvailable: | 161 case keystone_glue::kAutoupdateAvailable: |
160 // Install the update automatically. Return immediately, this routine | 162 // Install the update automatically. Return immediately, this routine |
161 // will be re-entered shortly with kAutoupdateInstalling. | 163 // will be re-entered shortly with kAutoupdateInstalling. |
162 [[KeystoneGlue defaultKeystoneGlue] installUpdate]; | 164 [[KeystoneGlue defaultKeystoneGlue] installUpdate]; |
163 return; | 165 return; |
164 | 166 |
165 case kAutoupdateInstalling: | 167 case keystone_glue::kAutoupdateInstalling: |
166 status = UPDATING; | 168 status = UPDATING; |
167 enable_promote_button = false; | 169 enable_promote_button = false; |
168 break; | 170 break; |
169 | 171 |
170 case kAutoupdateInstalled: | 172 case keystone_glue::kAutoupdateInstalled: |
171 status = NEARLY_UPDATED; | 173 status = NEARLY_UPDATED; |
172 break; | 174 break; |
173 | 175 |
174 case kAutoupdatePromoting: | 176 case keystone_glue::kAutoupdatePromoting: |
175 #if 1 | 177 #if 1 |
176 // TODO(mark): KSRegistration currently handles the promotion | 178 // TODO(mark): KSRegistration currently handles the promotion |
177 // synchronously, meaning that the main thread's loop doesn't spin, | 179 // synchronously, meaning that the main thread's loop doesn't spin, |
178 // meaning that animations and other updates to the window won't occur | 180 // meaning that animations and other updates to the window won't occur |
179 // until KSRegistration is done with promotion. This looks laggy and bad | 181 // until KSRegistration is done with promotion. This looks laggy and bad |
180 // and probably qualifies as "jank." For now, there just won't be any | 182 // and probably qualifies as "jank." For now, there just won't be any |
181 // visual feedback while promotion is in progress, but it should complete | 183 // visual feedback while promotion is in progress, but it should complete |
182 // (or fail) very quickly. http://b/2290009. | 184 // (or fail) very quickly. http://b/2290009. |
183 return; | 185 return; |
184 #endif | 186 #endif |
185 status = CHECKING; | 187 status = CHECKING; |
186 enable_promote_button = false; | 188 enable_promote_button = false; |
187 break; | 189 break; |
188 | 190 |
189 case kAutoupdateRegisterFailed: | 191 case keystone_glue::kAutoupdateRegisterFailed: |
190 enable_promote_button = false; | 192 enable_promote_button = false; |
191 // Fall through. | 193 // Fall through. |
192 case kAutoupdateCheckFailed: | 194 case keystone_glue::kAutoupdateCheckFailed: |
193 case kAutoupdateInstallFailed: | 195 case keystone_glue::kAutoupdateInstallFailed: |
194 case kAutoupdatePromoteFailed: | 196 case keystone_glue::kAutoupdatePromoteFailed: |
195 status = FAILED; | 197 status = FAILED; |
196 message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, | 198 message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, |
197 keystone_status); | 199 keystone_status); |
198 break; | 200 break; |
199 | 201 |
200 case kAutoupdateNeedsPromotion: | 202 case keystone_glue::kAutoupdateNeedsPromotion: { |
201 { | |
202 status = FAILED; | 203 status = FAILED; |
203 base::string16 product_name = | 204 base::string16 product_name = |
204 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 205 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
205 message = l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, | 206 message = l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, |
206 product_name); | 207 product_name); |
207 } | 208 } |
208 break; | 209 break; |
209 | 210 |
210 default: | 211 default: |
211 NOTREACHED(); | 212 NOTREACHED(); |
(...skipping 13 matching lines...) Expand all Loading... |
225 | 226 |
226 void VersionUpdaterMac::UpdateShowPromoteButton() { | 227 void VersionUpdaterMac::UpdateShowPromoteButton() { |
227 if (ObsoleteSystemMac::Has32BitOnlyCPU() && | 228 if (ObsoleteSystemMac::Has32BitOnlyCPU() && |
228 ObsoleteSystemMac::Is32BitEndOfTheLine()) { | 229 ObsoleteSystemMac::Is32BitEndOfTheLine()) { |
229 // Promotion is moot upon reaching the end of the line. | 230 // Promotion is moot upon reaching the end of the line. |
230 show_promote_button_ = false; | 231 show_promote_button_ = false; |
231 return; | 232 return; |
232 } | 233 } |
233 | 234 |
234 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; | 235 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; |
235 AutoupdateStatus recent_status = [keystone_glue recentStatus]; | 236 keystone_glue::AutoupdateStatus recent_status = [keystone_glue recentStatus]; |
236 if (recent_status == kAutoupdateRegistering || | 237 if (recent_status == keystone_glue::kAutoupdateRegistering || |
237 recent_status == kAutoupdateRegisterFailed || | 238 recent_status == keystone_glue::kAutoupdateRegisterFailed || |
238 recent_status == kAutoupdatePromoted) { | 239 recent_status == keystone_glue::kAutoupdatePromoted) { |
239 // Promotion isn't possible at this point. | 240 // Promotion isn't possible at this point. |
240 show_promote_button_ = false; | 241 show_promote_button_ = false; |
241 } else if (recent_status == kAutoupdatePromoting || | 242 } else if (recent_status == keystone_glue::kAutoupdatePromoting || |
242 recent_status == kAutoupdatePromoteFailed) { | 243 recent_status == keystone_glue::kAutoupdatePromoteFailed) { |
243 // Show promotion UI because the user either just clicked that button or | 244 // Show promotion UI because the user either just clicked that button or |
244 // because the user should be able to click it again. | 245 // because the user should be able to click it again. |
245 show_promote_button_ = true; | 246 show_promote_button_ = true; |
246 } else { | 247 } else { |
247 // Show the promote button if promotion is a possibility. | 248 // Show the promote button if promotion is a possibility. |
248 show_promote_button_ = [keystone_glue wantsPromotion]; | 249 show_promote_button_ = [keystone_glue wantsPromotion]; |
249 } | 250 } |
250 } | 251 } |
OLD | NEW |