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( |
25 const base::FilePath& web_app_path, | 25 const base::FilePath& web_app_path, |
26 std::unique_ptr<ShortcutInfo> shortcut_info, | 26 std::unique_ptr<ShortcutInfo> shortcut_info, |
27 const extensions::FileHandlersInfo& file_handlers_info, | |
28 const ShortcutLocations& creation_locations, | 27 const ShortcutLocations& creation_locations, |
29 ShortcutCreationReason /*creation_reason*/) { | 28 ShortcutCreationReason /*creation_reason*/) { |
30 #if !defined(OS_CHROMEOS) | 29 #if !defined(OS_CHROMEOS) |
31 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 30 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
32 return shell_integration_linux::CreateDesktopShortcut(*shortcut_info, | 31 return shell_integration_linux::CreateDesktopShortcut(*shortcut_info, |
33 creation_locations); | 32 creation_locations); |
34 #else | 33 #else |
35 return false; | 34 return false; |
36 #endif | 35 #endif |
37 } | 36 } |
38 | 37 |
39 void DeletePlatformShortcuts(const base::FilePath& web_app_path, | 38 void DeletePlatformShortcuts(const base::FilePath& web_app_path, |
40 std::unique_ptr<ShortcutInfo> shortcut_info) { | 39 std::unique_ptr<ShortcutInfo> shortcut_info) { |
41 #if !defined(OS_CHROMEOS) | 40 #if !defined(OS_CHROMEOS) |
42 shell_integration_linux::DeleteDesktopShortcuts(shortcut_info->profile_path, | 41 shell_integration_linux::DeleteDesktopShortcuts(shortcut_info->profile_path, |
43 shortcut_info->extension_id); | 42 shortcut_info->extension_id); |
44 #endif | 43 #endif |
45 } | 44 } |
46 | 45 |
47 void UpdatePlatformShortcuts( | 46 void UpdatePlatformShortcuts(const base::FilePath& web_app_path, |
48 const base::FilePath& web_app_path, | 47 const base::string16& /*old_app_title*/, |
49 const base::string16& /*old_app_title*/, | 48 std::unique_ptr<ShortcutInfo> shortcut_info) { |
50 std::unique_ptr<ShortcutInfo> shortcut_info, | |
51 const extensions::FileHandlersInfo& file_handlers_info) { | |
52 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 49 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
53 | 50 |
54 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 51 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
55 | 52 |
56 // Find out whether shortcuts are already installed. | 53 // Find out whether shortcuts are already installed. |
57 ShortcutLocations creation_locations = | 54 ShortcutLocations creation_locations = |
58 shell_integration_linux::GetExistingShortcutLocations( | 55 shell_integration_linux::GetExistingShortcutLocations( |
59 env.get(), shortcut_info->profile_path, shortcut_info->extension_id); | 56 env.get(), shortcut_info->profile_path, shortcut_info->extension_id); |
60 | 57 |
61 // 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 |
62 // 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 |
63 // not show it in the menu. | 60 // not show it in the menu. |
64 if (creation_locations.applications_menu_location == APP_MENU_LOCATION_NONE) | 61 if (creation_locations.applications_menu_location == APP_MENU_LOCATION_NONE) |
65 creation_locations.applications_menu_location = APP_MENU_LOCATION_HIDDEN; | 62 creation_locations.applications_menu_location = APP_MENU_LOCATION_HIDDEN; |
66 | 63 |
67 CreatePlatformShortcuts(web_app_path, std::move(shortcut_info), | 64 CreatePlatformShortcuts(web_app_path, std::move(shortcut_info), |
68 file_handlers_info, creation_locations, | 65 creation_locations, SHORTCUT_CREATION_AUTOMATED); |
69 SHORTCUT_CREATION_AUTOMATED); | |
70 } | 66 } |
71 | 67 |
72 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { | 68 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { |
73 #if !defined(OS_CHROMEOS) | 69 #if !defined(OS_CHROMEOS) |
74 shell_integration_linux::DeleteAllDesktopShortcuts(profile_path); | 70 shell_integration_linux::DeleteAllDesktopShortcuts(profile_path); |
75 #endif | 71 #endif |
76 } | 72 } |
77 | 73 |
78 } // namespace internals | 74 } // namespace internals |
79 | 75 |
80 } // namespace web_app | 76 } // namespace web_app |
OLD | NEW |