| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 | 160 |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 | 163 |
| 164 void LaunchShimOnFileThread( | 164 void LaunchShimOnFileThread( |
| 165 const ShellIntegration::ShortcutInfo& shortcut_info) { | 165 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 166 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 166 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 167 base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info); | 167 base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info); |
| 168 | 168 |
| 169 if (shim_path.empty() || !file_util::PathExists(shim_path)) { | 169 if (shim_path.empty() || !base::PathExists(shim_path)) { |
| 170 // The user may have deleted the copy in the Applications folder, use the | 170 // The user may have deleted the copy in the Applications folder, use the |
| 171 // one in the web app's app_data_path. | 171 // one in the web app's app_data_path. |
| 172 base::FilePath app_data_path = web_app::GetWebAppDataDirectory( | 172 base::FilePath app_data_path = web_app::GetWebAppDataDirectory( |
| 173 shortcut_info.profile_path, shortcut_info.extension_id, GURL()); | 173 shortcut_info.profile_path, shortcut_info.extension_id, GURL()); |
| 174 shim_path = app_data_path.Append(shim_path.BaseName()); | 174 shim_path = app_data_path.Append(shim_path.BaseName()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 if (!file_util::PathExists(shim_path)) | 177 if (!base::PathExists(shim_path)) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 CommandLine command_line(CommandLine::NO_PROGRAM); | 180 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 181 command_line.AppendSwitch(app_mode::kNoLaunchApp); | 181 command_line.AppendSwitch(app_mode::kNoLaunchApp); |
| 182 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); | 182 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); |
| 183 } | 183 } |
| 184 | 184 |
| 185 base::FilePath GetLocalizableAppShortcutsSubdirName() { | 185 base::FilePath GetLocalizableAppShortcutsSubdirName() { |
| 186 #if defined(GOOGLE_CHROME_BUILD) | 186 #if defined(GOOGLE_CHROME_BUILD) |
| 187 static const char kChromeAppDirName[] = "Chrome Apps.localized"; | 187 static const char kChromeAppDirName[] = "Chrome Apps.localized"; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 bool WebAppShortcutCreator::UpdateShortcuts() { | 370 bool WebAppShortcutCreator::UpdateShortcuts() { |
| 371 std::vector<base::FilePath> paths; | 371 std::vector<base::FilePath> paths; |
| 372 base::Delete(app_data_path_.Append(GetShortcutName()), true); | 372 base::Delete(app_data_path_.Append(GetShortcutName()), true); |
| 373 paths.push_back(app_data_path_); | 373 paths.push_back(app_data_path_); |
| 374 | 374 |
| 375 base::FilePath dst_path = GetDestinationPath(); | 375 base::FilePath dst_path = GetDestinationPath(); |
| 376 base::FilePath app_path = dst_path.Append(GetShortcutName()); | 376 base::FilePath app_path = dst_path.Append(GetShortcutName()); |
| 377 | 377 |
| 378 // If the path does not exist, check if a matching bundle can be found | 378 // If the path does not exist, check if a matching bundle can be found |
| 379 // elsewhere. | 379 // elsewhere. |
| 380 if (dst_path.empty() || !file_util::PathExists(app_path)) | 380 if (dst_path.empty() || !base::PathExists(app_path)) |
| 381 app_path = GetAppBundleById(GetBundleIdentifier()); | 381 app_path = GetAppBundleById(GetBundleIdentifier()); |
| 382 | 382 |
| 383 if (!app_path.empty()) { | 383 if (!app_path.empty()) { |
| 384 base::Delete(app_path, true); | 384 base::Delete(app_path, true); |
| 385 paths.push_back(app_path.DirName()); | 385 paths.push_back(app_path.DirName()); |
| 386 } | 386 } |
| 387 | 387 |
| 388 size_t success_count = CreateShortcutsIn(paths); | 388 size_t success_count = CreateShortcutsIn(paths); |
| 389 if (success_count == 0) | 389 if (success_count == 0) |
| 390 return false; | 390 return false; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 shortcut_creator.UpdateShortcuts(); | 625 shortcut_creator.UpdateShortcuts(); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { | 628 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { |
| 629 // TODO(mgiuca): Implement this on Mac. | 629 // TODO(mgiuca): Implement this on Mac. |
| 630 } | 630 } |
| 631 | 631 |
| 632 } // namespace internals | 632 } // namespace internals |
| 633 | 633 |
| 634 } // namespace web_app | 634 } // namespace web_app |
| OLD | NEW |