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. 4 5 #ifndef CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ 6 #define CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ 7 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" 14 15 class PrefService; 16 class Profile; 17 18 namespace user_prefs { 19 class PrefRegistrySyncable; 20 } 21 22 // This class manages the installation of shortcuts for platform apps. 23 class AppShortcutManager : public BrowserContextKeyedService, 24 public content::NotificationObserver, 25 public ProfileInfoCacheObserver { 26 public: 27 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 28 29 explicit AppShortcutManager(Profile* profile); 30 31 virtual ~AppShortcutManager(); 32 33 // Checks if kShortcutsEnabled is set in prefs. If not, this sets it and 34 // creates shortcuts for all apps. 35 void OnceOffCreateShortcuts(); 36 37 // content::NotificationObserver 38 virtual void Observe(int type, 39 const content::NotificationSource& source, 40 const content::NotificationDetails& details) OVERRIDE; 41 42 // ProfileInfoCacheObserver 43 virtual void OnProfileWillBeRemoved( 44 const base::FilePath& profile_path) OVERRIDE; 45 46 private: 47 void DeleteApplicationShortcuts(const extensions::Extension* extension); 48 49 content::NotificationRegistrar registrar_; 50 Profile* profile_; 51 bool is_profile_info_cache_observer_; 52 PrefService* prefs_; 53 54 // Fields used when installing application shortcuts. 55 base::WeakPtrFactory<AppShortcutManager> weak_factory_; 56 57 DISALLOW_COPY_AND_ASSIGN(AppShortcutManager); 58 }; 59 60 #endif // CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ 61