Chromium Code Reviews| 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 <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/prefs/public/pref_change_registrar.h" | 13 #include "base/prefs/public/pref_change_registrar.h" |
| 14 #include "base/prefs/public/pref_observer.h" | 14 #include "base/prefs/public/pref_observer.h" |
| 15 #include "base/scoped_observer.h" | |
| 15 #include "chrome/browser/extensions/extension_install_ui.h" | 16 #include "chrome/browser/extensions/extension_install_ui.h" |
| 16 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 17 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 17 #include "chrome/browser/extensions/extension_warning_set.h" | 18 #include "chrome/browser/extensions/extension_warning_service.h" |
| 18 #include "chrome/browser/extensions/requirements_checker.h" | 19 #include "chrome/browser/extensions/requirements_checker.h" |
| 19 #include "chrome/common/extensions/extension_resource.h" | 20 #include "chrome/common/extensions/extension_resource.h" |
| 20 #include "content/public/browser/navigation_controller.h" | 21 #include "content/public/browser/navigation_controller.h" |
| 21 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/web_contents_observer.h" | 25 #include "content/public/browser/web_contents_observer.h" |
| 25 #include "content/public/browser/web_ui_message_handler.h" | 26 #include "content/public/browser/web_ui_message_handler.h" |
| 26 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 27 #include "ui/base/dialogs/select_file_dialog.h" | 28 #include "ui/base/dialogs/select_file_dialog.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 // Extension Settings UI handler. | 60 // Extension Settings UI handler. |
| 60 class ExtensionSettingsHandler | 61 class ExtensionSettingsHandler |
| 61 : public content::WebUIMessageHandler, | 62 : public content::WebUIMessageHandler, |
| 62 public content::NotificationObserver, | 63 public content::NotificationObserver, |
| 63 public PrefObserver, | 64 public PrefObserver, |
| 64 public content::WebContentsObserver, | 65 public content::WebContentsObserver, |
| 65 public ui::SelectFileDialog::Listener, | 66 public ui::SelectFileDialog::Listener, |
| 66 public ExtensionUninstallDialog::Delegate, | 67 public ExtensionUninstallDialog::Delegate, |
| 67 public base::SupportsWeakPtr<ExtensionSettingsHandler>{ | 68 public extensions::ExtensionWarningService::Observer, |
| 69 public base::SupportsWeakPtr<ExtensionSettingsHandler> { | |
| 68 public: | 70 public: |
| 69 ExtensionSettingsHandler(); | 71 ExtensionSettingsHandler(); |
| 70 virtual ~ExtensionSettingsHandler(); | 72 virtual ~ExtensionSettingsHandler(); |
| 71 | 73 |
| 72 static void RegisterUserPrefs(PrefService* prefs); | 74 static void RegisterUserPrefs(PrefService* prefs); |
| 73 | 75 |
| 74 // Extension Detail JSON Struct for page. |pages| is injected for unit | 76 // Extension Detail JSON Struct for page. |pages| is injected for unit |
| 75 // testing. | 77 // testing. |
| 76 // Note: |warning_set| can be NULL in unit tests. | 78 // Note: |warning_service| can be NULL in unit tests. |
| 77 base::DictionaryValue* CreateExtensionDetailValue( | 79 base::DictionaryValue* CreateExtensionDetailValue( |
| 78 const extensions::Extension* extension, | 80 const extensions::Extension* extension, |
| 79 const std::vector<ExtensionPage>& pages, | 81 const std::vector<ExtensionPage>& pages, |
| 80 const ExtensionWarningSet* warning_set); | 82 const extensions::ExtensionWarningService* warning_service); |
| 81 | 83 |
| 82 void GetLocalizedValues(base::DictionaryValue* localized_strings); | 84 void GetLocalizedValues(base::DictionaryValue* localized_strings); |
| 83 | 85 |
| 84 // content::WebContentsObserver implementation, which reloads all unpacked | 86 // content::WebContentsObserver implementation, which reloads all unpacked |
| 85 // extensions whenever chrome://extensions is reloaded. | 87 // extensions whenever chrome://extensions is reloaded. |
| 86 virtual void NavigateToPendingEntry( | 88 virtual void NavigateToPendingEntry( |
| 87 const GURL& url, | 89 const GURL& url, |
| 88 content::NavigationController::ReloadType reload_type) OVERRIDE; | 90 content::NavigationController::ReloadType reload_type) OVERRIDE; |
| 89 | 91 |
| 90 private: | 92 private: |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 111 | 113 |
| 112 // PrefObserver implementation. | 114 // PrefObserver implementation. |
| 113 virtual void OnPreferenceChanged(PrefServiceBase* service, | 115 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 114 const std::string& pref_name) OVERRIDE; | 116 const std::string& pref_name) OVERRIDE; |
| 115 | 117 |
| 116 // ExtensionUninstallDialog::Delegate implementation, used for receiving | 118 // ExtensionUninstallDialog::Delegate implementation, used for receiving |
| 117 // notification about uninstall confirmation dialog selections. | 119 // notification about uninstall confirmation dialog selections. |
| 118 virtual void ExtensionUninstallAccepted() OVERRIDE; | 120 virtual void ExtensionUninstallAccepted() OVERRIDE; |
| 119 virtual void ExtensionUninstallCanceled() OVERRIDE; | 121 virtual void ExtensionUninstallCanceled() OVERRIDE; |
| 120 | 122 |
| 123 // extensions::ExtensionWarningService::Observer implementation. | |
| 124 virtual void ExtensionWarningsChanged() OVERRIDE; | |
| 125 | |
| 121 // Helper method that reloads all unpacked extensions. | 126 // Helper method that reloads all unpacked extensions. |
| 122 void ReloadUnpackedExtensions(); | 127 void ReloadUnpackedExtensions(); |
| 123 | 128 |
| 124 // Callback for "requestExtensionsData" message. | 129 // Callback for "requestExtensionsData" message. |
| 125 void HandleRequestExtensionsData(const base::ListValue* args); | 130 void HandleRequestExtensionsData(const base::ListValue* args); |
| 126 | 131 |
| 127 // Callback for "toggleDeveloperMode" message. | 132 // Callback for "toggleDeveloperMode" message. |
| 128 void HandleToggleDeveloperMode(const base::ListValue* args); | 133 void HandleToggleDeveloperMode(const base::ListValue* args); |
| 129 | 134 |
| 130 // Callback for "inspect" message. | 135 // Callback for "inspect" message. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 content::NotificationRegistrar registrar_; | 234 content::NotificationRegistrar registrar_; |
| 230 | 235 |
| 231 PrefChangeRegistrar pref_registrar_; | 236 PrefChangeRegistrar pref_registrar_; |
| 232 PrefChangeRegistrar local_state_pref_registrar_; | 237 PrefChangeRegistrar local_state_pref_registrar_; |
| 233 | 238 |
| 234 // This will not be empty when a requirements check is in progress. Doing | 239 // This will not be empty when a requirements check is in progress. Doing |
| 235 // another Check() before the previous one is complete will cause the first | 240 // another Check() before the previous one is complete will cause the first |
| 236 // one to abort. | 241 // one to abort. |
| 237 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; | 242 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; |
| 238 | 243 |
| 244 ScopedObserver<extensions::ExtensionWarningService, | |
|
Evan Stade
2012/11/14 21:50:15
I did not even know this existed. That is cool.
| |
| 245 extensions::ExtensionWarningService::Observer> | |
| 246 warning_service_observer_; | |
| 247 | |
| 239 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 248 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
| 240 }; | 249 }; |
| 241 | 250 |
| 242 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 251 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |