blob: f1b1b5ecf1afea1066d7e012261de7e07b4c611b [file] [log] [blame]
[email protected]b6b72222012-02-11 02:04:131// 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
dchenge73d8520c2015-12-27 01:19:097#include <utility>
8
[email protected]b6b72222012-02-11 02:04:139#include "base/environment.h"
[email protected]92269382012-03-03 09:00:0810#include "base/logging.h"
avi664c07b2015-12-26 02:18:3111#include "build/build_config.h"
[email protected]8806d3b2012-04-13 06:46:3412#include "chrome/browser/shell_integration_linux.h"
[email protected]b6b72222012-02-11 02:04:1313#include "content/public/browser/browser_thread.h"
14
15namespace web_app {
[email protected]e66ba952012-10-09 09:59:4416
[email protected]090e1ee72014-06-03 13:08:4017void UpdateShortcutsForAllApps(Profile* profile,
18 const base::Closure& callback) {
19 callback.Run();
20}
21
[email protected]b6b72222012-02-11 02:04:1322namespace internals {
23
[email protected]c002e752012-08-10 12:50:1124bool CreatePlatformShortcuts(
[email protected]650b2d52013-02-10 03:41:4525 const base::FilePath& web_app_path,
dcheng4af48582016-04-19 00:29:3526 std::unique_ptr<ShortcutInfo> shortcut_info,
[email protected]e6be3fe2014-04-11 13:17:5127 const extensions::FileHandlersInfo& file_handlers_info,
[email protected]9b1b5fe2014-05-15 08:23:1728 const ShortcutLocations& creation_locations,
[email protected]a705c7ee72013-07-26 08:01:5429 ShortcutCreationReason /*creation_reason*/) {
[email protected]9aadaa42013-08-16 10:43:1730#if !defined(OS_CHROMEOS)
anujk.sharma9fcea9a2015-04-22 06:57:4931 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
mgiucab21fe8ee2015-04-09 04:00:4432 return shell_integration_linux::CreateDesktopShortcut(*shortcut_info,
33 creation_locations);
[email protected]9aadaa42013-08-16 10:43:1734#else
35 return false;
36#endif
[email protected]b6b72222012-02-11 02:04:1337}
38
[email protected]9b1b5fe2014-05-15 08:23:1739void DeletePlatformShortcuts(const base::FilePath& web_app_path,
dcheng4af48582016-04-19 00:29:3540 std::unique_ptr<ShortcutInfo> shortcut_info) {
[email protected]9aadaa42013-08-16 10:43:1741#if !defined(OS_CHROMEOS)
mgiucab21fe8ee2015-04-09 04:00:4442 shell_integration_linux::DeleteDesktopShortcuts(shortcut_info->profile_path,
43 shortcut_info->extension_id);
[email protected]9aadaa42013-08-16 10:43:1744#endif
[email protected]0b7df36d2012-07-11 09:50:4745}
46
[email protected]e66ba952012-10-09 09:59:4447void UpdatePlatformShortcuts(
[email protected]650b2d52013-02-10 03:41:4548 const base::FilePath& web_app_path,
[email protected]0085863a2013-12-06 21:19:0349 const base::string16& /*old_app_title*/,
dcheng4af48582016-04-19 00:29:3550 std::unique_ptr<ShortcutInfo> shortcut_info,
[email protected]e6be3fe2014-04-11 13:17:5151 const extensions::FileHandlersInfo& file_handlers_info) {
anujk.sharma9fcea9a2015-04-22 06:57:4952 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
[email protected]d81a63c02013-03-07 08:49:0453
dcheng4af48582016-04-19 00:29:3554 std::unique_ptr<base::Environment> env(base::Environment::Create());
[email protected]d81a63c02013-03-07 08:49:0455
56 // Find out whether shortcuts are already installed.
[email protected]9b1b5fe2014-05-15 08:23:1757 ShortcutLocations creation_locations =
[email protected]06bfeb12014-05-27 14:00:0958 shell_integration_linux::GetExistingShortcutLocations(
mgiucab21fe8ee2015-04-09 04:00:4459 env.get(), shortcut_info->profile_path, shortcut_info->extension_id);
[email protected]da0349e2014-06-11 07:38:2860
[email protected]d81a63c02013-03-07 08:49:0461 // 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
63 // not show it in the menu.
[email protected]da0349e2014-06-11 07:38:2864 if (creation_locations.applications_menu_location == APP_MENU_LOCATION_NONE)
65 creation_locations.applications_menu_location = APP_MENU_LOCATION_HIDDEN;
[email protected]d81a63c02013-03-07 08:49:0466
dchenge73d8520c2015-12-27 01:19:0967 CreatePlatformShortcuts(web_app_path, std::move(shortcut_info),
mgiucab21fe8ee2015-04-09 04:00:4468 file_handlers_info, creation_locations,
[email protected]da0349e2014-06-11 07:38:2869 SHORTCUT_CREATION_AUTOMATED);
[email protected]e66ba952012-10-09 09:59:4470}
71
[email protected]f80bda02013-07-02 10:30:3172void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
[email protected]9aadaa42013-08-16 10:43:1773#if !defined(OS_CHROMEOS)
[email protected]06bfeb12014-05-27 14:00:0974 shell_integration_linux::DeleteAllDesktopShortcuts(profile_path);
[email protected]9aadaa42013-08-16 10:43:1775#endif
[email protected]f80bda02013-07-02 10:30:3176}
77
[email protected]b6b72222012-02-11 02:04:1378} // namespace internals
[email protected]e66ba952012-10-09 09:59:4479
[email protected]b6b72222012-02-11 02:04:1380} // namespace web_app