| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef APPS_SHORTCUT_MANAGER_H_ | 5 #ifndef APPS_SHORTCUT_MANAGER_H_ |
| 6 #define APPS_SHORTCUT_MANAGER_H_ | 6 #define APPS_SHORTCUT_MANAGER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
| 10 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 10 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 | 13 |
| 14 class PrefService; |
| 14 class Profile; | 15 class Profile; |
| 15 | 16 |
| 16 namespace apps { | 17 namespace apps { |
| 17 | 18 |
| 18 // This class manages the installation of shortcuts for platform apps. | 19 // This class manages the installation of shortcuts for platform apps. |
| 19 class ShortcutManager : public BrowserContextKeyedService, | 20 class ShortcutManager : public BrowserContextKeyedService, |
| 20 public content::NotificationObserver { | 21 public content::NotificationObserver { |
| 21 public: | 22 public: |
| 22 explicit ShortcutManager(Profile* profile); | 23 explicit ShortcutManager(Profile* profile); |
| 23 | 24 |
| 24 virtual ~ShortcutManager(); | 25 virtual ~ShortcutManager(); |
| 25 | 26 |
| 26 // content::NotificationObserver | 27 // content::NotificationObserver |
| 27 virtual void Observe(int type, | 28 virtual void Observe(int type, |
| 28 const content::NotificationSource& source, | 29 const content::NotificationSource& source, |
| 29 const content::NotificationDetails& details) OVERRIDE; | 30 const content::NotificationDetails& details) OVERRIDE; |
| 30 | 31 |
| 31 private: | 32 private: |
| 33 // Checks if kShortcutsEnabled is set in prefs. If not, this sets it and |
| 34 // creates shortcuts for all apps. |
| 35 void OnceOffCreateShortcuts(); |
| 36 |
| 32 void DeleteApplicationShortcuts(const extensions::Extension* extension); | 37 void DeleteApplicationShortcuts(const extensions::Extension* extension); |
| 33 | 38 |
| 34 content::NotificationRegistrar registrar_; | 39 content::NotificationRegistrar registrar_; |
| 35 Profile* profile_; | 40 Profile* profile_; |
| 41 PrefService* prefs_; |
| 36 | 42 |
| 37 // Fields used when installing application shortcuts. | 43 // Fields used when installing application shortcuts. |
| 38 base::WeakPtrFactory<ShortcutManager> weak_factory_; | 44 base::WeakPtrFactory<ShortcutManager> weak_factory_; |
| 39 | 45 |
| 40 DISALLOW_COPY_AND_ASSIGN(ShortcutManager); | 46 DISALLOW_COPY_AND_ASSIGN(ShortcutManager); |
| 41 }; | 47 }; |
| 42 | 48 |
| 43 } // namespace apps | 49 } // namespace apps |
| 44 | 50 |
| 45 #endif // APPS_SHORTCUT_MANAGER_H_ | 51 #endif // APPS_SHORTCUT_MANAGER_H_ |
| OLD | NEW |