Index: chrome/common/chrome_paths_mac.mm |
diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm |
index ce990470a2633814246c29f82a538bf1fe050d93..dc65deb46aefa0ff4b9175cf1c3922184cd5ba26 100644 |
--- a/chrome/common/chrome_paths_mac.mm |
+++ b/chrome/common/chrome_paths_mac.mm |
@@ -51,7 +51,7 @@ NSBundle* OuterAppBundleInternal() { |
} |
#endif // !defined(OS_IOS) |
-const char* ProductDirNameInternal() { |
+char* ProductDirNameInternal(NSBundle* chrome_bundle) { |
const char* product_dir_name = NULL; |
#if !defined(OS_IOS) |
base::mac::ScopedNSAutoreleasePool pool; |
@@ -65,9 +65,8 @@ const char* ProductDirNameInternal() { |
// should not be accessed from non-browser processes, but those processes do |
// attempt to get the profile directory, so direct them to look in the outer |
// browser .app's Info.plist for the CrProductDirName key. |
- NSBundle* bundle = chrome::OuterAppBundle(); |
NSString* product_dir_name_ns = |
- [bundle objectForInfoDictionaryKey:@"CrProductDirName"]; |
+ [chrome_bundle objectForInfoDictionaryKey:@"CrProductDirName"]; |
product_dir_name = [product_dir_name_ns fileSystemRepresentation]; |
#endif |
@@ -92,7 +91,12 @@ const char* ProductDirNameInternal() { |
// official canary channel, the Info.plist will have CrProductDirName set |
// to "Google/Chrome Canary". |
std::string ProductDirName() { |
- static const char* product_dir_name = ProductDirNameInternal(); |
+#if defined(OS_IOS) |
+ static const char* product_dir_name = ProductDirNameInternal(nil); |
+#else |
+ static const char* product_dir_name = |
+ ProductDirNameInternal(chrome::OuterAppBundle()); |
+#endif |
return std::string(product_dir_name); |
} |
@@ -100,15 +104,20 @@ std::string ProductDirName() { |
namespace chrome { |
-bool GetDefaultUserDataDirectory(base::FilePath* result) { |
+bool GetDefaultUserDataDirectoryForProduct(const std::string& product_dir, |
Mark Mentovai
2013/03/22 18:08:41
This belongs in the anonymous namespace a few line
jeremya
2013/04/01 23:30:22
Done.
|
+ base::FilePath* result) { |
bool success = false; |
if (result && PathService::Get(base::DIR_APP_DATA, result)) { |
- *result = result->Append(ProductDirName()); |
+ *result = result->Append(product_dir); |
success = true; |
} |
return success; |
} |
+bool GetDefaultUserDataDirectory(base::FilePath* result) { |
+ return GetDefaultUserDataDirectoryForProduct(ProductDirName(), result); |
+} |
+ |
bool GetUserDocumentsDirectory(base::FilePath* result) { |
return base::mac::GetUserDirectory(NSDocumentDirectory, result); |
} |
@@ -218,6 +227,15 @@ NSBundle* OuterAppBundle() { |
return bundle; |
} |
+bool GetUserDataDirectoryForBundle(NSBundle* bundle, base::FilePath* result) { |
+ char* product_dir_name = ProductDirNameInternal(bundle); |
Mark Mentovai
2013/03/22 18:08:41
I don’t like calling *Internal functions from some
Mark Mentovai
2013/03/22 18:08:41
You can stick the result into a scoped_ptr_malloc
jeremya
2013/04/01 23:30:22
Done.
jeremya
2013/04/01 23:30:22
Done.
|
+ bool success = |
+ GetDefaultUserDataDirectoryForProduct(product_dir_name, result); |
+ // ProductDirNameInternal() returns a strdup()'d string, so clean it up here. |
+ free(static_cast<void*>(product_dir_name)); |
+ return success; |
+} |
+ |
#endif // !defined(OS_IOS) |
bool ProcessNeedsProfileDir(const std::string& process_type) { |