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

Unified Diff: base/mac/foundation_util.mm

Issue 9346013: Publish app shortcuts on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: base/mac/foundation_util.mm
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index 8ab02abce8e027f28678c8cd475a0be9dfbf5015..6d8563fa9f12ea096a1f4be2fa2c2a6a8a5f3858 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -73,9 +73,7 @@ FilePath PathForFrameworkBundleResource(CFStringRef resourceName) {
NSBundle* bundle = base::mac::FrameworkBundle();
NSString* resourcePath = [bundle pathForResource:(NSString*)resourceName
ofType:nil];
- if (!resourcePath)
- return FilePath();
- return FilePath([resourcePath fileSystemRepresentation]);
+ return NSStringToFilePath(resourcePath);
}
OSType CreatorCodeForCFBundleRef(CFBundleRef bundle) {
@@ -101,8 +99,7 @@ bool GetSearchPathDirectory(NSSearchPathDirectory directory,
if ([dirs count] < 1) {
return false;
}
- NSString* path = [dirs objectAtIndex:0];
- *result = FilePath([path fileSystemRepresentation]);
+ *result = NSStringToFilePath([dirs objectAtIndex:0]);
return true;
}
@@ -330,6 +327,20 @@ std::string GetValueFromDictionaryErrorMessage(
" instead";
}
+NSString* FilePathToNSString(const FilePath& path) {
+ if (path.empty())
+ return nil;
+ return [[NSFileManager defaultManager]
+ stringWithFileSystemRepresentation:path.value().c_str()
Mark Mentovai 2012/02/08 04:29:04 This is overkill. +[NSString stringWithUTF8String:
sail 2012/02/08 05:21:38 Done.
+ length:path.value().size()];
+}
+
+FilePath NSStringToFilePath(NSString* str) {
+ if (!str || ![str length])
Mark Mentovai 2012/02/08 04:29:04 You can simplify this to (![str length]).
sail 2012/02/08 05:21:38 Done.
+ return FilePath();
+ return FilePath([str fileSystemRepresentation]);
+}
+
} // namespace mac
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698