Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "base/file_path.h" |
|
Mark Mentovai
2009/03/03 16:21:45
Leave the blank line between system and chrome hea
| |
| 10 #include "base/logging.h" | |
| 10 #include "base/scoped_cftyperef.h" | 11 #include "base/scoped_cftyperef.h" |
| 12 #include "base/sys_string_conversions.h" | |
| 11 | 13 |
| 12 namespace mac_util { | 14 namespace mac_util { |
| 13 | 15 |
| 14 std::string PathFromFSRef(const FSRef& ref) { | 16 std::string PathFromFSRef(const FSRef& ref) { |
| 15 scoped_cftyperef<CFURLRef> url( | 17 scoped_cftyperef<CFURLRef> url( |
| 16 CFURLCreateFromFSRef(kCFAllocatorDefault, &ref)); | 18 CFURLCreateFromFSRef(kCFAllocatorDefault, &ref)); |
| 17 NSString *path_string = [(NSURL *)url.get() path]; | 19 NSString *path_string = [(NSURL *)url.get() path]; |
| 18 return [path_string fileSystemRepresentation]; | 20 return [path_string fileSystemRepresentation]; |
| 19 } | 21 } |
| 20 | 22 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 34 | 36 |
| 35 FSCatalogInfo info; | 37 FSCatalogInfo info; |
| 36 if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, | 38 if (FSGetCatalogInfo(&fsref, kFSCatInfoNodeFlags, &info, |
| 37 NULL, NULL, NULL) != noErr) { | 39 NULL, NULL, NULL) != noErr) { |
| 38 return false; | 40 return false; |
| 39 } | 41 } |
| 40 | 42 |
| 41 return info.nodeFlags & kFSNodeIsDirectoryMask; | 43 return info.nodeFlags & kFSNodeIsDirectoryMask; |
| 42 } | 44 } |
| 43 | 45 |
| 46 // No threading worries since NSBundle isn't thread safe. | |
| 47 static NSBundle* g_override_app_bundle = nil; | |
| 48 | |
| 49 NSBundle* MainAppBundle() { | |
| 50 if (g_override_app_bundle) | |
| 51 return g_override_app_bundle; | |
| 52 return [NSBundle mainBundle]; | |
| 53 } | |
| 54 | |
| 55 void SetOverrideAppBundle(NSBundle* bundle) { | |
| 56 [g_override_app_bundle release]; | |
| 57 g_override_app_bundle = [bundle retain]; | |
| 58 } | |
| 59 | |
| 60 void SetOverrideAppBundlePath(const FilePath& file_path) { | |
| 61 NSString* path = base::SysUTF8ToNSString(file_path.value()); | |
| 62 NSBundle* bundle = [NSBundle bundleWithPath:path]; | |
| 63 DCHECK(bundle) << "failed to load the bundle: " << file_path.value(); | |
| 64 | |
| 65 SetOverrideAppBundle(bundle); | |
| 66 } | |
| 67 | |
| 44 } // namespace mac_util | 68 } // namespace mac_util |
| OLD | NEW |