summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjackhou <jackhou@chromium.org>2014-08-28 20:23:04 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-29 03:24:57 +0000
commitaeac008d6856655cda70806584e74c6e67c4ca62 (patch)
tree59ddf9a67ec3516b233954989558e6a13e4de3de /apps
parentef97623cf0cacf08259c6733c457ff5fd85cc277 (diff)
downloadchromium_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}
Diffstat (limited to 'apps')
-rw-r--r--apps/app_shim/DEPS1
-rw-r--r--apps/app_shim/app_shim_host_manager_browsertest_mac.mm14
-rw-r--r--apps/app_shim/app_shim_host_manager_mac.mm32
3 files changed, 41 insertions, 6 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));