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

Side by Side Diff: chrome/browser/mac/keystone_glue.mm

Issue 9240004: Transition to base/mac/bundle_locations.h step 3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/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 "base/bind.h" 12 #include "base/bind.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/mac/bundle_locations.h"
16 #include "base/mac/mac_util.h" 17 #include "base/mac/mac_util.h"
17 #include "base/mac/scoped_nsautorelease_pool.h" 18 #include "base/mac/scoped_nsautorelease_pool.h"
18 #include "base/mac/scoped_nsexception_enabler.h" 19 #include "base/mac/scoped_nsexception_enabler.h"
19 #include "base/memory/ref_counted.h" 20 #include "base/memory/ref_counted.h"
20 #include "base/sys_string_conversions.h" 21 #include "base/sys_string_conversions.h"
21 #include "base/threading/worker_pool.h" 22 #include "base/threading/worker_pool.h"
22 #include "chrome/browser/mac/authorization_util.h" 23 #include "chrome/browser/mac/authorization_util.h"
23 #import "chrome/browser/mac/keystone_registration.h" 24 #import "chrome/browser/mac/keystone_registration.h"
24 #include "chrome/common/chrome_constants.h" 25 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_version_info.h" 26 #include "chrome/common/chrome_version_info.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 [appPath_ release]; 254 [appPath_ release];
254 [url_ release]; 255 [url_ release];
255 [version_ release]; 256 [version_ release];
256 [channel_ release]; 257 [channel_ release];
257 [registration_ release]; 258 [registration_ release];
258 [[NSNotificationCenter defaultCenter] removeObserver:self]; 259 [[NSNotificationCenter defaultCenter] removeObserver:self];
259 [super dealloc]; 260 [super dealloc];
260 } 261 }
261 262
262 - (NSDictionary*)infoDictionary { 263 - (NSDictionary*)infoDictionary {
263 // Use [NSBundle mainBundle] to get the application's own bundle identifier 264 // Use base::mac::OuterBundle() to get the Chrome app's own bundle identifier
264 // and path, not the framework's. For auto-update, the application is 265 // and path, not the framework's. For auto-update, the application is
265 // what's significant here: it's used to locate the outermost part of the 266 // what's significant here: it's used to locate the outermost part of the
266 // application for the existence checker and other operations that need to 267 // application for the existence checker and other operations that need to
267 // see the entire application bundle. 268 // see the entire application bundle.
268 return [[NSBundle mainBundle] infoDictionary]; 269 return [base::mac::OuterBundle() infoDictionary];
269 } 270 }
270 271
271 - (void)loadParameters { 272 - (void)loadParameters {
272 NSBundle* appBundle = [NSBundle mainBundle]; 273 NSBundle* appBundle = base::mac::OuterBundle();
273 NSDictionary* infoDictionary = [self infoDictionary]; 274 NSDictionary* infoDictionary = [self infoDictionary];
274 275
275 NSString* productID = [infoDictionary objectForKey:@"KSProductID"]; 276 NSString* productID = [infoDictionary objectForKey:@"KSProductID"];
276 if (productID == nil) { 277 if (productID == nil) {
277 productID = [appBundle bundleIdentifier]; 278 productID = [appBundle bundleIdentifier];
278 } 279 }
279 280
280 NSString* appPath = [appBundle bundlePath]; 281 NSString* appPath = [appBundle bundlePath];
281 NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"]; 282 NSString* url = [infoDictionary objectForKey:@"KSUpdateURL"];
282 NSString* version = [infoDictionary objectForKey:kVersionKey]; 283 NSString* version = [infoDictionary objectForKey:kVersionKey];
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 738
738 // Check the outermost bundle directory, the main executable path, and the 739 // Check the outermost bundle directory, the main executable path, and the
739 // framework directory. It may be enough to just look at the outermost 740 // framework directory. It may be enough to just look at the outermost
740 // bundle directory, but checking an interior file and directory can be 741 // bundle directory, but checking an interior file and directory can be
741 // helpful in case permissions are set differently only on the outermost 742 // helpful in case permissions are set differently only on the outermost
742 // directory. An interior file and directory are both checked because some 743 // directory. An interior file and directory are both checked because some
743 // file operations, such as Snow Leopard's Finder's copy operation when 744 // file operations, such as Snow Leopard's Finder's copy operation when
744 // authenticating, may actually result in different ownership being applied 745 // authenticating, may actually result in different ownership being applied
745 // to files and directories. 746 // to files and directories.
746 NSFileManager* fileManager = [NSFileManager defaultManager]; 747 NSFileManager* fileManager = [NSFileManager defaultManager];
747 NSString* executablePath = [[NSBundle mainBundle] executablePath]; 748 NSString* executablePath = [base::mac::OuterBundle() executablePath];
748 NSString* frameworkPath = [base::mac::MainAppBundle() bundlePath]; 749 NSString* frameworkPath = [base::mac::MainAppBundle() bundlePath];
749 return ![fileManager isWritableFileAtPath:appPath_] || 750 return ![fileManager isWritableFileAtPath:appPath_] ||
750 ![fileManager isWritableFileAtPath:executablePath] || 751 ![fileManager isWritableFileAtPath:executablePath] ||
751 ![fileManager isWritableFileAtPath:frameworkPath]; 752 ![fileManager isWritableFileAtPath:frameworkPath];
752 } 753 }
753 754
754 - (BOOL)wantsPromotion { 755 - (BOOL)wantsPromotion {
755 if ([self needsPromotion]) { 756 if ([self needsPromotion]) {
756 return YES; 757 return YES;
757 } 758 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 return [KeystoneGlue defaultKeystoneGlue] != nil; 984 return [KeystoneGlue defaultKeystoneGlue] != nil;
984 } 985 }
985 986
986 string16 CurrentlyInstalledVersion() { 987 string16 CurrentlyInstalledVersion() {
987 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; 988 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue];
988 NSString* version = [keystoneGlue currentlyInstalledVersion]; 989 NSString* version = [keystoneGlue currentlyInstalledVersion];
989 return base::SysNSStringToUTF16(version); 990 return base::SysNSStringToUTF16(version);
990 } 991 }
991 992
992 } // namespace keystone_glue 993 } // namespace keystone_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698