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