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 <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 // Takes the path to an app bundle and checks that the CrAppModeUserDataDir in | 206 // Takes the path to an app bundle and checks that the CrAppModeUserDataDir in |
207 // the Info.plist starts with the current user_data_dir. This uses starts with | 207 // the Info.plist starts with the current user_data_dir. This uses starts with |
208 // instead of equals because the CrAppModeUserDataDir could be the user_data_dir | 208 // instead of equals because the CrAppModeUserDataDir could be the user_data_dir |
209 // or the |app_data_dir_|. | 209 // or the |app_data_dir_|. |
210 bool HasSameUserDataDir(const base::FilePath& bundle_path) { | 210 bool HasSameUserDataDir(const base::FilePath& bundle_path) { |
211 NSDictionary* plist = ReadPlist(GetPlistPath(bundle_path)); | 211 NSDictionary* plist = ReadPlist(GetPlistPath(bundle_path)); |
212 base::FilePath user_data_dir; | 212 base::FilePath user_data_dir; |
213 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 213 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
214 DCHECK(!user_data_dir.empty()); | 214 DCHECK(!user_data_dir.empty()); |
215 return base::StartsWithASCII( | 215 return base::StartsWith( |
216 base::SysNSStringToUTF8( | 216 base::SysNSStringToUTF8( |
217 [plist valueForKey:app_mode::kCrAppModeUserDataDirKey]), | 217 [plist valueForKey:app_mode::kCrAppModeUserDataDirKey]), |
218 user_data_dir.value(), true /* case_sensitive */); | 218 user_data_dir.value(), base::CompareCase::SENSITIVE); |
219 } | 219 } |
220 | 220 |
221 void LaunchShimOnFileThread(scoped_ptr<web_app::ShortcutInfo> shortcut_info, | 221 void LaunchShimOnFileThread(scoped_ptr<web_app::ShortcutInfo> shortcut_info, |
222 bool launched_after_rebuild) { | 222 bool launched_after_rebuild) { |
223 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 223 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
224 base::FilePath shim_path = web_app::GetAppInstallPath(*shortcut_info); | 224 base::FilePath shim_path = web_app::GetAppInstallPath(*shortcut_info); |
225 | 225 |
226 if (shim_path.empty() || | 226 if (shim_path.empty() || |
227 !base::PathExists(shim_path) || | 227 !base::PathExists(shim_path) || |
228 !HasSameUserDataDir(shim_path)) { | 228 !HasSameUserDataDir(shim_path)) { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { | 446 void DeletePathAndParentIfEmpty(const base::FilePath& app_path) { |
447 DCHECK(!app_path.empty()); | 447 DCHECK(!app_path.empty()); |
448 base::DeleteFile(app_path, true); | 448 base::DeleteFile(app_path, true); |
449 base::FilePath apps_folder = app_path.DirName(); | 449 base::FilePath apps_folder = app_path.DirName(); |
450 if (base::IsDirectoryEmpty(apps_folder)) | 450 if (base::IsDirectoryEmpty(apps_folder)) |
451 base::DeleteFile(apps_folder, false); | 451 base::DeleteFile(apps_folder, false); |
452 } | 452 } |
453 | 453 |
454 bool IsShimForProfile(const base::FilePath& base_name, | 454 bool IsShimForProfile(const base::FilePath& base_name, |
455 const std::string& profile_base_name) { | 455 const std::string& profile_base_name) { |
456 if (!base::StartsWithASCII(base_name.value(), profile_base_name, true)) | 456 if (!base::StartsWith(base_name.value(), profile_base_name, |
| 457 base::CompareCase::SENSITIVE)) |
457 return false; | 458 return false; |
458 | 459 |
459 if (base_name.Extension() != ".app") | 460 if (base_name.Extension() != ".app") |
460 return false; | 461 return false; |
461 | 462 |
462 std::string app_id = base_name.RemoveExtension().value(); | 463 std::string app_id = base_name.RemoveExtension().value(); |
463 // Strip (profile_base_name + " ") from the start. | 464 // Strip (profile_base_name + " ") from the start. |
464 app_id = app_id.substr(profile_base_name.size() + 1); | 465 app_id = app_id.substr(profile_base_name.size() + 1); |
465 return crx_file::id_util::IdIsValid(app_id); | 466 return crx_file::id_util::IdIsValid(app_id); |
466 } | 467 } |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 web_app::GetShortcutInfoForApp( | 1212 web_app::GetShortcutInfoForApp( |
1212 app, | 1213 app, |
1213 profile, | 1214 profile, |
1214 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 1215 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
1215 profile, | 1216 profile, |
1216 app, | 1217 app, |
1217 close_callback)); | 1218 close_callback)); |
1218 } | 1219 } |
1219 | 1220 |
1220 } // namespace chrome | 1221 } // namespace chrome |
OLD | NEW |