Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: chrome/browser/cocoa/about_window_controller.mm

Issue 333049: Make KeystoneGlue less antisocial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/keystone_glue_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/l10n_util_mac.h" 5 #include "app/l10n_util_mac.h"
6 #include "app/resource_bundle.h" 6 #include "app/resource_bundle.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 object:nil]; 89 object:nil];
90 } 90 }
91 return self; 91 return self;
92 } 92 }
93 93
94 - (void)dealloc { 94 - (void)dealloc {
95 [[NSNotificationCenter defaultCenter] removeObserver:self]; 95 [[NSNotificationCenter defaultCenter] removeObserver:self];
96 [super dealloc]; 96 [super dealloc];
97 } 97 }
98 98
99 // YES when an About box is currently showing the kAutoupdateInstallFailed
100 // status, or if no About box is visible, if the most recent About box to be
101 // closed was closed while showing this status. When an About box opens, if
102 // the recent status is kAutoupdateInstallFailed and
103 // recentShownInstallFailedStatus is NO, the failure needs to be shown instead
104 // of launching a new update check. recentShownInstallFailedStatus is
105 // maintained by -updateStatus:.
106 static BOOL recentShownInstallFailedStatus = NO;
107
99 - (void)awakeFromNib { 108 - (void)awakeFromNib {
100 NSBundle* bundle = mac_util::MainAppBundle(); 109 NSBundle* bundle = mac_util::MainAppBundle();
101 NSString* chromeVersion = 110 NSString* chromeVersion =
102 [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; 111 [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
103 112
104 #if defined(GOOGLE_CHROME_BUILD) 113 #if defined(GOOGLE_CHROME_BUILD)
105 NSString* version = chromeVersion; 114 NSString* version = chromeVersion;
106 #else // GOOGLE_CHROME_BUILD 115 #else // GOOGLE_CHROME_BUILD
107 // The format string is not localized, but this is how the displayed version 116 // The format string is not localized, but this is how the displayed version
108 // is built on Windows too. 117 // is built on Windows too.
(...skipping 26 matching lines...) Expand all
135 [legalText_ sizeToFit]; 144 [legalText_ sizeToFit];
136 NSRect newRect = oldLegalRect; 145 NSRect newRect = oldLegalRect;
137 newRect.size.height = [legalText_ frame].size.height; 146 newRect.size.height = [legalText_ frame].size.height;
138 [legalBlock_ setFrame:newRect]; 147 [legalBlock_ setFrame:newRect];
139 CGFloat legalShift = newRect.size.height - oldLegalRect.size.height; 148 CGFloat legalShift = newRect.size.height - oldLegalRect.size.height;
140 149
141 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; 150 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue];
142 CGFloat updateShift; 151 CGFloat updateShift;
143 if (keystoneGlue) { 152 if (keystoneGlue) {
144 if ([keystoneGlue asyncOperationPending] || 153 if ([keystoneGlue asyncOperationPending] ||
145 [keystoneGlue recentStatus] == kAutoupdateInstallFailed) { 154 ([keystoneGlue recentStatus] == kAutoupdateInstallFailed &&
155 !recentShownInstallFailedStatus)) {
146 // If an asynchronous update operation is currently pending, such as a 156 // If an asynchronous update operation is currently pending, such as a
147 // check for updates or an update installation attempt, set the status 157 // check for updates or an update installation attempt, set the status
148 // up correspondingly without launching a new update check. 158 // up correspondingly without launching a new update check.
149 // 159 //
150 // If a previous update attempt was unsuccessful but no About box was 160 // If a previous update attempt was unsuccessful but no About box was
151 // around to report the error, show it now, and allow another chance to 161 // around to report the error, show it now, and allow another chance to
152 // install the update. 162 // install the update.
153 [self updateStatus:[keystoneGlue recentNotification]]; 163 [self updateStatus:[keystoneGlue recentNotification]];
154 } else { 164 } else {
155 // Launch a new update check, even if one was already completed, because 165 // Launch a new update check, even if one was already completed, because
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 238
229 // Immediately, kAutoupdateStatusNotification will be posted, and 239 // Immediately, kAutoupdateStatusNotification will be posted, and
230 // -updateStatus: will be called with status kAutoupdateInstalling. 240 // -updateStatus: will be called with status kAutoupdateInstalling.
231 // 241 //
232 // Upon completion, kAutoupdateStatusNotification will be posted, and 242 // Upon completion, kAutoupdateStatusNotification will be posted, and
233 // -updateStatus: will be called with a status indicating the result of the 243 // -updateStatus: will be called with a status indicating the result of the
234 // installation attempt. 244 // installation attempt.
235 } 245 }
236 246
237 - (void)updateStatus:(NSNotification*)notification { 247 - (void)updateStatus:(NSNotification*)notification {
248 recentShownInstallFailedStatus = NO;
249
238 NSDictionary* dictionary = [notification userInfo]; 250 NSDictionary* dictionary = [notification userInfo];
239 AutoupdateStatus status = static_cast<AutoupdateStatus>( 251 AutoupdateStatus status = static_cast<AutoupdateStatus>(
240 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); 252 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]);
241 253
242 // Don't assume |version| is a real string. It may be nil. 254 // Don't assume |version| is a real string. It may be nil.
243 NSString* version = [dictionary objectForKey:kAutoupdateStatusVersion]; 255 NSString* version = [dictionary objectForKey:kAutoupdateStatusVersion];
244 256
245 bool throbber = false; 257 bool throbber = false;
246 int imageID = 0; 258 int imageID = 0;
247 NSString* message; 259 NSString* message;
(...skipping 16 matching lines...) Expand all
264 276
265 case kAutoupdateAvailable: 277 case kAutoupdateAvailable:
266 imageID = IDR_UPDATE_AVAILABLE; 278 imageID = IDR_UPDATE_AVAILABLE;
267 message = l10n_util::GetNSStringFWithFixup( 279 message = l10n_util::GetNSStringFWithFixup(
268 IDS_UPGRADE_AVAILABLE, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 280 IDS_UPGRADE_AVAILABLE, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
269 [updateNowButton_ setEnabled:YES]; 281 [updateNowButton_ setEnabled:YES];
270 282
271 break; 283 break;
272 284
273 case kAutoupdateInstalling: 285 case kAutoupdateInstalling:
274 // Don't let someone click "Update Now" twice. 286 // Don't let anyone click "Update Now" twice.
275 [updateNowButton_ setEnabled:NO]; 287 [updateNowButton_ setEnabled:NO];
276 288
277 throbber = true; 289 throbber = true;
278 message = l10n_util::GetNSStringWithFixup(IDS_UPGRADE_STARTED); 290 message = l10n_util::GetNSStringWithFixup(IDS_UPGRADE_STARTED);
279 291
280 break; 292 break;
281 293
282 case kAutoupdateInstalled: 294 case kAutoupdateInstalled:
283 { 295 {
284 imageID = IDR_UPDATE_UPTODATE; 296 imageID = IDR_UPDATE_UPTODATE;
(...skipping 11 matching lines...) Expand all
296 // TODO(mark): Turn the button in the dialog into a restart button 308 // TODO(mark): Turn the button in the dialog into a restart button
297 // instead of springing this sheet or dialog. 309 // instead of springing this sheet or dialog.
298 NSWindow* window = [self window]; 310 NSWindow* window = [self window];
299 NSWindow* restartDialogParent = [window isVisible] ? window : nil; 311 NSWindow* restartDialogParent = [window isVisible] ? window : nil;
300 restart_browser::RequestRestart(restartDialogParent); 312 restart_browser::RequestRestart(restartDialogParent);
301 } 313 }
302 314
303 break; 315 break;
304 316
305 case kAutoupdateInstallFailed: 317 case kAutoupdateInstallFailed:
306 // Since the installation failure will now be displayed in an About box, 318 recentShownInstallFailedStatus = YES;
307 // the saved state can be cleared. If the About box is closed and then
308 // reopened, this will let it start out with a clean slate and not be
309 // affected by past failures.
310 [[KeystoneGlue defaultKeystoneGlue] clearRecentNotification];
311 319
312 // Allow another chance. 320 // Allow another chance.
313 [updateNowButton_ setEnabled:YES]; 321 [updateNowButton_ setEnabled:YES];
314 322
315 // Fall through. 323 // Fall through.
316 324
317 case kAutoupdateCheckFailed: 325 case kAutoupdateCheckFailed:
318 // TODO(mark): Keystone doesn't currently indicate when a check for 326 // TODO(mark): Keystone doesn't currently indicate when a check for
319 // updates failed. Fix that. 327 // updates failed. Fix that.
320 imageID = IDR_UPDATE_FAIL; 328 imageID = IDR_UPDATE_FAIL;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 NSRange string_range = NSMakeRange(0, [legal_block length]); 482 NSRange string_range = NSMakeRange(0, [legal_block length]);
475 [legal_block addAttribute:NSFontAttributeName 483 [legal_block addAttribute:NSFontAttributeName
476 value:[NSFont labelFontOfSize:11] 484 value:[NSFont labelFontOfSize:11]
477 range:string_range]; 485 range:string_range];
478 486
479 [legal_block endEditing]; 487 [legal_block endEditing];
480 return legal_block; 488 return legal_block;
481 } 489 }
482 490
483 @end // @implementation AboutWindowController 491 @end // @implementation AboutWindowController
OLDNEW
« no previous file with comments | « chrome/app/keystone_glue_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698