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

Side by Side Diff: base/mac_util.mm

Issue 159668: First cut at Safari Import - Home Page & History Only. (Closed)
Patch Set: Fix Stuart's comments. 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
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> 7 #include <Carbon/Carbon.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // No threading worries since NSBundle isn't thread safe. 47 // No threading worries since NSBundle isn't thread safe.
48 static NSBundle* g_override_app_bundle = nil; 48 static NSBundle* g_override_app_bundle = nil;
49 49
50 NSBundle* MainAppBundle() { 50 NSBundle* MainAppBundle() {
51 if (g_override_app_bundle) 51 if (g_override_app_bundle)
52 return g_override_app_bundle; 52 return g_override_app_bundle;
53 return [NSBundle mainBundle]; 53 return [NSBundle mainBundle];
54 } 54 }
55 55
56 FilePath GetUserLibraryPath() {
57 NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
58 NSUserDomainMask, YES);
59 if ([dirs count] == 0)
60 return FilePath();
61
62 NSString* library_dir = [dirs objectAtIndex:0];
63 const char* library_dir_path = [library_dir fileSystemRepresentation];
64 if (!library_dir_path)
65 return FilePath();
66
67 return FilePath(library_dir_path);
68 }
69
56 void SetOverrideAppBundle(NSBundle* bundle) { 70 void SetOverrideAppBundle(NSBundle* bundle) {
57 [g_override_app_bundle release]; 71 [g_override_app_bundle release];
58 g_override_app_bundle = [bundle retain]; 72 g_override_app_bundle = [bundle retain];
59 } 73 }
60 74
61 void SetOverrideAppBundlePath(const FilePath& file_path) { 75 void SetOverrideAppBundlePath(const FilePath& file_path) {
62 NSString* path = base::SysUTF8ToNSString(file_path.value()); 76 NSString* path = base::SysUTF8ToNSString(file_path.value());
63 NSBundle* bundle = [NSBundle bundleWithPath:path]; 77 NSBundle* bundle = [NSBundle bundleWithPath:path];
64 DCHECK(bundle) << "failed to load the bundle: " << file_path.value(); 78 DCHECK(bundle) << "failed to load the bundle: " << file_path.value();
65 79
66 SetOverrideAppBundle(bundle); 80 SetOverrideAppBundle(bundle);
67 } 81 }
68 82
69 } // namespace mac_util 83 } // namespace mac_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698