OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ |
6 #define CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/browser/dom_ui/dom_ui.h" | 10 #include "chrome/browser/dom_ui/dom_ui.h" |
11 #include "chrome/browser/extensions/extension_install_ui.h" | 11 #include "chrome/browser/extensions/extension_install_ui.h" |
| 12 #include "chrome/browser/prefs/pref_change_registrar.h" |
12 #include "chrome/common/notification_observer.h" | 13 #include "chrome/common/notification_observer.h" |
13 #include "chrome/common/notification_registrar.h" | 14 #include "chrome/common/notification_registrar.h" |
14 | 15 |
15 class Extension; | 16 class Extension; |
| 17 class ExtensionPrefs; |
16 class ExtensionsService; | 18 class ExtensionsService; |
| 19 class NotificationRegistrar; |
| 20 class PrefChangeRegistrar; |
17 | 21 |
18 namespace gfx { | 22 namespace gfx { |
19 class Rect; | 23 class Rect; |
20 } | 24 } |
21 | 25 |
22 // The handler for Javascript messages related to the "apps" view. | 26 // The handler for Javascript messages related to the "apps" view. |
23 class AppLauncherHandler | 27 class AppLauncherHandler |
24 : public DOMMessageHandler, | 28 : public DOMMessageHandler, |
25 public ExtensionInstallUI::Delegate, | 29 public ExtensionInstallUI::Delegate, |
26 public NotificationObserver { | 30 public NotificationObserver { |
27 public: | 31 public: |
28 explicit AppLauncherHandler(ExtensionsService* extension_service); | 32 explicit AppLauncherHandler(ExtensionsService* extension_service); |
29 virtual ~AppLauncherHandler(); | 33 virtual ~AppLauncherHandler(); |
30 | 34 |
31 // DOMMessageHandler implementation. | 35 // DOMMessageHandler implementation. |
32 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); | 36 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); |
33 virtual void RegisterMessages(); | 37 virtual void RegisterMessages(); |
34 | 38 |
35 // NotificationObserver | 39 // NotificationObserver |
36 virtual void Observe(NotificationType type, | 40 virtual void Observe(NotificationType type, |
37 const NotificationSource& source, | 41 const NotificationSource& source, |
38 const NotificationDetails& details); | 42 const NotificationDetails& details); |
39 | 43 |
40 // Populate a dictionary with the information from an extension. | 44 // Populate a dictionary with the information from an extension. |
41 static void CreateAppInfo(Extension* extension, DictionaryValue* value); | 45 static void CreateAppInfo(Extension* extension, |
| 46 ExtensionPrefs* extension_prefs, |
| 47 DictionaryValue* value); |
| 48 |
| 49 // Populate the given dictionary with all installed app info. |
| 50 void FillAppDictionary(DictionaryValue* value); |
42 | 51 |
43 // Callback for the "getApps" message. | 52 // Callback for the "getApps" message. |
44 void HandleGetApps(const ListValue* args); | 53 void HandleGetApps(const ListValue* args); |
45 | 54 |
46 // Callback for the "launchApp" message. | 55 // Callback for the "launchApp" message. |
47 void HandleLaunchApp(const ListValue* args); | 56 void HandleLaunchApp(const ListValue* args); |
48 | 57 |
| 58 // Callback for the "setLaunchType" message. |
| 59 void HandleSetLaunchType(const ListValue* args); |
| 60 |
49 // Callback for the "uninstallApp" message. | 61 // Callback for the "uninstallApp" message. |
50 void HandleUninstallApp(const ListValue* args); | 62 void HandleUninstallApp(const ListValue* args); |
51 | 63 |
52 private: | 64 private: |
53 // ExtensionInstallUI::Delegate implementation, used for receiving | 65 // ExtensionInstallUI::Delegate implementation, used for receiving |
54 // notification about uninstall confirmation dialog selections. | 66 // notification about uninstall confirmation dialog selections. |
55 virtual void InstallUIProceed(); | 67 virtual void InstallUIProceed(); |
56 virtual void InstallUIAbort(); | 68 virtual void InstallUIAbort(); |
57 | 69 |
58 // Returns the ExtensionInstallUI object for this class, creating it if | 70 // Returns the ExtensionInstallUI object for this class, creating it if |
59 // needed. | 71 // needed. |
60 ExtensionInstallUI* GetExtensionInstallUI(); | 72 ExtensionInstallUI* GetExtensionInstallUI(); |
61 | 73 |
62 // Starts the animation of the app icon. | 74 // Starts the animation of the app icon. |
63 void AnimateAppIcon(Extension* extension, const gfx::Rect& rect); | 75 void AnimateAppIcon(Extension* extension, const gfx::Rect& rect); |
64 | 76 |
65 // The apps are represented in the extensions model. | 77 // The apps are represented in the extensions model. |
66 scoped_refptr<ExtensionsService> extensions_service_; | 78 scoped_refptr<ExtensionsService> extensions_service_; |
67 | 79 |
68 // We monitor changes to the extension system so that we can reload the apps | 80 // We monitor changes to the extension system so that we can reload the apps |
69 // when necessary. | 81 // when necessary. |
70 NotificationRegistrar registrar_; | 82 NotificationRegistrar registrar_; |
71 | 83 |
| 84 // Monitor extension preference changes so that the DOM UI can be notified. |
| 85 PrefChangeRegistrar pref_change_registrar_; |
| 86 |
72 // Used to show confirmation UI for uninstalling/enabling extensions in | 87 // Used to show confirmation UI for uninstalling/enabling extensions in |
73 // incognito mode. | 88 // incognito mode. |
74 scoped_ptr<ExtensionInstallUI> install_ui_; | 89 scoped_ptr<ExtensionInstallUI> install_ui_; |
75 | 90 |
76 // The id of the extension we are prompting the user about. | 91 // The id of the extension we are prompting the user about. |
77 std::string extension_id_prompting_; | 92 std::string extension_id_prompting_; |
78 | 93 |
79 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 94 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
80 }; | 95 }; |
81 | 96 |
82 #endif // CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ | 97 #endif // CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ |
OLD | NEW |