summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_applications/web_app_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/web_applications/web_app_mac.mm')
-rw-r--r--chrome/browser/web_applications/web_app_mac.mm38
1 files changed, 12 insertions, 26 deletions
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 608b5b2..2c61548 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -80,24 +80,11 @@ bool AddBitmapImageRepToIconFamily(IconFamily* icon_family,
}
}
-base::FilePath GetWritableApplicationsDirectory() {
- base::FilePath path;
- if (base::mac::GetLocalDirectory(NSApplicationDirectory, &path) &&
- file_util::PathIsWritable(path)) {
- return path;
- }
- if (base::mac::GetUserDirectory(NSApplicationDirectory, &path))
- return path;
- return base::FilePath();
-}
-
} // namespace
namespace web_app {
-const char kChromeAppDirName[] = "Chrome Apps.localized";
-
WebAppShortcutCreator::WebAppShortcutCreator(
const base::FilePath& user_data_dir,
const ShellIntegration::ShortcutInfo& shortcut_info,
@@ -132,15 +119,7 @@ bool WebAppShortcutCreator::CreateShortcut() {
if (!UpdateIcon(staging_path))
return false;
- base::FilePath dst_path = GetDestinationPath();
- if (dst_path.empty()) {
- LOG(ERROR) << "Couldn't find an Applications directory to copy app to.";
- return false;
- }
- if (!file_util::CreateDirectory(dst_path)) {
- LOG(ERROR) << "Creating directory " << dst_path.value() << " failed.";
- return false;
- }
+ base::FilePath dst_path = GetDestinationPath(app_file_name);
if (!file_util::CopyDirectory(staging_path, dst_path, true)) {
LOG(ERROR) << "Copying app to dst path: " << dst_path.value() << " failed";
return false;
@@ -158,11 +137,18 @@ base::FilePath WebAppShortcutCreator::GetAppLoaderPath() const {
base::mac::NSToCFCast(@"app_mode_loader.app"));
}
-base::FilePath WebAppShortcutCreator::GetDestinationPath() const {
- base::FilePath path = GetWritableApplicationsDirectory();
- if (path.empty())
+base::FilePath WebAppShortcutCreator::GetDestinationPath(
+ const base::FilePath& app_file_name) const {
+ base::FilePath path;
+ if (base::mac::GetLocalDirectory(NSApplicationDirectory, &path) &&
+ file_util::PathIsWritable(path)) {
+ return path;
+ }
+
+ if (base::mac::GetUserDirectory(NSApplicationDirectory, &path))
return path;
- return path.Append(kChromeAppDirName);
+
+ return base::FilePath();
}
bool WebAppShortcutCreator::UpdatePlist(const base::FilePath& app_path) const {