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

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..f2be997c3f8e26d862c45b19db6fea5adc398627 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -166,10 +166,10 @@ namespace web_app {
const char kChromeAppDirName[] = "Chrome Apps.localized";
WebAppShortcutCreator::WebAppShortcutCreator(
- const base::FilePath& user_data_dir,
+ const base::FilePath& web_app_path,
const ShellIntegration::ShortcutInfo& shortcut_info,
const string16& chrome_bundle_id)
- : user_data_dir_(user_data_dir),
+ : web_app_path_(web_app_path),
info_(shortcut_info),
chrome_bundle_id_(chrome_bundle_id) {
}
@@ -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(web_app_path_)) {
+ LOG(ERROR) << "Creating web_app_path " << web_app_path_.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 web_app_path so we can still run it if the user
+ // deletes the one in the applications folder.
+ if (!file_util::CopyDirectory(staging_path, web_app_path_, true)) {
+ NOTREACHED();
return false;
}
+ base::mac::RemoveQuarantineAttribute(web_app_path_.Append(app_name));
+
+ if (!file_util::CopyDirectory(staging_path, dst_path, true))
+ return false;
base::mac::RemoveQuarantineAttribute(app_path);
+
benwells 2013/06/13 03:57:43 Nit: is the new blank line needed?
jackhou1 2013/06/14 03:31:27 Done.
RevealGeneratedBundleInFinder(app_path);
return true;
@@ -282,7 +294,7 @@ bool WebAppShortcutCreator::UpdatePlist(const base::FilePath& app_path) const {
// 2. Fill in other values.
[plist setObject:GetBundleIdentifier(plist)
forKey:base::mac::CFToNSCast(kCFBundleIdentifierKey)];
- [plist setObject:base::mac::FilePathToNSString(user_data_dir_)
+ [plist setObject:base::mac::FilePathToNSString(web_app_path_)
forKey:app_mode::kCrAppModeUserDataDirKey];
benwells 2013/06/13 03:57:43 Is this property in the plist still needed? I have
jackhou1 2013/06/14 03:31:27 Right now, most of the kCrAppMode* entries are unu
benwells 2013/06/14 03:36:40 We should review them and remove any that aren't u
[plist setObject:base::mac::FilePathToNSString(info_.profile_path.BaseName())
forKey:app_mode::kCrAppModeProfileDirKey];
@@ -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 (shim_path.empty() || !file_util::PathExists(shim_path)) {
+ // The user may have deleted the copy in the Applications folder, use the
+ // one in the web app's web_app_path.
+ base::FilePath web_app_path = GetWebAppDataDirectory(
+ shortcut_info.profile_path, shortcut_info.extension_id, GURL());
+ shim_path = web_app_path.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