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