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 CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find
er.h" | |
13 #include "chrome/browser/extensions/error_console/error_console.h" | 12 #include "chrome/browser/extensions/error_console/error_console.h" |
14 #include "chrome/browser/extensions/extension_install_prompt.h" | |
15 #include "chrome/browser/extensions/extension_management.h" | 13 #include "chrome/browser/extensions/extension_management.h" |
16 #include "chrome/common/extensions/webstore_install_result.h" | 14 #include "chrome/common/extensions/webstore_install_result.h" |
17 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/browser/web_ui_message_handler.h" | 19 #include "content/public/browser/web_ui_message_handler.h" |
22 #include "extensions/browser/extension_prefs_observer.h" | 20 #include "extensions/browser/extension_prefs_observer.h" |
23 #include "extensions/browser/extension_registry_observer.h" | 21 #include "extensions/browser/extension_registry_observer.h" |
24 #include "extensions/browser/warning_service.h" | 22 #include "extensions/browser/warning_service.h" |
(...skipping 18 matching lines...) Expand all Loading... |
43 class Extension; | 41 class Extension; |
44 class ExtensionPrefs; | 42 class ExtensionPrefs; |
45 class ExtensionRegistry; | 43 class ExtensionRegistry; |
46 | 44 |
47 // Extension Settings UI handler. | 45 // Extension Settings UI handler. |
48 class ExtensionSettingsHandler | 46 class ExtensionSettingsHandler |
49 : public content::WebUIMessageHandler, | 47 : public content::WebUIMessageHandler, |
50 public content::NotificationObserver, | 48 public content::NotificationObserver, |
51 public content::WebContentsObserver, | 49 public content::WebContentsObserver, |
52 public ErrorConsole::Observer, | 50 public ErrorConsole::Observer, |
53 public ExtensionInstallPrompt::Delegate, | |
54 public ExtensionManagement::Observer, | 51 public ExtensionManagement::Observer, |
55 public ExtensionPrefsObserver, | 52 public ExtensionPrefsObserver, |
56 public ExtensionRegistryObserver, | 53 public ExtensionRegistryObserver, |
57 public WarningService::Observer, | 54 public WarningService::Observer, |
58 public base::SupportsWeakPtr<ExtensionSettingsHandler> { | 55 public base::SupportsWeakPtr<ExtensionSettingsHandler> { |
59 public: | 56 public: |
60 ExtensionSettingsHandler(); | 57 ExtensionSettingsHandler(); |
61 ~ExtensionSettingsHandler() override; | 58 ~ExtensionSettingsHandler() override; |
62 | 59 |
63 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 60 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
64 | 61 |
65 void GetLocalizedValues(content::WebUIDataSource* source); | 62 void GetLocalizedValues(content::WebUIDataSource* source); |
66 | 63 |
67 private: | 64 private: |
68 friend class BrokerDelegate; | |
69 | |
70 // content::WebContentsObserver implementation. | 65 // content::WebContentsObserver implementation. |
71 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | 66 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
72 void DidStartNavigationToPendingEntry( | 67 void DidStartNavigationToPendingEntry( |
73 const GURL& url, | 68 const GURL& url, |
74 content::NavigationController::ReloadType reload_type) override; | 69 content::NavigationController::ReloadType reload_type) override; |
75 | 70 |
76 // WebUIMessageHandler implementation. | 71 // WebUIMessageHandler implementation. |
77 void RegisterMessages() override; | 72 void RegisterMessages() override; |
78 | 73 |
79 // ErrorConsole::Observer implementation. | 74 // ErrorConsole::Observer implementation. |
(...skipping 17 matching lines...) Expand all Loading... |
97 // ExtensionPrefsObserver implementation. | 92 // ExtensionPrefsObserver implementation. |
98 void OnExtensionDisableReasonsChanged(const std::string& extension_id, | 93 void OnExtensionDisableReasonsChanged(const std::string& extension_id, |
99 int disable_reasons) override; | 94 int disable_reasons) override; |
100 | 95 |
101 // ExtensionManagement::Observer implementation. | 96 // ExtensionManagement::Observer implementation. |
102 void OnExtensionManagementSettingsChanged() override; | 97 void OnExtensionManagementSettingsChanged() override; |
103 | 98 |
104 // WarningService::Observer implementation. | 99 // WarningService::Observer implementation. |
105 void ExtensionWarningsChanged() override; | 100 void ExtensionWarningsChanged() override; |
106 | 101 |
107 // ExtensionInstallPrompt::Delegate implementation. | |
108 void InstallUIProceed() override; | |
109 void InstallUIAbort(bool user_initiated) override; | |
110 | |
111 // Called after the App Info Dialog has closed. | |
112 virtual void AppInfoDialogClosed(); | |
113 | |
114 // Helper method that reloads all unpacked extensions. | 102 // Helper method that reloads all unpacked extensions. |
115 void ReloadUnpackedExtensions(); | 103 void ReloadUnpackedExtensions(); |
116 | 104 |
117 // Callback for "requestExtensionsData" message. | 105 // Callback for "requestExtensionsData" message. |
118 void HandleRequestExtensionsData(const base::ListValue* args); | 106 void HandleRequestExtensionsData(const base::ListValue* args); |
119 | 107 |
120 // Callback for "toggleDeveloperMode" message. | 108 // Callback for "toggleDeveloperMode" message. |
121 void HandleToggleDeveloperMode(const base::ListValue* args); | 109 void HandleToggleDeveloperMode(const base::ListValue* args); |
122 | 110 |
123 // Callback for "launch" message. | 111 // Callback for "launch" message. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 void MaybeRegisterForNotifications(); | 149 void MaybeRegisterForNotifications(); |
162 | 150 |
163 // Called when the reinstallation is complete. | 151 // Called when the reinstallation is complete. |
164 void OnReinstallComplete(bool success, | 152 void OnReinstallComplete(bool success, |
165 const std::string& error, | 153 const std::string& error, |
166 webstore_install::Result result); | 154 webstore_install::Result result); |
167 | 155 |
168 // Our model. Outlives us since it's owned by our containing profile. | 156 // Our model. Outlives us since it's owned by our containing profile. |
169 ExtensionService* extension_service_; | 157 ExtensionService* extension_service_; |
170 | 158 |
171 // The id of the extension we are prompting the user about. | |
172 std::string extension_id_prompting_; | |
173 | |
174 // If true, we will ignore notifications in ::Observe(). This is needed | 159 // If true, we will ignore notifications in ::Observe(). This is needed |
175 // to prevent reloading the page when we were the cause of the | 160 // to prevent reloading the page when we were the cause of the |
176 // notification. | 161 // notification. |
177 bool ignore_notifications_; | 162 bool ignore_notifications_; |
178 | 163 |
179 // The page may be refreshed in response to a RenderViewHost being destroyed, | 164 // The page may be refreshed in response to a RenderViewHost being destroyed, |
180 // but the iteration over RenderViewHosts will include the host because the | 165 // but the iteration over RenderViewHosts will include the host because the |
181 // notification is sent when it is in the process of being deleted (and before | 166 // notification is sent when it is in the process of being deleted (and before |
182 // it is removed from the process). Keep a pointer to it so we can exclude | 167 // it is removed from the process). Keep a pointer to it so we can exclude |
183 // it from the active views. | 168 // it from the active views. |
184 content::RenderViewHost* deleting_rvh_; | 169 content::RenderViewHost* deleting_rvh_; |
185 // Do the same for a deleting RenderWidgetHost ID and RenderProcessHost ID. | 170 // Do the same for a deleting RenderWidgetHost ID and RenderProcessHost ID. |
186 int deleting_rwh_id_; | 171 int deleting_rwh_id_; |
187 int deleting_rph_id_; | 172 int deleting_rph_id_; |
188 | 173 |
189 // We want to register for notifications only after we've responded at least | 174 // We want to register for notifications only after we've responded at least |
190 // once to the page, otherwise we'd be calling JavaScript functions on objects | 175 // once to the page, otherwise we'd be calling JavaScript functions on objects |
191 // that don't exist yet when notifications come in. This variable makes sure | 176 // that don't exist yet when notifications come in. This variable makes sure |
192 // we do so only once. | 177 // we do so only once. |
193 bool registered_for_notifications_; | 178 bool registered_for_notifications_; |
194 | 179 |
195 content::NotificationRegistrar registrar_; | 180 content::NotificationRegistrar registrar_; |
196 | 181 |
197 // The UI for showing what permissions the extension has. | |
198 scoped_ptr<ExtensionInstallPrompt> prompt_; | |
199 | |
200 ScopedObserver<WarningService, WarningService::Observer> | 182 ScopedObserver<WarningService, WarningService::Observer> |
201 warning_service_observer_; | 183 warning_service_observer_; |
202 | 184 |
203 // An observer to listen for when Extension errors are reported. | 185 // An observer to listen for when Extension errors are reported. |
204 ScopedObserver<ErrorConsole, ErrorConsole::Observer> error_console_observer_; | 186 ScopedObserver<ErrorConsole, ErrorConsole::Observer> error_console_observer_; |
205 | 187 |
206 // An observer to listen for notable changes in the ExtensionPrefs, like | 188 // An observer to listen for notable changes in the ExtensionPrefs, like |
207 // a change in Disable Reasons. | 189 // a change in Disable Reasons. |
208 ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver> | 190 ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver> |
209 extension_prefs_observer_; | 191 extension_prefs_observer_; |
210 | 192 |
211 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 193 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
212 extension_registry_observer_; | 194 extension_registry_observer_; |
213 | 195 |
214 ScopedObserver<ExtensionManagement, ExtensionManagement::Observer> | 196 ScopedObserver<ExtensionManagement, ExtensionManagement::Observer> |
215 extension_management_observer_; | 197 extension_management_observer_; |
216 | 198 |
217 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off | 199 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off |
218 // a verification check to try and rescue them. | 200 // a verification check to try and rescue them. |
219 bool should_do_verification_check_; | 201 bool should_do_verification_check_; |
220 | 202 |
221 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 203 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
222 }; | 204 }; |
223 | 205 |
224 } // namespace extensions | 206 } // namespace extensions |
225 | 207 |
226 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 208 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
OLD | NEW |