Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / apps / shortcut_manager.h
blobfb662d39ebc0dc69c8d4ad427ab21e395ce2c665
1 // Copyright 2013 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 #ifndef CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_
6 #define CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "base/scoped_observer.h"
10 #include "chrome/browser/profiles/profile_info_cache_observer.h"
11 #include "components/keyed_service/core/keyed_service.h"
12 #include "extensions/browser/extension_registry_observer.h"
13 #include "extensions/common/extension.h"
15 class PrefService;
16 class Profile;
18 namespace extensions {
19 class ExtensionRegistry;
22 namespace user_prefs {
23 class PrefRegistrySyncable;
26 // This class manages the installation of shortcuts for platform apps.
27 class AppShortcutManager : public KeyedService,
28 public extensions::ExtensionRegistryObserver,
29 public ProfileInfoCacheObserver {
30 public:
31 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
33 explicit AppShortcutManager(Profile* profile);
35 ~AppShortcutManager() override;
37 // Updates all shortcuts if kAppShortcutsVersion in prefs is less than
38 // kCurrentAppShortcutsVersion.
39 void UpdateShortcutsForAllAppsIfNeeded();
41 // extensions::ExtensionRegistryObserver.
42 void OnExtensionWillBeInstalled(content::BrowserContext* browser_context,
43 const extensions::Extension* extension,
44 bool is_update,
45 bool from_ephemeral,
46 const std::string& old_name) override;
47 void OnExtensionUninstalled(content::BrowserContext* browser_context,
48 const extensions::Extension* extension,
49 extensions::UninstallReason reason) override;
51 // ProfileInfoCacheObserver.
52 void OnProfileWillBeRemoved(const base::FilePath& profile_path) override;
54 private:
55 void DeleteApplicationShortcuts(const extensions::Extension* extension);
57 Profile* profile_;
58 bool is_profile_info_cache_observer_;
59 PrefService* prefs_;
61 ScopedObserver<extensions::ExtensionRegistry,
62 extensions::ExtensionRegistryObserver>
63 extension_registry_observer_;
65 base::WeakPtrFactory<AppShortcutManager> weak_ptr_factory_;
67 DISALLOW_COPY_AND_ASSIGN(AppShortcutManager);
70 #endif // CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_