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

Unified Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 16304005: Create a copy of each app's shim bundle in the app's app_data_path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 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/browser/web_applications/web_app_mac.mm
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 825e90814b525e65435f160cdcebf37a96668628..d4f303aeda6558c728f582d44f4bc1626fce5237 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -195,6 +195,11 @@ bool WebAppShortcutCreator::CreateShortcut() {
LOG(ERROR) << "Couldn't find an Applications directory to copy app to.";
return false;
}
+ if (!file_util::CreateDirectory(user_data_dir_)) {
+ LOG(ERROR) << "Creating user_data_dir " << user_data_dir_.value()
+ << " failed.";
+ return false;
+ }
if (!file_util::CreateDirectory(dst_path)) {
LOG(ERROR) << "Creating directory " << dst_path.value() << " failed.";
return false;
@@ -209,7 +214,7 @@ bool WebAppShortcutCreator::CreateShortcut() {
// a Finder bug where the app's icon doesn't properly update.
if (!file_util::CopyDirectory(GetAppLoaderPath(), staging_path, true)) {
LOG(ERROR) << "Copying app to staging path: " << staging_path.value()
- << " failed";
+ << " failed.";
return false;
}
@@ -222,12 +227,19 @@ bool WebAppShortcutCreator::CreateShortcut() {
if (!UpdateIcon(staging_path))
return false;
- if (!file_util::CopyDirectory(staging_path, dst_path, true)) {
- LOG(ERROR) << "Copying app to dst path: " << dst_path.value() << " failed";
+ // Put one copy in the app's user_data_dir so we can still run it if the user
+ // deletes the one in the applications folder.
+ if (!file_util::CopyDirectory(staging_path, user_data_dir_, true)) {
+ NOTREACHED();
return false;
}
+ base::mac::RemoveQuarantineAttribute(user_data_dir_.Append(app_name));
+
+ if (!file_util::CopyDirectory(staging_path, dst_path, true))
+ return false;
base::mac::RemoveQuarantineAttribute(app_path);
+
RevealGeneratedBundleInFinder(app_path);
return true;
@@ -382,8 +394,14 @@ void LaunchShimOnFileThread(
const ShellIntegration::ShortcutInfo& shortcut_info) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info);
- if (shim_path.empty())
- return;
+
+ if (!file_util::PathExists(shim_path)) {
tapted 2013/06/12 08:37:56 This should be if (shim_path.empty() || !file_ut
jackhou1 2013/06/12 09:05:18 Done.
+ // The user may have deleted the copy in the Applications folder, use the
+ // one in the web app's user_data_dir.
+ base::FilePath shortcut_data_dir = GetWebAppDataDirectory(
+ shortcut_info.profile_path, shortcut_info.extension_id, GURL());
+ shim_path = shortcut_data_dir.Append(shim_path.BaseName());
+ }
CommandLine command_line(CommandLine::NO_PROGRAM);
command_line.AppendSwitch(app_mode::kNoLaunchApp);

Powered by Google App Engine
This is Rietveld 408576698