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