| 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 #include "chrome/browser/web_applications/web_app.h" | 5 #include "chrome/browser/web_applications/web_app.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/shell_integration_linux.h" | 12 #include "chrome/browser/shell_integration_linux.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 | 14 |
| 15 namespace web_app { | 15 namespace web_app { |
| 16 | 16 |
| 17 void UpdateShortcutsForAllApps(Profile* profile, | 17 void UpdateShortcutsForAllApps(Profile* profile, |
| 18 const base::Closure& callback) { | 18 const base::Closure& callback) { |
| 19 callback.Run(); | 19 callback.Run(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace internals { | 22 namespace internals { |
| 23 | 23 |
| 24 bool CreatePlatformShortcuts( | 24 bool CreatePlatformShortcuts(const base::FilePath& web_app_path, |
| 25 const base::FilePath& web_app_path, | 25 const ShortcutInfo& shortcut_info, |
| 26 std::unique_ptr<ShortcutInfo> shortcut_info, | 26 const ShortcutLocations& creation_locations, |
| 27 const ShortcutLocations& creation_locations, | 27 ShortcutCreationReason /*creation_reason*/) { |
| 28 ShortcutCreationReason /*creation_reason*/) { | |
| 29 #if !defined(OS_CHROMEOS) | 28 #if !defined(OS_CHROMEOS) |
| 30 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 29 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 31 return shell_integration_linux::CreateDesktopShortcut(*shortcut_info, | 30 return shell_integration_linux::CreateDesktopShortcut(shortcut_info, |
| 32 creation_locations); | 31 creation_locations); |
| 33 #else | 32 #else |
| 34 return false; | 33 return false; |
| 35 #endif | 34 #endif |
| 36 } | 35 } |
| 37 | 36 |
| 38 void DeletePlatformShortcuts(const base::FilePath& web_app_path, | 37 void DeletePlatformShortcuts(const base::FilePath& web_app_path, |
| 39 std::unique_ptr<ShortcutInfo> shortcut_info) { | 38 const ShortcutInfo& shortcut_info) { |
| 40 #if !defined(OS_CHROMEOS) | 39 #if !defined(OS_CHROMEOS) |
| 41 shell_integration_linux::DeleteDesktopShortcuts(shortcut_info->profile_path, | 40 shell_integration_linux::DeleteDesktopShortcuts(shortcut_info.profile_path, |
| 42 shortcut_info->extension_id); | 41 shortcut_info.extension_id); |
| 43 #endif | 42 #endif |
| 44 } | 43 } |
| 45 | 44 |
| 46 void UpdatePlatformShortcuts(const base::FilePath& web_app_path, | 45 void UpdatePlatformShortcuts(const base::FilePath& web_app_path, |
| 47 const base::string16& /*old_app_title*/, | 46 const base::string16& /*old_app_title*/, |
| 48 std::unique_ptr<ShortcutInfo> shortcut_info) { | 47 const ShortcutInfo& shortcut_info) { |
| 49 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 48 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 50 | 49 |
| 51 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 50 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 52 | 51 |
| 53 // Find out whether shortcuts are already installed. | 52 // Find out whether shortcuts are already installed. |
| 54 ShortcutLocations creation_locations = | 53 ShortcutLocations creation_locations = |
| 55 shell_integration_linux::GetExistingShortcutLocations( | 54 shell_integration_linux::GetExistingShortcutLocations( |
| 56 env.get(), shortcut_info->profile_path, shortcut_info->extension_id); | 55 env.get(), shortcut_info.profile_path, shortcut_info.extension_id); |
| 57 | 56 |
| 58 // Always create a hidden shortcut in applications if a visible one is not | 57 // Always create a hidden shortcut in applications if a visible one is not |
| 59 // being created. This allows the operating system to identify the app, but | 58 // being created. This allows the operating system to identify the app, but |
| 60 // not show it in the menu. | 59 // not show it in the menu. |
| 61 if (creation_locations.applications_menu_location == APP_MENU_LOCATION_NONE) | 60 if (creation_locations.applications_menu_location == APP_MENU_LOCATION_NONE) |
| 62 creation_locations.applications_menu_location = APP_MENU_LOCATION_HIDDEN; | 61 creation_locations.applications_menu_location = APP_MENU_LOCATION_HIDDEN; |
| 63 | 62 |
| 64 CreatePlatformShortcuts(web_app_path, std::move(shortcut_info), | 63 CreatePlatformShortcuts(web_app_path, shortcut_info, creation_locations, |
| 65 creation_locations, SHORTCUT_CREATION_AUTOMATED); | 64 SHORTCUT_CREATION_AUTOMATED); |
| 66 } | 65 } |
| 67 | 66 |
| 68 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { | 67 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { |
| 69 #if !defined(OS_CHROMEOS) | 68 #if !defined(OS_CHROMEOS) |
| 70 shell_integration_linux::DeleteAllDesktopShortcuts(profile_path); | 69 shell_integration_linux::DeleteAllDesktopShortcuts(profile_path); |
| 71 #endif | 70 #endif |
| 72 } | 71 } |
| 73 | 72 |
| 74 } // namespace internals | 73 } // namespace internals |
| 75 | 74 |
| 76 } // namespace web_app | 75 } // namespace web_app |
| OLD | NEW |