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 "chrome/browser/profiles/profile_info_cache_observer.h"
10 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "extensions/common/extension.h"
18 namespace user_prefs
{
19 class PrefRegistrySyncable
;
22 // This class manages the installation of shortcuts for platform apps.
23 class AppShortcutManager
: public BrowserContextKeyedService
,
24 public content::NotificationObserver
,
25 public ProfileInfoCacheObserver
{
27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable
* registry
);
29 explicit AppShortcutManager(Profile
* profile
);
31 virtual ~AppShortcutManager();
33 // Checks if kShortcutsEnabled is set in prefs. If not, this sets it and
34 // creates shortcuts for all apps.
35 void OnceOffCreateShortcuts();
37 // content::NotificationObserver
38 virtual void Observe(int type
,
39 const content::NotificationSource
& source
,
40 const content::NotificationDetails
& details
) OVERRIDE
;
42 // ProfileInfoCacheObserver
43 virtual void OnProfileWillBeRemoved(
44 const base::FilePath
& profile_path
) OVERRIDE
;
47 void DeleteApplicationShortcuts(const extensions::Extension
* extension
);
49 content::NotificationRegistrar registrar_
;
51 bool is_profile_info_cache_observer_
;
54 // Fields used when installing application shortcuts.
55 base::WeakPtrFactory
<AppShortcutManager
> weak_factory_
;
57 DISALLOW_COPY_AND_ASSIGN(AppShortcutManager
);
60 #endif // CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_