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