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 #import "chrome/browser/mac/keystone_glue.h" | 5 #import "chrome/browser/mac/keystone_glue.h" |
| 6 | 6 |
| 7 #include <sys/mount.h> | 7 #include <sys/mount.h> |
| 8 #include <sys/param.h> | 8 #include <sys/param.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 // outer application bundle's Info.plist, not the framework's Info.plist. | 112 // outer application bundle's Info.plist, not the framework's Info.plist. |
| 113 - (NSString*)appInfoPlistPath; | 113 - (NSString*)appInfoPlistPath; |
| 114 | 114 |
| 115 // Returns a dictionary containing parameters to be used for a KSRegistration | 115 // Returns a dictionary containing parameters to be used for a KSRegistration |
| 116 // -registerWithParameters: or -promoteWithParameters:authorization: call. | 116 // -registerWithParameters: or -promoteWithParameters:authorization: call. |
| 117 - (NSDictionary*)keystoneParameters; | 117 - (NSDictionary*)keystoneParameters; |
| 118 | 118 |
| 119 // Called when Keystone registration completes. | 119 // Called when Keystone registration completes. |
| 120 - (void)registrationComplete:(NSNotification*)notification; | 120 - (void)registrationComplete:(NSNotification*)notification; |
| 121 | 121 |
| 122 // Set the registration active and pass profile count parameters. | |
| 123 - (void)setRegistrationActive; | |
| 124 | |
| 122 // Called periodically to announce activity by pinging the Keystone server. | 125 // Called periodically to announce activity by pinging the Keystone server. |
| 123 - (void)markActive:(NSTimer*)timer; | 126 - (void)markActive:(NSTimer*)timer; |
| 124 | 127 |
| 125 // Called when an update check or update installation is complete. Posts the | 128 // Called when an update check or update installation is complete. Posts the |
| 126 // kAutoupdateStatusNotification notification to the default notification | 129 // kAutoupdateStatusNotification notification to the default notification |
| 127 // center. | 130 // center. |
| 128 - (void)updateStatus:(AutoupdateStatus)status version:(NSString*)version; | 131 - (void)updateStatus:(AutoupdateStatus)status version:(NSString*)version; |
| 129 | 132 |
| 130 // Returns the version of the currently-installed application on disk. | 133 // Returns the version of the currently-installed application on disk. |
| 131 - (NSString*)currentlyInstalledVersion; | 134 - (NSString*)currentlyInstalledVersion; |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 url_, ksr::KSRegistrationServerURLStringKey, | 487 url_, ksr::KSRegistrationServerURLStringKey, |
| 485 preserveTTToken, ksr::KSRegistrationPreserveTrustedTesterTokenKey, | 488 preserveTTToken, ksr::KSRegistrationPreserveTrustedTesterTokenKey, |
| 486 tagValue, ksr::KSRegistrationTagKey, | 489 tagValue, ksr::KSRegistrationTagKey, |
| 487 appInfoPlistPath, ksr::KSRegistrationTagPathKey, | 490 appInfoPlistPath, ksr::KSRegistrationTagPathKey, |
| 488 tagKey, ksr::KSRegistrationTagKeyKey, | 491 tagKey, ksr::KSRegistrationTagKeyKey, |
| 489 brandPath, ksr::KSRegistrationBrandPathKey, | 492 brandPath, ksr::KSRegistrationBrandPathKey, |
| 490 brandKey, ksr::KSRegistrationBrandKeyKey, | 493 brandKey, ksr::KSRegistrationBrandKeyKey, |
| 491 nil]; | 494 nil]; |
| 492 } | 495 } |
| 493 | 496 |
| 497 - (void)setRegistrationActive { | |
| 498 if (numProfiles_ == 0) { | |
| 499 [registration_ setActive]; | |
|
Mark Mentovai
2014/10/09 21:26:20
What’s the point of this? Why wouldn’t we want to
Mike Lerman
2014/10/10 15:32:29
There should never be zero profiles - that's inval
| |
| 500 return; | |
| 501 } | |
| 502 | |
| 503 NSError* reportingError = nil; | |
| 504 KSUnsignedReportingAttribute* numProfilesAttribute = | |
| 505 [KSUnsignedReportingAttribute | |
| 506 reportingAttributeWithValue:numProfiles_ | |
| 507 name:@"_NumAccounts" | |
| 508 aggregationType:kKSReportingAggregationSum | |
| 509 error:&reportingError]; | |
| 510 if (reportingError != nil) | |
| 511 VLOG(INFO) << [reportingError localizedDescription]; | |
|
Mark Mentovai
2014/10/09 21:26:20
What is VLOG(INFO)? VLOG() takes an integer argume
Mike Lerman
2014/10/10 15:32:29
I suppose so! VLOG and LOG should have a similar i
| |
| 512 | |
| 513 reportingError = nil; | |
| 514 KSUnsignedReportingAttribute* numSignedInProfilesAttribute = | |
| 515 [KSUnsignedReportingAttribute | |
| 516 reportingAttributeWithValue:numSignedInProfiles_ | |
| 517 name:@"_NumSignedIn" | |
| 518 aggregationType:kKSReportingAggregationSum | |
| 519 error:&reportingError]; | |
| 520 if (reportingError != nil) | |
| 521 VLOG(INFO) << [reportingError localizedDescription]; | |
| 522 | |
| 523 NSArray* profileCountsInformation = | |
| 524 [NSArray arrayWithObjects:numProfilesAttribute, | |
| 525 numSignedInProfilesAttribute, | |
| 526 nil]; | |
| 527 | |
| 528 reportingError = nil; | |
| 529 if (![registration_ setActiveWithReportingAttributes:profileCountsInformation | |
| 530 error:&reportingError]) | |
| 531 VLOG(INFO) << [reportingError localizedDescription]; | |
| 532 } | |
| 533 | |
| 494 - (void)registerWithKeystone { | 534 - (void)registerWithKeystone { |
| 495 [self updateStatus:kAutoupdateRegistering version:nil]; | 535 [self updateStatus:kAutoupdateRegistering version:nil]; |
| 496 | 536 |
| 497 NSDictionary* parameters = [self keystoneParameters]; | 537 NSDictionary* parameters = [self keystoneParameters]; |
| 498 BOOL result; | 538 BOOL result; |
| 499 { | 539 { |
| 500 // TODO(shess): Allows Keystone to throw an exception when | 540 // TODO(shess): Allows Keystone to throw an exception when |
| 501 // /usr/bin/python does not exist (really!). | 541 // /usr/bin/python does not exist (really!). |
| 502 // http://crbug.com/86221 and http://crbug.com/87931 | 542 // http://crbug.com/86221 and http://crbug.com/87931 |
| 503 base::mac::ScopedNSExceptionEnabler enabler; | 543 base::mac::ScopedNSExceptionEnabler enabler; |
| 504 result = [registration_ registerWithParameters:parameters]; | 544 result = [registration_ registerWithParameters:parameters]; |
| 505 } | 545 } |
| 506 if (!result) { | 546 if (!result) { |
| 507 [self updateStatus:kAutoupdateRegisterFailed version:nil]; | 547 [self updateStatus:kAutoupdateRegisterFailed version:nil]; |
| 508 return; | 548 return; |
| 509 } | 549 } |
| 510 | 550 |
| 511 // Upon completion, ksr::KSRegistrationDidCompleteNotification will be | 551 // Upon completion, ksr::KSRegistrationDidCompleteNotification will be |
| 512 // posted, and -registrationComplete: will be called. | 552 // posted, and -registrationComplete: will be called. |
| 513 | 553 |
| 514 // Mark an active RIGHT NOW; don't wait an hour for the first one. | 554 // Mark an active RIGHT NOW; don't wait an hour for the first one. |
| 515 [registration_ setActive]; | 555 [self setRegistrationActive]; |
| 516 | 556 |
| 517 // Set up hourly activity pings. | 557 // Set up hourly activity pings. |
| 518 timer_ = [NSTimer scheduledTimerWithTimeInterval:60 * 60 // One hour | 558 timer_ = [NSTimer scheduledTimerWithTimeInterval:60 * 60 // One hour |
| 519 target:self | 559 target:self |
| 520 selector:@selector(markActive:) | 560 selector:@selector(markActive:) |
| 521 userInfo:registration_ | 561 userInfo:nil |
| 522 repeats:YES]; | 562 repeats:YES]; |
| 523 } | 563 } |
| 524 | 564 |
| 525 - (void)registrationComplete:(NSNotification*)notification { | 565 - (void)registrationComplete:(NSNotification*)notification { |
| 526 NSDictionary* userInfo = [notification userInfo]; | 566 NSDictionary* userInfo = [notification userInfo]; |
| 527 if ([[userInfo objectForKey:ksr::KSRegistrationStatusKey] boolValue]) { | 567 if ([[userInfo objectForKey:ksr::KSRegistrationStatusKey] boolValue]) { |
| 528 if ([self isSystemTicketDoomed]) { | 568 if ([self isSystemTicketDoomed]) { |
| 529 [self updateStatus:kAutoupdateNeedsPromotion version:nil]; | 569 [self updateStatus:kAutoupdateNeedsPromotion version:nil]; |
| 530 } else { | 570 } else { |
| 531 [self updateStatus:kAutoupdateRegistered version:nil]; | 571 [self updateStatus:kAutoupdateRegistered version:nil]; |
| 532 } | 572 } |
| 533 } else { | 573 } else { |
| 534 // Dump registration_? | 574 // Dump registration_? |
| 535 [self updateStatus:kAutoupdateRegisterFailed version:nil]; | 575 [self updateStatus:kAutoupdateRegisterFailed version:nil]; |
| 536 } | 576 } |
| 537 } | 577 } |
| 538 | 578 |
| 539 - (void)stopTimer { | 579 - (void)stopTimer { |
| 540 [timer_ invalidate]; | 580 [timer_ invalidate]; |
| 541 } | 581 } |
| 542 | 582 |
| 543 - (void)markActive:(NSTimer*)timer { | 583 - (void)markActive:(NSTimer*)timer { |
| 544 KSRegistration* ksr = [timer userInfo]; | 584 [self setRegistrationActive]; |
| 545 [ksr setActive]; | |
| 546 } | 585 } |
| 547 | 586 |
| 548 - (void)checkForUpdate { | 587 - (void)checkForUpdate { |
| 549 DCHECK(![self asyncOperationPending]); | 588 DCHECK(![self asyncOperationPending]); |
| 550 | 589 |
| 551 if (!registration_) { | 590 if (!registration_) { |
| 552 [self updateStatus:kAutoupdateCheckFailed version:nil]; | 591 [self updateStatus:kAutoupdateCheckFailed version:nil]; |
| 553 return; | 592 return; |
| 554 } | 593 } |
| 555 | 594 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1042 NSString* tagSuffix = @""; | 1081 NSString* tagSuffix = @""; |
| 1043 if (ObsoleteSystemMac::Has32BitOnlyCPU()) { | 1082 if (ObsoleteSystemMac::Has32BitOnlyCPU()) { |
| 1044 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"]; | 1083 tagSuffix = [tagSuffix stringByAppendingString:@"-32bit"]; |
| 1045 } | 1084 } |
| 1046 if ([self wantsFullInstaller]) { | 1085 if ([self wantsFullInstaller]) { |
| 1047 tagSuffix = [tagSuffix stringByAppendingString:@"-full"]; | 1086 tagSuffix = [tagSuffix stringByAppendingString:@"-full"]; |
| 1048 } | 1087 } |
| 1049 return tagSuffix; | 1088 return tagSuffix; |
| 1050 } | 1089 } |
| 1051 | 1090 |
| 1091 | |
| 1092 - (void)updateProfileCountsWithNumProfiles:(uint32_t)numProfiles | |
| 1093 numSignedInProfiles:(uint32_t)numSignedInProfiles { | |
| 1094 numProfiles_ = numProfiles; | |
| 1095 numSignedInProfiles_ = numSignedInProfiles; | |
| 1096 } | |
| 1097 | |
| 1052 @end // @implementation KeystoneGlue | 1098 @end // @implementation KeystoneGlue |
| 1053 | 1099 |
| 1054 namespace { | 1100 namespace { |
| 1055 | 1101 |
| 1056 std::string BrandCodeInternal() { | 1102 std::string BrandCodeInternal() { |
| 1057 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; | 1103 KeystoneGlue* keystone_glue = [KeystoneGlue defaultKeystoneGlue]; |
| 1058 NSString* brand_path = [keystone_glue brandFilePath]; | 1104 NSString* brand_path = [keystone_glue brandFilePath]; |
| 1059 | 1105 |
| 1060 if (![brand_path length]) | 1106 if (![brand_path length]) |
| 1061 return std::string(); | 1107 return std::string(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1084 return [KeystoneGlue defaultKeystoneGlue] != nil; | 1130 return [KeystoneGlue defaultKeystoneGlue] != nil; |
| 1085 } | 1131 } |
| 1086 | 1132 |
| 1087 base::string16 CurrentlyInstalledVersion() { | 1133 base::string16 CurrentlyInstalledVersion() { |
| 1088 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; | 1134 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
| 1089 NSString* version = [keystoneGlue currentlyInstalledVersion]; | 1135 NSString* version = [keystoneGlue currentlyInstalledVersion]; |
| 1090 return base::SysNSStringToUTF16(version); | 1136 return base::SysNSStringToUTF16(version); |
| 1091 } | 1137 } |
| 1092 | 1138 |
| 1093 } // namespace keystone_glue | 1139 } // namespace keystone_glue |
| OLD | NEW |