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