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