OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 default: | 78 default: |
79 return false; | 79 return false; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 } // namespace | 83 } // namespace |
84 | 84 |
85 | 85 |
86 namespace web_app { | 86 namespace web_app { |
87 | 87 |
88 const char kChromeAppDirName[] = "Chrome Apps.localized"; | |
89 | |
88 WebAppShortcutCreator::WebAppShortcutCreator( | 90 WebAppShortcutCreator::WebAppShortcutCreator( |
89 const base::FilePath& user_data_dir, | 91 const base::FilePath& user_data_dir, |
90 const ShellIntegration::ShortcutInfo& shortcut_info, | 92 const ShellIntegration::ShortcutInfo& shortcut_info, |
91 const string16& chrome_bundle_id) | 93 const string16& chrome_bundle_id) |
92 : user_data_dir_(user_data_dir), | 94 : user_data_dir_(user_data_dir), |
93 info_(shortcut_info), | 95 info_(shortcut_info), |
94 chrome_bundle_id_(chrome_bundle_id) { | 96 chrome_bundle_id_(chrome_bundle_id) { |
95 } | 97 } |
96 | 98 |
97 WebAppShortcutCreator::~WebAppShortcutCreator() { | 99 WebAppShortcutCreator::~WebAppShortcutCreator() { |
(...skipping 15 matching lines...) Expand all Loading... | |
113 return false; | 115 return false; |
114 } | 116 } |
115 | 117 |
116 if (!UpdatePlist(staging_path)) | 118 if (!UpdatePlist(staging_path)) |
117 return false; | 119 return false; |
118 | 120 |
119 if (!UpdateIcon(staging_path)) | 121 if (!UpdateIcon(staging_path)) |
120 return false; | 122 return false; |
121 | 123 |
122 base::FilePath dst_path = GetDestinationPath(app_file_name); | 124 base::FilePath dst_path = GetDestinationPath(app_file_name); |
125 if (dst_path.empty()) { | |
126 LOG(ERROR) << "Couldn't find an Applications directory to copy app to."; | |
127 return false; | |
128 } | |
129 dst_path = dst_path.Append(kChromeAppDirName); | |
130 if (!file_util::CreateDirectory(dst_path)) { | |
131 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed."; | |
132 return false; | |
133 } | |
123 if (!file_util::CopyDirectory(staging_path, dst_path, true)) { | 134 if (!file_util::CopyDirectory(staging_path, dst_path, true)) { |
124 LOG(ERROR) << "Copying app to dst path: " << dst_path.value() << " failed"; | 135 LOG(ERROR) << "Copying app to dst path: " << dst_path.value() << " failed"; |
125 return false; | 136 return false; |
126 } | 137 } |
127 | 138 |
128 dst_path = dst_path.Append(app_file_name); | 139 dst_path = dst_path.Append(app_file_name); |
129 base::mac::RemoveQuarantineAttribute(dst_path); | 140 base::mac::RemoveQuarantineAttribute(dst_path); |
130 RevealGeneratedBundleInFinder(dst_path); | 141 RevealGeneratedBundleInFinder(dst_path); |
131 | 142 |
132 return true; | 143 return true; |
133 } | 144 } |
134 | 145 |
135 base::FilePath WebAppShortcutCreator::GetAppLoaderPath() const { | 146 base::FilePath WebAppShortcutCreator::GetAppLoaderPath() const { |
136 return base::mac::PathForFrameworkBundleResource( | 147 return base::mac::PathForFrameworkBundleResource( |
137 base::mac::NSToCFCast(@"app_mode_loader.app")); | 148 base::mac::NSToCFCast(@"app_mode_loader.app")); |
138 } | 149 } |
139 | 150 |
140 base::FilePath WebAppShortcutCreator::GetDestinationPath( | 151 base::FilePath WebAppShortcutCreator::GetDestinationPath( |
141 const base::FilePath& app_file_name) const { | 152 const base::FilePath& app_file_name) const { |
benwells
2013/03/18 05:01:17
Is there a reason this takes app_file_name?
| |
142 base::FilePath path; | 153 base::FilePath path; |
143 if (base::mac::GetLocalDirectory(NSApplicationDirectory, &path) && | 154 if (base::mac::GetLocalDirectory(NSApplicationDirectory, &path) && |
144 file_util::PathIsWritable(path)) { | 155 file_util::PathIsWritable(path)) { |
145 return path; | 156 return path; |
146 } | 157 } |
147 | 158 |
148 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) | 159 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) |
149 return path; | 160 return path; |
150 | 161 |
151 return base::FilePath(); | 162 return base::FilePath(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 void UpdatePlatformShortcuts( | 311 void UpdatePlatformShortcuts( |
301 const base::FilePath& web_app_path, | 312 const base::FilePath& web_app_path, |
302 const ShellIntegration::ShortcutInfo& shortcut_info) { | 313 const ShellIntegration::ShortcutInfo& shortcut_info) { |
303 // TODO(benwells): Implement this when shortcuts / weblings are enabled on | 314 // TODO(benwells): Implement this when shortcuts / weblings are enabled on |
304 // mac. | 315 // mac. |
305 } | 316 } |
306 | 317 |
307 } // namespace internals | 318 } // namespace internals |
308 | 319 |
309 } // namespace web_app | 320 } // namespace web_app |
OLD | NEW |