diff options
author | jackhou <jackhou@chromium.org> | 2014-08-28 20:23:04 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-29 03:24:57 +0000 |
commit | aeac008d6856655cda70806584e74c6e67c4ca62 (patch) | |
tree | 59ddf9a67ec3516b233954989558e6a13e4de3de | |
parent | ef97623cf0cacf08259c6733c457ff5fd85cc277 (diff) | |
download | chromium_src-aeac008d6856655cda70806584e74c6e67c4ca62.zip chromium_src-aeac008d6856655cda70806584e74c6e67c4ca62.tar.gz chromium_src-aeac008d6856655cda70806584e74c6e67c4ca62.tar.bz2 |
[Mac] Make app shims load the same framework version as the running Chrome process.
When a new version of Chrome has been downloaded but the old version is
still running, any app shims that start will load the new framework version.
This is problematic as the IPC codes (See ipc_message_start.h) may not match.
With this CL, app shims will check a version file written by the Chrome
process and load the corresponding framework version.
This also increments kCurrentAppShortcutsVersion, which causes all app
shims to be rebuilt.
This also moves AppModeChromeLocatorTest to browser_tests. It's not really
necessary for them to have their own target (app_mode_app_tests), and this
way they actually get run.
BUG=405347
Review URL: https://codereview.chromium.org/501303002
Cr-Commit-Position: refs/heads/master@{#292563}
-rw-r--r-- | apps/app_shim/DEPS | 1 | ||||
-rw-r--r-- | apps/app_shim/app_shim_host_manager_browsertest_mac.mm | 14 | ||||
-rw-r--r-- | apps/app_shim/app_shim_host_manager_mac.mm | 32 | ||||
-rw-r--r-- | chrome/app/app_mode_loader_mac.mm | 38 | ||||
-rw-r--r-- | chrome/browser/apps/shortcut_manager.cc | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 32 | ||||
-rw-r--r-- | chrome/common/mac/app_mode_chrome_locator.h | 8 | ||||
-rw-r--r-- | chrome/common/mac/app_mode_chrome_locator.mm | 40 | ||||
-rw-r--r-- | chrome/common/mac/app_mode_chrome_locator_browsertest.mm | 140 | ||||
-rw-r--r-- | chrome/common/mac/app_mode_chrome_locator_unittest.mm | 71 | ||||
-rw-r--r-- | chrome/common/mac/app_mode_common.h | 6 | ||||
-rw-r--r-- | chrome/common/mac/app_mode_common.mm | 2 |
12 files changed, 250 insertions, 136 deletions
diff --git a/apps/app_shim/DEPS b/apps/app_shim/DEPS index 230115e..ec27f8a 100644 --- a/apps/app_shim/DEPS +++ b/apps/app_shim/DEPS @@ -11,6 +11,7 @@ include_rules = [ "+chrome/browser/web_applications/web_app_mac.h", "+chrome/common/chrome_constants.h", "+chrome/common/chrome_paths.h", + "+chrome/common/chrome_version_info.h", "+chrome/common/extensions/extension_constants.h", "+chrome/common/mac/app_mode_common.h", "+components/crx_file", diff --git a/apps/app_shim/app_shim_host_manager_browsertest_mac.mm b/apps/app_shim/app_shim_host_manager_browsertest_mac.mm index 3e92cbf..0ab7003 100644 --- a/apps/app_shim/app_shim_host_manager_browsertest_mac.mm +++ b/apps/app_shim/app_shim_host_manager_browsertest_mac.mm @@ -15,6 +15,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_paths.h" +#include "chrome/common/chrome_version_info.h" #include "chrome/common/mac/app_mode_common.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/test/test_utils.h" @@ -226,6 +227,7 @@ class AppShimHostManagerBrowserTestSocketFiles protected: base::FilePath directory_in_tmp_; base::FilePath symlink_path_; + base::FilePath version_path_; private: virtual bool SetUpUserDataDirectory() OVERRIDE; @@ -243,6 +245,12 @@ bool AppShimHostManagerBrowserTestSocketFiles::SetUpUserDataDirectory() { PathService::Get(base::DIR_TEMP, &temp_dir); EXPECT_TRUE(base::CreateSymbolicLink(temp_dir.Append("chrome-XXXXXX"), symlink_path_)); + + // Create an invalid RunningChromeVersion file. + version_path_ = + user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); + EXPECT_TRUE(base::CreateSymbolicLink(base::FilePath("invalid_version"), + version_path_)); return AppShimHostManagerBrowserTest::SetUpUserDataDirectory(); } @@ -251,6 +259,7 @@ void AppShimHostManagerBrowserTestSocketFiles:: // Check that created files have been deleted. EXPECT_FALSE(base::PathExists(directory_in_tmp_)); EXPECT_FALSE(base::PathExists(symlink_path_)); + EXPECT_FALSE(base::PathExists(version_path_)); } IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSocketFiles, @@ -268,6 +277,11 @@ IN_PROC_BROWSER_TEST_F(AppShimHostManagerBrowserTestSocketFiles, base::FilePath socket_path; ASSERT_TRUE(base::ReadSymbolicLink(symlink_path_, &socket_path)); EXPECT_EQ(app_mode::kAppShimSocketShortName, socket_path.BaseName().value()); + + // Check that the RunningChromeVersion file is correctly written. + base::FilePath version; + EXPECT_TRUE(base::ReadSymbolicLink(version_path_, &version)); + EXPECT_EQ(chrome::VersionInfo().Version(), version.value()); } } // namespace diff --git a/apps/app_shim/app_shim_host_manager_mac.mm b/apps/app_shim/app_shim_host_manager_mac.mm index 799d32d..9766442 100644 --- a/apps/app_shim/app_shim_host_manager_mac.mm +++ b/apps/app_shim/app_shim_host_manager_mac.mm @@ -20,6 +20,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/chrome_version_info.h" #include "chrome/common/mac/app_mode_common.h" using content::BrowserThread; @@ -41,11 +42,15 @@ base::FilePath GetDirectoryInTmpTemplate(const base::FilePath& user_data_dir) { } void DeleteSocketFiles(const base::FilePath& directory_in_tmp, - const base::FilePath& symlink_path) { - if (!directory_in_tmp.empty()) - base::DeleteFile(directory_in_tmp, true); + const base::FilePath& symlink_path, + const base::FilePath& version_path) { + // Delete in reverse order of creation. + if (!version_path.empty()) + base::DeleteFile(version_path, false); if (!symlink_path.empty()) base::DeleteFile(symlink_path, false); + if (!directory_in_tmp.empty()) + base::DeleteFile(directory_in_tmp, true); } } // namespace @@ -69,13 +74,19 @@ AppShimHostManager::~AppShimHostManager() { return; apps::AppShimHandler::SetDefaultHandler(NULL); + base::FilePath user_data_dir; base::FilePath symlink_path; - if (PathService::Get(chrome::DIR_USER_DATA, &symlink_path)) - symlink_path = symlink_path.Append(app_mode::kAppShimSocketSymlinkName); + base::FilePath version_path; + if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { + symlink_path = user_data_dir.Append(app_mode::kAppShimSocketSymlinkName); + version_path = + user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); + } BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&DeleteSocketFiles, directory_in_tmp_, symlink_path)); + base::Bind( + &DeleteSocketFiles, directory_in_tmp_, symlink_path, version_path)); } void AppShimHostManager::InitOnFileThread() { @@ -118,6 +129,15 @@ void AppShimHostManager::InitOnFileThread() { base::DeleteFile(symlink_path, false); base::CreateSymbolicLink(socket_path, symlink_path); + // Create a symlink containing the current version string. This allows the + // shim to load the same framework version as the currently running Chrome + // process. + base::FilePath version_path = + user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName); + base::DeleteFile(version_path, false); + base::CreateSymbolicLink(base::FilePath(chrome::VersionInfo().Version()), + version_path); + BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&AppShimHostManager::ListenOnIOThread, this)); diff --git a/chrome/app/app_mode_loader_mac.mm b/chrome/app/app_mode_loader_mac.mm index 90d6d3e..ba9da17 100644 --- a/chrome/app/app_mode_loader_mac.mm +++ b/chrome/app/app_mode_loader_mac.mm @@ -10,8 +10,7 @@ #include <dlfcn.h> -#include <CoreFoundation/CoreFoundation.h> -#import <Foundation/Foundation.h> +#import <Cocoa/Cocoa.h> #include "base/command_line.h" #include "base/files/file_path.h" @@ -21,7 +20,9 @@ #include "base/mac/launch_services_util.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/process/launch.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/sys_string_conversions.h" +#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #import "chrome/common/mac/app_mode_chrome_locator.h" #include "chrome/common/mac/app_mode_common.h" @@ -68,14 +69,37 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) { } } - // ** 2: Read information from the Chrome bundle. + // ** 2: Read the running Chrome version. + // The user_data_dir for shims actually contains the app_data_path. + // I.e. <user_data_dir>/<profile_dir>/Web Applications/_crx_extensionid/ + base::FilePath app_data_dir = base::mac::NSStringToFilePath([app_bundle + objectForInfoDictionaryKey:app_mode::kCrAppModeUserDataDirKey]); + base::FilePath user_data_dir = app_data_dir.DirName().DirName().DirName(); + CHECK(!user_data_dir.empty()); + + // If the version file does not exist, |cr_version_str| will be empty and + // app_mode::GetChromeBundleInfo will default to the latest version. + base::FilePath cr_version_str; + base::ReadSymbolicLink( + user_data_dir.Append(app_mode::kRunningChromeVersionSymlinkName), + &cr_version_str); + + // If the version file does exist, it may have been left by a crashed Chrome + // process. Ensure the process is still running. + if (!cr_version_str.empty()) { + NSArray* existing_chrome = [NSRunningApplication + runningApplicationsWithBundleIdentifier:cr_bundle_id]; + if ([existing_chrome count] == 0) + cr_version_str.clear(); + } + + // ** 3: 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(), &executable_path, - &raw_version_str, &version_path, &framework_shlib_path)) { LOG(FATAL) << "Couldn't ready Chrome bundle info"; @@ -83,7 +107,7 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) { base::FilePath app_mode_bundle_path = base::mac::NSStringToFilePath([app_bundle bundlePath]); - // ** 3: Fill in ChromeAppModeInfo. + // ** 4: Fill in ChromeAppModeInfo. info->chrome_outer_bundle_path = cr_bundle_path; info->chrome_versioned_path = version_path; info->app_mode_bundle_path = app_mode_bundle_path; @@ -109,7 +133,7 @@ int LoadFrameworkAndStart(app_mode::ChromeAppModeInfo* info) { info->profile_dir = base::mac::NSStringToFilePath( [info_plist objectForKey:app_mode::kCrAppModeProfileDirKey]); - // Open the framework. + // ** 5: Open the framework. StartFun ChromeAppModeStart = NULL; void* cr_dylib = dlopen(framework_shlib_path.value().c_str(), RTLD_LAZY); if (cr_dylib) { diff --git a/chrome/browser/apps/shortcut_manager.cc b/chrome/browser/apps/shortcut_manager.cc index d2a010e..d34f51c 100644 --- a/chrome/browser/apps/shortcut_manager.cc +++ b/chrome/browser/apps/shortcut_manager.cc @@ -36,7 +36,7 @@ namespace { // need to be recreated. This might happen when we change various aspects of app // shortcuts like command-line flags or associated icons, binaries, etc. #if defined(OS_MACOSX) -const int kCurrentAppShortcutsVersion = 1; +const int kCurrentAppShortcutsVersion = 2; #else const int kCurrentAppShortcutsVersion = 0; #endif diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 1de89e9..4b0064b 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1557,6 +1557,7 @@ 'browser/ui/webui/web_ui_test_handler.h', 'browser/ui/zoom/zoom_controller_browsertest.cc', 'browser/unload_browsertest.cc', + 'common/mac/app_mode_chrome_locator_browsertest.mm', 'common/mac/mock_launchd.cc', 'common/mac/mock_launchd.h', 'common/time_format_browsertest.cc', @@ -1941,6 +1942,7 @@ # chrome_resources.gyp:{packed_extra_resources,packed_resources}, # and can build this target standalone much faster. 'dependencies': [ + 'app_mode_app_support', 'chrome', '../components/components.gyp:breakpad_stubs', '../third_party/ocmock/ocmock.gyp:ocmock', @@ -2690,36 +2692,6 @@ }, ], 'conditions': [ - ['OS=="mac"', { - 'targets': [ - { - # Tests for Mac app launcher. - 'target_name': 'app_mode_app_tests', - 'type': 'executable', - 'product_name': 'app_mode_app_tests', - 'dependencies': [ - '../base/base.gyp:test_support_base', - '../chrome/common_constants.gyp:common_constants', - '../testing/gtest.gyp:gtest', - 'chrome.gyp:chrome', # run time dependency - 'app_mode_app_support', - ], - 'sources': [ - 'common/mac/app_mode_chrome_locator_unittest.mm', - 'test/base/app_mode_app_tests.cc', - ], - 'include_dirs': [ - '..', - ], - 'link_settings': { - 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework', - '$(SDKROOT)/System/Library/Frameworks/Foundation.framework', - ], - }, - }, # target app_mode_app_tests - ], - }], ['OS!="mac"', { 'targets': [ { diff --git a/chrome/common/mac/app_mode_chrome_locator.h b/chrome/common/mac/app_mode_chrome_locator.h index b608e9c..5b95ee7 100644 --- a/chrome/common/mac/app_mode_chrome_locator.h +++ b/chrome/common/mac/app_mode_chrome_locator.h @@ -21,16 +21,18 @@ namespace app_mode { // Returns true if the bundle was found, false otherwise. bool FindBundleById(NSString* bundle_id, base::FilePath* out_bundle); -// Given the path to the Chrome bundle, read the following information: +// Given the path to the Chrome bundle, and an optional framework version, read +// the following information: // |executable_path| - Path to the Chrome executable. -// |raw_version_str| - Chrome version. // |version_path| - |chrome_bundle|/Contents/Versions/|raw_version_str|/ // |framework_shlib_path| - Path to the chrome framework's shared library (not // the framework directory). +// If |version_str| is not given, this will read the current Chrome version from +// the bundle's plist. // Returns true if all information read succesfuly, false otherwise. 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); diff --git a/chrome/common/mac/app_mode_chrome_locator.mm b/chrome/common/mac/app_mode_chrome_locator.mm index 3cd5302..923e671 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); diff --git a/chrome/common/mac/app_mode_chrome_locator_browsertest.mm b/chrome/common/mac/app_mode_chrome_locator_browsertest.mm new file mode 100644 index 0000000..5eaa483 --- /dev/null +++ b/chrome/common/mac/app_mode_chrome_locator_browsertest.mm @@ -0,0 +1,140 @@ +// Copyright (c) 2012 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. + +#import "chrome/common/mac/app_mode_chrome_locator.h" + +#include <CoreFoundation/CoreFoundation.h> + +#include "base/files/file_path.h" +#include "base/files/file_util.h" +#include "base/files/scoped_temp_dir.h" +#include "base/path_service.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_version_info.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace { + +// This needs to be a browser test because it expects to find a Chrome.app +// bundle in the output directory. + +// Return the path to the Chrome/Chromium app bundle compiled along with the +// test executable. +void GetChromeBundlePath(base::FilePath* chrome_bundle) { + base::FilePath path; + PathService::Get(base::DIR_MODULE, &path); + path = path.Append(chrome::kBrowserProcessExecutableNameChromium); + path = path.ReplaceExtension(base::FilePath::StringType("app")); + *chrome_bundle = path; +} + +} // namespace + +TEST(ChromeLocatorTest, FindBundle) { + base::FilePath finder_bundle_path; + EXPECT_TRUE( + app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path)); + EXPECT_TRUE(base::DirectoryExists(finder_bundle_path)); +} + +TEST(ChromeLocatorTest, FindNonExistentBundle) { + base::FilePath dummy; + EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy)); +} + +TEST(ChromeLocatorTest, GetNonExistentBundleInfo) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + + base::FilePath executable_path; + base::FilePath version_path; + base::FilePath framework_path; + EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(), + std::string(), + &executable_path, + &version_path, + &framework_path)); +} + +TEST(ChromeLocatorTest, GetChromeBundleInfo) { + base::FilePath chrome_bundle_path; + GetChromeBundlePath(&chrome_bundle_path); + ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); + + base::FilePath executable_path; + base::FilePath version_path; + base::FilePath framework_path; + EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, + std::string(), + &executable_path, + &version_path, + &framework_path)); + EXPECT_TRUE(base::PathExists(executable_path)); + EXPECT_TRUE(base::DirectoryExists(version_path)); + EXPECT_TRUE(base::PathExists(framework_path)); +} + +TEST(ChromeLocatorTest, GetChromeBundleInfoWithLatestVersion) { + base::FilePath chrome_bundle_path; + GetChromeBundlePath(&chrome_bundle_path); + ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); + + base::FilePath executable_path; + base::FilePath version_path; + base::FilePath framework_path; + EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, + chrome::VersionInfo().Version(), + &executable_path, + &version_path, + &framework_path)); + EXPECT_TRUE(base::PathExists(executable_path)); + EXPECT_TRUE(base::DirectoryExists(version_path)); + EXPECT_TRUE(base::PathExists(framework_path)); +} + +TEST(ChromeLocatorTest, GetChromeBundleInfoWithInvalidVersion) { + base::FilePath chrome_bundle_path; + GetChromeBundlePath(&chrome_bundle_path); + ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); + + base::FilePath executable_path; + base::FilePath version_path; + base::FilePath framework_path; + // This still passes because it should default to the latest version. + EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, + std::string("invalid_version"), + &executable_path, + &version_path, + &framework_path)); + EXPECT_TRUE(base::PathExists(executable_path)); + EXPECT_TRUE(base::DirectoryExists(version_path)); + EXPECT_TRUE(base::PathExists(framework_path)); +} + +TEST(ChromeLocatorTest, GetChromeBundleInfoWithPreviousVersion) { + base::FilePath chrome_bundle_path; + GetChromeBundlePath(&chrome_bundle_path); + ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); + + // Make a symlink that pretends to be a previous version. + base::FilePath fake_version_directory = chrome_bundle_path.Append("Contents") + .Append("Versions") + .Append("previous_version"); + EXPECT_TRUE(base::CreateSymbolicLink( + base::FilePath(chrome::VersionInfo().Version()), fake_version_directory)); + + base::FilePath executable_path; + base::FilePath version_path; + base::FilePath framework_path; + EXPECT_TRUE(app_mode::GetChromeBundleInfo(chrome_bundle_path, + std::string("previous_version"), + &executable_path, + &version_path, + &framework_path)); + EXPECT_TRUE(base::PathExists(executable_path)); + EXPECT_TRUE(base::DirectoryExists(version_path)); + EXPECT_TRUE(base::PathExists(framework_path)); + + base::DeleteFile(fake_version_directory, false); +} diff --git a/chrome/common/mac/app_mode_chrome_locator_unittest.mm b/chrome/common/mac/app_mode_chrome_locator_unittest.mm deleted file mode 100644 index c6c8798..0000000 --- a/chrome/common/mac/app_mode_chrome_locator_unittest.mm +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2012 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. - -#import "chrome/common/mac/app_mode_chrome_locator.h" - -#include <CoreFoundation/CoreFoundation.h> - -#include "base/files/file_path.h" -#include "base/files/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "base/path_service.h" -#include "chrome/common/chrome_constants.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -// Return the path to the Chrome/Chromium app bundle compiled along with the -// test executable. -void GetChromeBundlePath(base::FilePath* chrome_bundle) { - base::FilePath path; - PathService::Get(base::DIR_EXE, &path); - path = path.Append(chrome::kBrowserProcessExecutableNameChromium); - path = path.ReplaceExtension(base::FilePath::StringType("app")); - *chrome_bundle = path; -} - -} // namespace - -TEST(ChromeLocatorTest, FindBundle) { - base::FilePath finder_bundle_path; - EXPECT_TRUE( - app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path)); - EXPECT_TRUE(base::DirectoryExists(finder_bundle_path)); -} - -TEST(ChromeLocatorTest, FindNonExistentBundle) { - base::FilePath dummy; - EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy)); -} - -TEST(ChromeLocatorTest, GetNonExistentBundleInfo) { - base::ScopedTempDir temp_dir; - ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - - base::FilePath executable_path; - base::string16 raw_version; - base::FilePath version_path; - base::FilePath framework_path; - EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(), - &executable_path, &raw_version, &version_path, &framework_path)); -} - -TEST(ChromeLocatorTest, GetChromeBundleInfo) { - using app_mode::GetChromeBundleInfo; - - base::FilePath chrome_bundle_path; - GetChromeBundlePath(&chrome_bundle_path); - ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path)); - - base::FilePath executable_path; - base::string16 raw_version; - base::FilePath version_path; - base::FilePath framework_path; - EXPECT_TRUE(GetChromeBundleInfo(chrome_bundle_path, - &executable_path, &raw_version, &version_path, &framework_path)); - EXPECT_TRUE(base::PathExists(executable_path)); - EXPECT_GT(raw_version.size(), 0U); - EXPECT_TRUE(base::DirectoryExists(version_path)); - EXPECT_TRUE(base::PathExists(framework_path)); -} diff --git a/chrome/common/mac/app_mode_common.h b/chrome/common/mac/app_mode_common.h index 709e8cd..4e6e07f 100644 --- a/chrome/common/mac/app_mode_common.h +++ b/chrome/common/mac/app_mode_common.h @@ -29,6 +29,10 @@ extern const char kAppShimSocketShortName[]; // user data dir with this name. extern const char kAppShimSocketSymlinkName[]; +// A symlink used to store the version string of the currently running Chrome. +// The shim will read this to determine which version of the framework to load. +extern const char kRunningChromeVersionSymlinkName[]; + // Special app mode id used for the App Launcher. extern const char kAppListModeId[]; @@ -105,7 +109,7 @@ extern NSString* const kShortcutBrowserBundleIDPlaceholder; // Current major/minor version numbers of |ChromeAppModeInfo| (defined below). const unsigned kCurrentChromeAppModeInfoMajorVersion = 1; -const unsigned kCurrentChromeAppModeInfoMinorVersion = 2; +const unsigned kCurrentChromeAppModeInfoMinorVersion = 3; // The structure used to pass information from the app mode loader to the // (browser) framework. This is versioned using major and minor version numbers, diff --git a/chrome/common/mac/app_mode_common.mm b/chrome/common/mac/app_mode_common.mm index b966dc7..171c77f 100644 --- a/chrome/common/mac/app_mode_common.mm +++ b/chrome/common/mac/app_mode_common.mm @@ -11,6 +11,8 @@ namespace app_mode { const char kAppShimSocketShortName[] = "Socket"; const char kAppShimSocketSymlinkName[] = "App Shim Socket"; +const char kRunningChromeVersionSymlinkName[] = "RunningChromeVersion"; + const char kAppListModeId[] = "app_list"; const char kLaunchedByChromeProcessId[] = "launched-by-chrome-process-id"; |