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

Side by Side Diff: chrome/browser/ui/cocoa/keystone_glue.mm

Issue 6046009: Move base/mac_util.h to base/mac and use the base::mac namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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
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 #import "chrome/browser/ui/cocoa/keystone_glue.h" 5 #import "chrome/browser/ui/cocoa/keystone_glue.h"
6 6
7 #include <sys/param.h> 7 #include <sys/param.h>
8 #include <sys/mount.h> 8 #include <sys/mount.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #import "app/l10n_util_mac.h" 13 #import "app/l10n_util_mac.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/mac_util.h" 15 #include "base/mac/mac_util.h"
16 #include "base/mac/scoped_nsautorelease_pool.h" 16 #include "base/mac/scoped_nsautorelease_pool.h"
17 #include "base/sys_string_conversions.h" 17 #include "base/sys_string_conversions.h"
18 #include "base/ref_counted.h" 18 #include "base/ref_counted.h"
19 #include "base/task.h" 19 #include "base/task.h"
20 #include "base/threading/worker_pool.h" 20 #include "base/threading/worker_pool.h"
21 #include "chrome/browser/ui/cocoa/authorization_util.h" 21 #include "chrome/browser/ui/cocoa/authorization_util.h"
22 #include "chrome/common/chrome_constants.h" 22 #include "chrome/common/chrome_constants.h"
23 #include "grit/chromium_strings.h" 23 #include "grit/chromium_strings.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 25
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 } 432 }
433 return result; 433 return result;
434 } 434 }
435 435
436 - (BOOL)loadKeystoneRegistration { 436 - (BOOL)loadKeystoneRegistration {
437 if (!productID_ || !appPath_ || !url_ || !version_) 437 if (!productID_ || !appPath_ || !url_ || !version_)
438 return NO; 438 return NO;
439 439
440 // Load the KeystoneRegistration framework bundle if present. It lives 440 // Load the KeystoneRegistration framework bundle if present. It lives
441 // inside the framework, so use mac_util::MainAppBundle(); 441 // inside the framework, so use base::mac::MainAppBundle();
442 NSString* ksrPath = 442 NSString* ksrPath =
443 [[mac_util::MainAppBundle() privateFrameworksPath] 443 [[base::mac::MainAppBundle() privateFrameworksPath]
444 stringByAppendingPathComponent:@"KeystoneRegistration.framework"]; 444 stringByAppendingPathComponent:@"KeystoneRegistration.framework"];
445 NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath]; 445 NSBundle* ksrBundle = [NSBundle bundleWithPath:ksrPath];
446 [ksrBundle load]; 446 [ksrBundle load];
447 447
448 // Harness the KSRegistration class. 448 // Harness the KSRegistration class.
449 Class ksrClass = [ksrBundle classNamed:@"KSRegistration"]; 449 Class ksrClass = [ksrBundle classNamed:@"KSRegistration"];
450 KSRegistration* ksr = [ksrClass registrationWithProductID:productID_]; 450 KSRegistration* ksr = [ksrClass registrationWithProductID:productID_];
451 if (!ksr) 451 if (!ksr)
452 return NO; 452 return NO;
453 453
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // Check the outermost bundle directory, the main executable path, and the 715 // Check the outermost bundle directory, the main executable path, and the
716 // framework directory. It may be enough to just look at the outermost 716 // framework directory. It may be enough to just look at the outermost
717 // bundle directory, but checking an interior file and directory can be 717 // bundle directory, but checking an interior file and directory can be
718 // helpful in case permissions are set differently only on the outermost 718 // helpful in case permissions are set differently only on the outermost
719 // directory. An interior file and directory are both checked because some 719 // directory. An interior file and directory are both checked because some
720 // file operations, such as Snow Leopard's Finder's copy operation when 720 // file operations, such as Snow Leopard's Finder's copy operation when
721 // authenticating, may actually result in different ownership being applied 721 // authenticating, may actually result in different ownership being applied
722 // to files and directories. 722 // to files and directories.
723 NSFileManager* fileManager = [NSFileManager defaultManager]; 723 NSFileManager* fileManager = [NSFileManager defaultManager];
724 NSString* executablePath = [[NSBundle mainBundle] executablePath]; 724 NSString* executablePath = [[NSBundle mainBundle] executablePath];
725 NSString* frameworkPath = [mac_util::MainAppBundle() bundlePath]; 725 NSString* frameworkPath = [base::mac::MainAppBundle() bundlePath];
726 return ![fileManager isWritableFileAtPath:appPath_] || 726 return ![fileManager isWritableFileAtPath:appPath_] ||
727 ![fileManager isWritableFileAtPath:executablePath] || 727 ![fileManager isWritableFileAtPath:executablePath] ||
728 ![fileManager isWritableFileAtPath:frameworkPath]; 728 ![fileManager isWritableFileAtPath:frameworkPath];
729 } 729 }
730 730
731 - (BOOL)wantsPromotion { 731 - (BOOL)wantsPromotion {
732 // -needsPromotion checks these too, but this method doesn't necessarily 732 // -needsPromotion checks these too, but this method doesn't necessarily
733 // return NO just becuase -needsPromotion returns NO, so another check is 733 // return NO just becuase -needsPromotion returns NO, so another check is
734 // needed here. 734 // needed here.
735 if (![self isUserTicket] || [self isOnReadOnlyFilesystem]) { 735 if (![self isUserTicket] || [self isOnReadOnlyFilesystem]) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 // -[KSRegistration promoteWithParameters:authorization:] is currently 802 // -[KSRegistration promoteWithParameters:authorization:] is currently
803 // synchronous too, and this operation needs to happen before that one. 803 // synchronous too, and this operation needs to happen before that one.
804 // 804 //
805 // TODO(mark): Make asynchronous. That only makes sense if the promotion 805 // TODO(mark): Make asynchronous. That only makes sense if the promotion
806 // operation itself is asynchronous too. http://b/2290009. Hopefully, 806 // operation itself is asynchronous too. http://b/2290009. Hopefully,
807 // the Keystone promotion code will just be changed to do what preflight 807 // the Keystone promotion code will just be changed to do what preflight
808 // now does, and then the preflight script can be removed instead. 808 // now does, and then the preflight script can be removed instead.
809 // However, preflight operation (and promotion) should only be asynchronous 809 // However, preflight operation (and promotion) should only be asynchronous
810 // if the synchronous parameter is NO. 810 // if the synchronous parameter is NO.
811 NSString* preflightPath = 811 NSString* preflightPath =
812 [mac_util::MainAppBundle() pathForResource:@"keystone_promote_preflight" 812 [base::mac::MainAppBundle() pathForResource:@"keystone_promote_preflight"
813 ofType:@"sh"]; 813 ofType:@"sh"];
814 const char* preflightPathC = [preflightPath fileSystemRepresentation]; 814 const char* preflightPathC = [preflightPath fileSystemRepresentation];
815 const char* userBrandFile = NULL; 815 const char* userBrandFile = NULL;
816 const char* systemBrandFile = NULL; 816 const char* systemBrandFile = NULL;
817 if (brandFileType_ == kBrandFileTypeUser) { 817 if (brandFileType_ == kBrandFileTypeUser) {
818 // Running with user level brand file, promote to the system level. 818 // Running with user level brand file, promote to the system level.
819 userBrandFile = [UserBrandFilePath() fileSystemRepresentation]; 819 userBrandFile = [UserBrandFilePath() fileSystemRepresentation];
820 systemBrandFile = [SystemBrandFilePath() fileSystemRepresentation]; 820 systemBrandFile = [SystemBrandFilePath() fileSystemRepresentation];
821 } 821 }
822 const char* arguments[] = {userBrandFile, systemBrandFile, NULL}; 822 const char* arguments[] = {userBrandFile, systemBrandFile, NULL};
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 } 888 }
889 889
890 - (void)changePermissionsForPromotionAsync { 890 - (void)changePermissionsForPromotionAsync {
891 // NSBundle is not documented as being thread-safe. Do NSBundle operations 891 // NSBundle is not documented as being thread-safe. Do NSBundle operations
892 // on the main thread before jumping over to a WorkerPool-managed 892 // on the main thread before jumping over to a WorkerPool-managed
893 // thread to run the tool. 893 // thread to run the tool.
894 DCHECK([NSThread isMainThread]); 894 DCHECK([NSThread isMainThread]);
895 895
896 SEL selector = @selector(changePermissionsForPromotionWithTool:); 896 SEL selector = @selector(changePermissionsForPromotionWithTool:);
897 NSString* toolPath = 897 NSString* toolPath =
898 [mac_util::MainAppBundle() pathForResource:@"keystone_promote_postflight" 898 [base::mac::MainAppBundle() pathForResource:@"keystone_promote_postflight"
899 ofType:@"sh"]; 899 ofType:@"sh"];
900 900
901 PerformBridge::PostPerform(self, selector, toolPath); 901 PerformBridge::PostPerform(self, selector, toolPath);
902 } 902 }
903 903
904 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath { 904 - (void)changePermissionsForPromotionWithTool:(NSString*)toolPath {
905 const char* toolPathC = [toolPath fileSystemRepresentation]; 905 const char* toolPathC = [toolPath fileSystemRepresentation];
906 906
907 const char* appPathC = [appPath_ fileSystemRepresentation]; 907 const char* appPathC = [appPath_ fileSystemRepresentation];
908 const char* arguments[] = {appPathC, NULL}; 908 const char* arguments[] = {appPathC, NULL};
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 return [KeystoneGlue defaultKeystoneGlue] != nil; 948 return [KeystoneGlue defaultKeystoneGlue] != nil;
949 } 949 }
950 950
951 string16 CurrentlyInstalledVersion() { 951 string16 CurrentlyInstalledVersion() {
952 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; 952 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue];
953 NSString* version = [keystoneGlue currentlyInstalledVersion]; 953 NSString* version = [keystoneGlue currentlyInstalledVersion];
954 return base::SysNSStringToUTF16(version); 954 return base::SysNSStringToUTF16(version);
955 } 955 }
956 956
957 } // namespace keystone_glue 957 } // namespace keystone_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698