summaryrefslogtreecommitdiffstats
path: root/chrome/common/chrome_paths_mac.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 15:51:57 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 15:51:57 +0000
commit41cd00a4e364aad2b9a53964684e554aa3b675e8 (patch)
tree65c85ff828574d1c06a0a66a4a6dd5c8dfcf447f /chrome/common/chrome_paths_mac.mm
parent2b42f3d1a6ed5ba99f5b6f4ca907051040664f47 (diff)
downloadchromium_src-41cd00a4e364aad2b9a53964684e554aa3b675e8.zip
chromium_src-41cd00a4e364aad2b9a53964684e554aa3b675e8.tar.gz
chromium_src-41cd00a4e364aad2b9a53964684e554aa3b675e8.tar.bz2
Move the framework and helper application into a versioned directory in support
of unbreaking auto-update. BUG=14610 TEST= - The following bundles should be gone: - Chromium.app/Contents/Frameworks/Chromium Framework.framework - Chromium.app/Contents/Resources/Chromium Helper.app They should be replaced by: - Chromium.app/Contents/Versions/*/Chromium Framework.framework - Chromium.app/Contents/Versions/*/Chromium Helper.app - The application should continue to function properly and all tests should still pass. - The signed application should have the inner framework and helper application signed, and the outer application signed. The outer seal should permit unknown versions to be present in the Versions directory, but should protect the active versioned directory. - Auto-updating to an official build with this change should still work. Review URL: http://codereview.chromium.org/261031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28963 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/chrome_paths_mac.mm')
-rw-r--r--chrome/common/chrome_paths_mac.mm50
1 files changed, 36 insertions, 14 deletions
diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm
index 3ddd796..beb22f2 100644
--- a/chrome/common/chrome_paths_mac.mm
+++ b/chrome/common/chrome_paths_mac.mm
@@ -66,6 +66,40 @@ bool GetUserDesktop(FilePath* result) {
return success;
}
+FilePath GetVersionedDirectory() {
+ static FilePath path;
+
+ if (path.empty()) {
+ // Start out with the path to the running .app.
+ NSBundle* app_bundle = [NSBundle mainBundle];
+ path = FilePath([[app_bundle bundlePath] fileSystemRepresentation]);
+
+ if (mac_util::IsBackgroundOnlyProcess()) {
+ // path identifies the helper .app in the browser .app's versioned
+ // directory. Go up one level to get to the browser .app's versioned
+ // directory.
+ path = path.DirName();
+ } else {
+ // path identifies the browser .app. Go into its versioned directory.
+ // TODO(mark): Here, |version| comes from the outer .app bundle's
+ // Info.plist. In the event of an incomplete update, it may be possible
+ // for this value to be incorrect. Consider the case where the updater
+ // is able to update one, but not both, of the executable and the
+ // Info.plist. The executable may load one version of the framework,
+ // and the Info.plist may refer to another version. Ideally, the
+ // version would be available in a compile-time constant, or there would
+ // be a better way to detect the loaded framework version at runtime.
+ NSString* version =
+ [app_bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
+ path = path.Append("Contents").
+ Append("Versions").
+ Append([version fileSystemRepresentation]);
+ }
+ }
+
+ return path;
+}
+
FilePath GetFrameworkBundlePath() {
// It's tempting to use +[NSBundle bundleWithIdentifier:], but it's really
// slow (about 30ms on 10.5 and 10.6), despite Apple's documentation stating
@@ -76,21 +110,9 @@ FilePath GetFrameworkBundlePath() {
// needed to compute the framework's path are also effectively free, so that
// is the approach that is used here.
- // Start out with the path to the running .app.
- FilePath path([[[NSBundle mainBundle] bundlePath] fileSystemRepresentation]);
-
- if (mac_util::IsBackgroundOnlyProcess()) {
- // path identifies the helper .app in the browser .app's Contents/Resources
- // directory. Go up two levels to get to the browser's Contents directory.
- path = path.DirName().DirName();
- } else {
- // path identifies the browser .app. Go into the Contents directory.
- path = path.Append("Contents");
- }
-
// The framework bundle is at a known path and name from the browser .app's
- // Contents directory.
- return path.Append("Frameworks").Append(kFrameworkName);
+ // versioned directory.
+ return GetVersionedDirectory().Append(kFrameworkName);
}
} // namespace chrome