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

Unified Diff: chrome/common/chrome_paths_mac.mm

Issue 12663023: [mac] Make app shims look in the correct user data dir on Canary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 9 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: chrome/common/chrome_paths_mac.mm
diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm
index ce990470a2633814246c29f82a538bf1fe050d93..ccb6a3d69d917d97de728b3ada1bd6239b9157b5 100644
--- a/chrome/common/chrome_paths_mac.mm
+++ b/chrome/common/chrome_paths_mac.mm
@@ -51,23 +51,13 @@ NSBundle* OuterAppBundleInternal() {
}
#endif // !defined(OS_IOS)
-const char* ProductDirNameInternal() {
+char* ProductDirNameForBundle(NSBundle* chrome_bundle) {
const char* product_dir_name = NULL;
#if !defined(OS_IOS)
base::mac::ScopedNSAutoreleasePool pool;
- // Use OuterAppBundle() to get the main app's bundle. This key needs to live
- // in the main app's bundle because it will be set differently on the canary
- // channel, and the autoupdate system dictates that there can be no
- // differences between channels within the versioned directory. This would
- // normally use base::mac::FrameworkBundle(), but that references the
- // framework bundle within the versioned directory. Ordinarily, the profile
- // 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
Mark Mentovai 2013/04/03 17:52:01 #else DCHECK(!chrome_bundle) to ensure that nobod
@@ -92,23 +82,42 @@ 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 = ProductDirNameForBundle(nil);
+#else
+ // Use OuterAppBundle() to get the main app's bundle. This key needs to live
+ // in the main app's bundle because it will be set differently on the canary
+ // channel, and the autoupdate system dictates that there can be no
+ // differences between channels within the versioned directory. This would
+ // normally use base::mac::FrameworkBundle(), but that references the
+ // framework bundle within the versioned directory. Ordinarily, the profile
+ // 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.
+ static const char* product_dir_name =
+ ProductDirNameForBundle(chrome::OuterAppBundle());
+#endif
return std::string(product_dir_name);
}
-} // namespace
-
-namespace chrome {
-
-bool GetDefaultUserDataDirectory(base::FilePath* result) {
+bool GetDefaultUserDataDirectoryForProduct(const std::string& product_dir,
+ 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;
}
+} // namespace
+
+namespace chrome {
+
+bool GetDefaultUserDataDirectory(base::FilePath* result) {
+ return GetDefaultUserDataDirectoryForProduct(ProductDirName(), result);
+}
+
bool GetUserDocumentsDirectory(base::FilePath* result) {
return base::mac::GetUserDirectory(NSDocumentDirectory, result);
}
@@ -218,6 +227,12 @@ NSBundle* OuterAppBundle() {
return bundle;
}
+bool GetUserDataDirectoryForBrowserBundle(
+ NSBundle* bundle, base::FilePath* result) {
Mark Mentovai 2013/04/03 17:52:01 Same thing with the wrapping on this line.
+ scoped_ptr_malloc<char> product_dir_name = ProductDirNameForBundle(bundle);
+ return GetDefaultUserDataDirectoryForProduct(product_dir_name.get(), result);
+}
+
#endif // !defined(OS_IOS)
bool ProcessNeedsProfileDir(const std::string& process_type) {
« chrome/common/chrome_paths_internal.h ('K') | « chrome/common/chrome_paths_internal.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698