Chromium Code Reviews| Index: chrome/app/app_mode_loader_mac.mm |
| diff --git a/chrome/app/app_mode_loader_mac.mm b/chrome/app/app_mode_loader_mac.mm |
| index 7a489ebea0ca0b02663cf2e75a989be7a6b9f357..cd938a04a8436ba3412081558cc42af11b912c42 100644 |
| --- a/chrome/app/app_mode_loader_mac.mm |
| +++ b/chrome/app/app_mode_loader_mac.mm |
| @@ -43,6 +43,27 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) { |
| NSBundle* app_bundle = [NSBundle mainBundle]; |
| CHECK(app_bundle) << "couldn't get loader bundle"; |
| + // Read information about the this app shortcut from the Info.plist. |
| + // Don't check for null-ness on optional items. |
| + NSDictionary* info_plist = [app_bundle infoDictionary]; |
| + CHECK(info_plist) << "couldn't get loader Info.plist"; |
| + |
| + info->app_mode_id = SysNSStringToUTF8( |
| + [info_plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); |
| + CHECK(info->app_mode_id.size()) << "couldn't get app shortcut ID"; |
| + |
| + info->app_mode_name = SysNSStringToUTF16( |
| + [info_plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); |
| + |
| + info->app_mode_url = SysNSStringToUTF8( |
| + [info_plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); |
| + |
| + info->user_data_dir = base::mac::NSStringToFilePath( |
| + [info_plist objectForKey:app_mode::kCrAppModeUserDataDirKey]); |
| + |
| + info->profile_dir = base::mac::NSStringToFilePath( |
| + [info_plist objectForKey:app_mode::kCrAppModeProfileDirKey]); |
| + |
| // ** 1: Get path to outer Chrome bundle. |
| // Get the bundle ID of the browser that created this app bundle. |
| NSString* cr_bundle_id = base::mac::ObjCCast<NSString>( |
| @@ -68,14 +89,27 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) { |
| } |
| } |
| + // The user_data_dir for shims actually contains the app_data_path. |
|
tapted
2014/08/26 07:12:47
for consistency: // ** 2: Read the running Chrome
jackhou1
2014/08/26 08:15:14
Done.
|
| + // I.e. <user_data_dir>/<profile_dir>/Web Applications/_crx_extensionid/ |
| + base::FilePath user_data_dir = |
|
tapted
2014/08/26 07:12:47
Can you keep the ChromeAppModeInfo populating toge
jackhou1
2014/08/26 08:15:14
Done.
|
| + info->user_data_dir.DirName().DirName().DirName(); |
| + CHECK(!user_data_dir.empty()); |
| + |
| + // Check if there is a version file written by Chrome. If so, use it to load |
| + // the correct version of the framework. If not, app_mode::GetChromeBundleInfo |
| + // will just load the latest version. |
| + base::FilePath cr_version_str; |
| + base::ReadSymbolicLink( |
| + user_data_dir.Append(app_mode::kAppShimVersionSymlinkName), |
| + &cr_version_str); |
| + |
| // ** 2: Read information from the Chrome bundle. |
| base::FilePath executable_path; |
| - base::string16 raw_version_str; |
| base::FilePath version_path; |
| base::FilePath framework_shlib_path; |
| if (!app_mode::GetChromeBundleInfo(cr_bundle_path, |
| + cr_version_str.value(), |
|
tapted
2014/08/26 07:12:47
I think we can only pass this in when we know for
jackhou1
2014/08/26 08:15:14
Hmm... I think we can read the SingletonLock to co
tapted
2014/08/26 08:43:47
yeah I think that should be OK - it's only a remot
jackhou1
2014/08/27 03:04:52
Reading SingletonLock doesn't seem to work, maybe
|
| &executable_path, |
| - &raw_version_str, |
| &version_path, |
| &framework_shlib_path)) { |
| LOG(FATAL) << "Couldn't ready Chrome bundle info"; |
| @@ -88,27 +122,6 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) { |
| info->chrome_versioned_path = version_path; |
| info->app_mode_bundle_path = app_mode_bundle_path; |
| - // Read information about the this app shortcut from the Info.plist. |
| - // Don't check for null-ness on optional items. |
| - NSDictionary* info_plist = [app_bundle infoDictionary]; |
| - CHECK(info_plist) << "couldn't get loader Info.plist"; |
| - |
| - info->app_mode_id = SysNSStringToUTF8( |
| - [info_plist objectForKey:app_mode::kCrAppModeShortcutIDKey]); |
| - CHECK(info->app_mode_id.size()) << "couldn't get app shortcut ID"; |
| - |
| - info->app_mode_name = SysNSStringToUTF16( |
| - [info_plist objectForKey:app_mode::kCrAppModeShortcutNameKey]); |
| - |
| - info->app_mode_url = SysNSStringToUTF8( |
| - [info_plist objectForKey:app_mode::kCrAppModeShortcutURLKey]); |
| - |
| - info->user_data_dir = base::mac::NSStringToFilePath( |
| - [info_plist objectForKey:app_mode::kCrAppModeUserDataDirKey]); |
| - |
| - info->profile_dir = base::mac::NSStringToFilePath( |
| - [info_plist objectForKey:app_mode::kCrAppModeProfileDirKey]); |
| - |
| // Open the framework. |
| StartFun ChromeAppModeStart = NULL; |
| void* cr_dylib = dlopen(framework_shlib_path.value().c_str(), RTLD_LAZY); |