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

Side by Side Diff: base/mac_util.mm

Issue 164332: Use real creator code for Keychain items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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
« no previous file with comments | « base/mac_util.h ('k') | chrome/browser/importer/importer.cc » ('j') | 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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 "base/mac_util.h" 5 #include "base/mac_util.h"
6 6
7 #include <Carbon/Carbon.h>
8 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
9 8
10 #include "base/file_path.h" 9 #include "base/file_path.h"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/scoped_cftyperef.h" 11 #include "base/scoped_cftyperef.h"
13 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
14 13
15 namespace mac_util { 14 namespace mac_util {
16 15
17 std::string PathFromFSRef(const FSRef& ref) { 16 std::string PathFromFSRef(const FSRef& ref) {
(...skipping 28 matching lines...) Expand all
46 45
47 // No threading worries since NSBundle isn't thread safe. 46 // No threading worries since NSBundle isn't thread safe.
48 static NSBundle* g_override_app_bundle = nil; 47 static NSBundle* g_override_app_bundle = nil;
49 48
50 NSBundle* MainAppBundle() { 49 NSBundle* MainAppBundle() {
51 if (g_override_app_bundle) 50 if (g_override_app_bundle)
52 return g_override_app_bundle; 51 return g_override_app_bundle;
53 return [NSBundle mainBundle]; 52 return [NSBundle mainBundle];
54 } 53 }
55 54
55 void SetOverrideAppBundle(NSBundle* bundle) {
56 if (bundle != g_override_app_bundle) {
57 [g_override_app_bundle release];
58 g_override_app_bundle = [bundle retain];
59 }
60 }
61
62 void SetOverrideAppBundlePath(const FilePath& file_path) {
63 NSString* path = base::SysUTF8ToNSString(file_path.value());
64 NSBundle* bundle = [NSBundle bundleWithPath:path];
65 DCHECK(bundle) << "failed to load the bundle: " << file_path.value();
66
67 SetOverrideAppBundle(bundle);
68 }
69
70 OSType CreatorCodeForCFBundleRef(CFBundleRef bundle) {
71 OSType creator;
72 CFBundleGetPackageInfo(bundle, NULL, &creator);
73 return creator;
74 }
75
76 OSType CreatorCodeForApplication() {
77 CFBundleRef bundle = CFBundleGetMainBundle();
78 if (!bundle)
79 return kUnknownType;
80
81 return CreatorCodeForCFBundleRef(bundle);
82 }
83
56 FilePath GetUserLibraryPath() { 84 FilePath GetUserLibraryPath() {
57 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, 85 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
58 NSUserDomainMask, YES); 86 NSUserDomainMask, YES);
59 if ([dirs count] == 0) 87 if ([dirs count] == 0)
60 return FilePath(); 88 return FilePath();
61 89
62 NSString* library_dir = [dirs objectAtIndex:0]; 90 NSString* library_dir = [dirs objectAtIndex:0];
63 const char* library_dir_path = [library_dir fileSystemRepresentation]; 91 const char* library_dir_path = [library_dir fileSystemRepresentation];
64 if (!library_dir_path) 92 if (!library_dir_path)
65 return FilePath(); 93 return FilePath();
66 94
67 return FilePath(library_dir_path); 95 return FilePath(library_dir_path);
68 } 96 }
69 97
70 void SetOverrideAppBundle(NSBundle* bundle) {
71 [g_override_app_bundle release];
72 g_override_app_bundle = [bundle retain];
73 }
74
75 void SetOverrideAppBundlePath(const FilePath& file_path) {
76 NSString* path = base::SysUTF8ToNSString(file_path.value());
77 NSBundle* bundle = [NSBundle bundleWithPath:path];
78 DCHECK(bundle) << "failed to load the bundle: " << file_path.value();
79
80 SetOverrideAppBundle(bundle);
81 }
82 98
83 } // namespace mac_util 99 } // namespace mac_util
OLDNEW
« no previous file with comments | « base/mac_util.h ('k') | chrome/browser/importer/importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698