summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 02:31:42 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-19 02:31:42 +0000
commit927e90a3f38b7a0022f30aeec9f799acb8473c6e (patch)
treeb56204476b5fae54d8d99dea7bd8b32404f15cb9 /chrome/common
parent37d55339d00eedac6d1b1773628f5473862fbe72 (diff)
downloadchromium_src-927e90a3f38b7a0022f30aeec9f799acb8473c6e.zip
chromium_src-927e90a3f38b7a0022f30aeec9f799acb8473c6e.tar.gz
chromium_src-927e90a3f38b7a0022f30aeec9f799acb8473c6e.tar.bz2
Allow the product directory name to vary based on a setting in the outer
browser .app's Info.plist. This supports the Mac canary. BUG=79814 TEST=Set CrProductDirName in Info.plist to a new value (like Google/Chrome79814) and launch the browser. You should be working with a new profile. The profile should be found at ~/Library/Application Support/Google/Chrome79814. It should work out of a cache directory at ~/Library/Caches/Google/Chrome79814. Review URL: http://codereview.chromium.org/6879021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_paths_mac.mm80
1 files changed, 62 insertions, 18 deletions
diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm
index fc76b53..8a053e3 100644
--- a/chrome/common/chrome_paths_mac.mm
+++ b/chrome/common/chrome_paths_mac.mm
@@ -1,44 +1,88 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/chrome_paths_internal.h"
-#import <Cocoa/Cocoa.h>
+#import <Foundation/Foundation.h>
#include "base/base_paths.h"
#include "base/logging.h"
-#include "base/mac/mac_util.h"
+#import "base/mac/foundation_util.h"
+#import "base/mac/mac_util.h"
#include "base/path_service.h"
#include "chrome/common/chrome_constants.h"
namespace {
+
const FilePath* g_override_versioned_directory = NULL;
-} // namespace
-namespace chrome {
+NSBundle* OuterAppBundle() {
+ if (!base::mac::AmIBundled()) {
+ // If unbundled (as in a test), there's no app bundle.
+ return nil;
+ }
-bool GetDefaultUserDataDirectory(FilePath* result) {
- bool success = false;
- if (result && PathService::Get(base::DIR_APP_DATA, result)) {
+ if (!base::mac::IsBackgroundOnlyProcess()) {
+ // Shortcut: in the browser process, just return the main app bundle.
+ return [NSBundle mainBundle];
+ }
+
+ // From C.app/Contents/Versions/1.2.3.4, go up three steps to get to C.app.
+ FilePath versioned_dir = chrome::GetVersionedDirectory();
+ FilePath outer_app_dir = versioned_dir.DirName().DirName().DirName();
+ const char* outer_app_dir_c = outer_app_dir.value().c_str();
+ NSString* outer_app_dir_ns = [NSString stringWithUTF8String:outer_app_dir_c];
+
+ return [NSBundle bundleWithPath:outer_app_dir_ns];
+}
+
+const char* ProductDirNameInternal() {
+ // 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::MainAppBundle(), 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 = OuterAppBundle();
+ NSString* product_dir_name_ns =
+ [bundle objectForInfoDictionaryKey:@"CrProductDirName"];
+ const char* product_dir_name = [product_dir_name_ns fileSystemRepresentation];
+
+ if (!product_dir_name) {
#if defined(GOOGLE_CHROME_BUILD)
- *result = result->Append("Google").Append("Chrome");
+ product_dir_name = "Google/Chrome";
#else
- *result = result->Append("Chromium");
+ product_dir_name = "Chromium";
#endif
- success = true;
}
- return success;
+
+ return product_dir_name;
+}
+
+// ProductDirName returns the name of the directory inside
+// ~/Library/Application Support that should hold the product application
+// data. This can be overridden by setting the CrProductDirName key in the
+// outer browser .app's Info.plist. The default is "Google/Chrome" for
+// officially-branded builds, and "Chromium" for unbranded builds. For the
+// official canary channel, the Info.plist will have CrProductDirName set
+// to "Google/Chrome Canary".
+std::string ProductDirName() {
+ static const char* product_dir_name = ProductDirNameInternal();
+ return std::string(product_dir_name);
}
-bool GetChromeFrameUserDataDirectory(FilePath* result) {
+} // namespace
+
+namespace chrome {
+
+bool GetDefaultUserDataDirectory(FilePath* result) {
bool success = false;
if (result && PathService::Get(base::DIR_APP_DATA, result)) {
-#if defined(GOOGLE_CHROME_BUILD)
- *result = result->Append("Google").Append("Chrome Frame");
-#else
- *result = result->Append("Chrome Frame");
-#endif
+ *result = result->Append(ProductDirName());
success = true;
}
return success;