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

Unified Diff: chrome/common/mac/app_mode_chrome_locator.mm

Issue 501303002: [Mac] Make app shims load the same framework version as the running Chrome process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase Created 6 years, 4 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/mac/app_mode_chrome_locator.mm
diff --git a/chrome/common/mac/app_mode_chrome_locator.mm b/chrome/common/mac/app_mode_chrome_locator.mm
index 3cd5302cc46cf9b1b8679c84026230719484aa94..923e671d804e356e6e42cfd1a17cd96ff6e8081d 100644
--- a/chrome/common/mac/app_mode_chrome_locator.mm
+++ b/chrome/common/mac/app_mode_chrome_locator.mm
@@ -8,6 +8,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/common/chrome_constants.h"
@@ -24,9 +25,14 @@ bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle) {
return true;
}
+NSString* GetVersionedPath(NSString* bundle_path, NSString* version) {
+ return [NSString
+ pathWithComponents:@[ bundle_path, @"Contents", @"Versions", version ]];
+}
+
bool GetChromeBundleInfo(const base::FilePath& chrome_bundle,
+ const std::string& version_str,
base::FilePath* executable_path,
- base::string16* raw_version_str,
base::FilePath* version_path,
base::FilePath* framework_shlib_path) {
using base::mac::ObjCCast;
@@ -37,22 +43,23 @@ bool GetChromeBundleInfo(const base::FilePath& chrome_bundle,
if (!cr_bundle)
return false;
- // Read raw version string.
- NSString* cr_version =
- ObjCCast<NSString>(
- [cr_bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
- if (!cr_version)
- return false;
-
// Get versioned directory.
- NSArray* cr_versioned_path_components =
- [NSArray arrayWithObjects:cr_bundle_path,
- @"Contents",
- @"Versions",
- cr_version,
- nil];
- NSString* cr_versioned_path =
- [NSString pathWithComponents:cr_versioned_path_components];
+ NSString* cr_versioned_path;
+ if (!version_str.empty()) {
+ cr_versioned_path =
+ GetVersionedPath(cr_bundle_path, base::SysUTF8ToNSString(version_str));
+ }
+
+ if (version_str.empty() ||
+ !base::PathExists(base::mac::NSStringToFilePath(cr_versioned_path))) {
+ // Read version string.
+ NSString* cr_version = ObjCCast<NSString>(
+ [cr_bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]);
+ if (!cr_version)
+ return false;
+
+ cr_versioned_path = GetVersionedPath(cr_bundle_path, cr_version);
+ }
// Get the framework path.
NSString* cr_bundle_exe =
@@ -90,7 +97,6 @@ bool GetChromeBundleInfo(const base::FilePath& chrome_bundle,
// Everything OK, copy output parameters.
*executable_path = base::mac::NSStringToFilePath([cr_bundle executablePath]);
- *raw_version_str = base::SysNSStringToUTF16(cr_version);
*version_path = base::mac::NSStringToFilePath(cr_versioned_path);
*framework_shlib_path =
base::mac::NSStringToFilePath(cr_framework_shlib_path);
« no previous file with comments | « chrome/common/mac/app_mode_chrome_locator.h ('k') | chrome/common/mac/app_mode_chrome_locator_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698