| 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/error_console/error_console.h" | |
| 13 #include "chrome/browser/extensions/extension_management.h" | 12 #include "chrome/browser/extensions/extension_management.h" |
| 14 #include "chrome/common/extensions/webstore_install_result.h" | 13 #include "chrome/common/extensions/webstore_install_result.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "content/public/browser/web_ui_message_handler.h" | 18 #include "content/public/browser/web_ui_message_handler.h" |
| 20 #include "extensions/browser/extension_prefs_observer.h" | 19 #include "extensions/browser/extension_prefs_observer.h" |
| 21 #include "extensions/browser/extension_registry_observer.h" | |
| 22 #include "extensions/browser/warning_service.h" | 20 #include "extensions/browser/warning_service.h" |
| 23 | 21 |
| 24 class ExtensionService; | 22 class ExtensionService; |
| 25 class GURL; | 23 class GURL; |
| 26 | 24 |
| 27 namespace base { | 25 namespace base { |
| 28 class FilePath; | 26 class FilePath; |
| 29 class ListValue; | 27 class ListValue; |
| 30 } | 28 } |
| 31 | 29 |
| 32 namespace content { | 30 namespace content { |
| 33 class WebUIDataSource; | 31 class WebUIDataSource; |
| 34 } | 32 } |
| 35 | 33 |
| 36 namespace user_prefs { | 34 namespace user_prefs { |
| 37 class PrefRegistrySyncable; | 35 class PrefRegistrySyncable; |
| 38 } | 36 } |
| 39 | 37 |
| 40 namespace extensions { | 38 namespace extensions { |
| 41 class Extension; | 39 class Extension; |
| 42 class ExtensionPrefs; | 40 class ExtensionPrefs; |
| 43 class ExtensionRegistry; | |
| 44 | 41 |
| 45 // Extension Settings UI handler. | 42 // Extension Settings UI handler. |
| 46 class ExtensionSettingsHandler | 43 class ExtensionSettingsHandler |
| 47 : public content::WebUIMessageHandler, | 44 : public content::WebUIMessageHandler, |
| 48 public content::NotificationObserver, | 45 public content::NotificationObserver, |
| 49 public content::WebContentsObserver, | 46 public content::WebContentsObserver, |
| 50 public ErrorConsole::Observer, | |
| 51 public ExtensionManagement::Observer, | 47 public ExtensionManagement::Observer, |
| 52 public ExtensionPrefsObserver, | 48 public ExtensionPrefsObserver, |
| 53 public ExtensionRegistryObserver, | |
| 54 public WarningService::Observer, | 49 public WarningService::Observer, |
| 55 public base::SupportsWeakPtr<ExtensionSettingsHandler> { | 50 public base::SupportsWeakPtr<ExtensionSettingsHandler> { |
| 56 public: | 51 public: |
| 57 ExtensionSettingsHandler(); | 52 ExtensionSettingsHandler(); |
| 58 ~ExtensionSettingsHandler() override; | 53 ~ExtensionSettingsHandler() override; |
| 59 | 54 |
| 60 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 55 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 61 | 56 |
| 62 void GetLocalizedValues(content::WebUIDataSource* source); | 57 void GetLocalizedValues(content::WebUIDataSource* source); |
| 63 | 58 |
| 64 private: | 59 private: |
| 65 // content::WebContentsObserver implementation. | 60 // content::WebContentsObserver implementation. |
| 66 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | 61 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
| 67 void DidStartNavigationToPendingEntry( | 62 void DidStartNavigationToPendingEntry( |
| 68 const GURL& url, | 63 const GURL& url, |
| 69 content::NavigationController::ReloadType reload_type) override; | 64 content::NavigationController::ReloadType reload_type) override; |
| 70 | 65 |
| 71 // WebUIMessageHandler implementation. | 66 // WebUIMessageHandler implementation. |
| 72 void RegisterMessages() override; | 67 void RegisterMessages() override; |
| 73 | 68 |
| 74 // ErrorConsole::Observer implementation. | |
| 75 void OnErrorAdded(const ExtensionError* error) override; | |
| 76 | |
| 77 // content::NotificationObserver implementation. | 69 // content::NotificationObserver implementation. |
| 78 void Observe(int type, | 70 void Observe(int type, |
| 79 const content::NotificationSource& source, | 71 const content::NotificationSource& source, |
| 80 const content::NotificationDetails& details) override; | 72 const content::NotificationDetails& details) override; |
| 81 | 73 |
| 82 // ExtensionRegistryObserver implementation. | |
| 83 void OnExtensionLoaded(content::BrowserContext* browser_context, | |
| 84 const Extension* extension) override; | |
| 85 void OnExtensionUnloaded(content::BrowserContext* browser_context, | |
| 86 const Extension* extension, | |
| 87 UnloadedExtensionInfo::Reason reason) override; | |
| 88 void OnExtensionUninstalled(content::BrowserContext* browser_context, | |
| 89 const Extension* extension, | |
| 90 extensions::UninstallReason reason) override; | |
| 91 | |
| 92 // ExtensionPrefsObserver implementation. | 74 // ExtensionPrefsObserver implementation. |
| 93 void OnExtensionDisableReasonsChanged(const std::string& extension_id, | 75 void OnExtensionDisableReasonsChanged(const std::string& extension_id, |
| 94 int disable_reasons) override; | 76 int disable_reasons) override; |
| 95 | 77 |
| 96 // ExtensionManagement::Observer implementation. | 78 // ExtensionManagement::Observer implementation. |
| 97 void OnExtensionManagementSettingsChanged() override; | 79 void OnExtensionManagementSettingsChanged() override; |
| 98 | 80 |
| 99 // WarningService::Observer implementation. | 81 // WarningService::Observer implementation. |
| 100 void ExtensionWarningsChanged() override; | 82 void ExtensionWarningsChanged() override; |
| 101 | 83 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 // once to the page, otherwise we'd be calling JavaScript functions on objects | 148 // once to the page, otherwise we'd be calling JavaScript functions on objects |
| 167 // that don't exist yet when notifications come in. This variable makes sure | 149 // that don't exist yet when notifications come in. This variable makes sure |
| 168 // we do so only once. | 150 // we do so only once. |
| 169 bool registered_for_notifications_; | 151 bool registered_for_notifications_; |
| 170 | 152 |
| 171 content::NotificationRegistrar registrar_; | 153 content::NotificationRegistrar registrar_; |
| 172 | 154 |
| 173 ScopedObserver<WarningService, WarningService::Observer> | 155 ScopedObserver<WarningService, WarningService::Observer> |
| 174 warning_service_observer_; | 156 warning_service_observer_; |
| 175 | 157 |
| 176 // An observer to listen for when Extension errors are reported. | |
| 177 ScopedObserver<ErrorConsole, ErrorConsole::Observer> error_console_observer_; | |
| 178 | |
| 179 // An observer to listen for notable changes in the ExtensionPrefs, like | 158 // An observer to listen for notable changes in the ExtensionPrefs, like |
| 180 // a change in Disable Reasons. | 159 // a change in Disable Reasons. |
| 181 ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver> | 160 ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver> |
| 182 extension_prefs_observer_; | 161 extension_prefs_observer_; |
| 183 | 162 |
| 184 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
| 185 extension_registry_observer_; | |
| 186 | |
| 187 ScopedObserver<ExtensionManagement, ExtensionManagement::Observer> | 163 ScopedObserver<ExtensionManagement, ExtensionManagement::Observer> |
| 188 extension_management_observer_; | 164 extension_management_observer_; |
| 189 | 165 |
| 190 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off | |
| 191 // a verification check to try and rescue them. | |
| 192 bool should_do_verification_check_; | |
| 193 | |
| 194 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 166 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
| 195 }; | 167 }; |
| 196 | 168 |
| 197 } // namespace extensions | 169 } // namespace extensions |
| 198 | 170 |
| 199 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 171 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |