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