Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / web_applications / web_app_linux.cc
blob193375c2bf947ca88bfd855b1222a5742928d08e
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.
5 #include "chrome/browser/web_applications/web_app.h"
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"
12 namespace web_app {
14 void UpdateShortcutsForAllApps(Profile* profile,
15 const base::Closure& callback) {
16 callback.Run();
19 namespace internals {
21 bool CreatePlatformShortcuts(
22 const base::FilePath& web_app_path,
23 scoped_ptr<ShortcutInfo> shortcut_info,
24 const extensions::FileHandlersInfo& file_handlers_info,
25 const ShortcutLocations& creation_locations,
26 ShortcutCreationReason /*creation_reason*/) {
27 #if !defined(OS_CHROMEOS)
28 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
29 return shell_integration_linux::CreateDesktopShortcut(*shortcut_info,
30 creation_locations);
31 #else
32 return false;
33 #endif
36 void DeletePlatformShortcuts(const base::FilePath& web_app_path,
37 scoped_ptr<ShortcutInfo> shortcut_info) {
38 #if !defined(OS_CHROMEOS)
39 shell_integration_linux::DeleteDesktopShortcuts(shortcut_info->profile_path,
40 shortcut_info->extension_id);
41 #endif
44 void UpdatePlatformShortcuts(
45 const base::FilePath& web_app_path,
46 const base::string16& /*old_app_title*/,
47 scoped_ptr<ShortcutInfo> shortcut_info,
48 const extensions::FileHandlersInfo& file_handlers_info) {
49 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
51 scoped_ptr<base::Environment> env(base::Environment::Create());
53 // Find out whether shortcuts are already installed.
54 ShortcutLocations creation_locations =
55 shell_integration_linux::GetExistingShortcutLocations(
56 env.get(), shortcut_info->profile_path, shortcut_info->extension_id);
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
60 // not show it in the menu.
61 if (creation_locations.applications_menu_location == APP_MENU_LOCATION_NONE)
62 creation_locations.applications_menu_location = APP_MENU_LOCATION_HIDDEN;
64 CreatePlatformShortcuts(web_app_path, shortcut_info.Pass(),
65 file_handlers_info, creation_locations,
66 SHORTCUT_CREATION_AUTOMATED);
69 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
70 #if !defined(OS_CHROMEOS)
71 shell_integration_linux::DeleteAllDesktopShortcuts(profile_path);
72 #endif
75 } // namespace internals
77 } // namespace web_app