| 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/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
| 15 #include "chrome/browser/extensions/error_console/error_console.h" | 15 #include "chrome/browser/extensions/error_console/error_console.h" |
| 16 #include "chrome/browser/extensions/extension_install_prompt.h" | 16 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 17 #include "chrome/browser/extensions/extension_install_ui.h" | 17 #include "chrome/browser/extensions/extension_install_ui.h" |
| 18 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 18 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 19 #include "chrome/browser/extensions/extension_warning_service.h" | 19 #include "chrome/browser/extensions/extension_warning_service.h" |
| 20 #include "chrome/browser/extensions/requirements_checker.h" | 20 #include "chrome/browser/extensions/requirements_checker.h" |
| 21 #include "content/public/browser/navigation_controller.h" | 21 #include "content/public/browser/navigation_controller.h" |
| 22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
| 25 #include "content/public/browser/web_ui_message_handler.h" | 25 #include "content/public/browser/web_ui_message_handler.h" |
| 26 #include "extensions/browser/extension_prefs.h" | 26 #include "extensions/browser/extension_prefs.h" |
| 27 #include "extensions/browser/extension_prefs_observer.h" | 27 #include "extensions/browser/extension_prefs_observer.h" |
| 28 #include "ui/shell_dialogs/select_file_dialog.h" | |
| 29 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 30 | 29 |
| 31 class ExtensionService; | 30 class ExtensionService; |
| 32 | 31 |
| 33 namespace base { | 32 namespace base { |
| 34 class DictionaryValue; | 33 class DictionaryValue; |
| 35 class FilePath; | 34 class FilePath; |
| 36 class ListValue; | 35 class ListValue; |
| 37 } | 36 } |
| 38 | 37 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 61 int render_view_id; | 60 int render_view_id; |
| 62 bool incognito; | 61 bool incognito; |
| 63 bool generated_background_page; | 62 bool generated_background_page; |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 // Extension Settings UI handler. | 65 // Extension Settings UI handler. |
| 67 class ExtensionSettingsHandler | 66 class ExtensionSettingsHandler |
| 68 : public content::WebUIMessageHandler, | 67 : public content::WebUIMessageHandler, |
| 69 public content::NotificationObserver, | 68 public content::NotificationObserver, |
| 70 public content::WebContentsObserver, | 69 public content::WebContentsObserver, |
| 71 public ui::SelectFileDialog::Listener, | |
| 72 public ErrorConsole::Observer, | 70 public ErrorConsole::Observer, |
| 73 public ExtensionInstallPrompt::Delegate, | 71 public ExtensionInstallPrompt::Delegate, |
| 74 public ExtensionPrefsObserver, | 72 public ExtensionPrefsObserver, |
| 75 public ExtensionUninstallDialog::Delegate, | 73 public ExtensionUninstallDialog::Delegate, |
| 76 public ExtensionWarningService::Observer, | 74 public ExtensionWarningService::Observer, |
| 77 public base::SupportsWeakPtr<ExtensionSettingsHandler> { | 75 public base::SupportsWeakPtr<ExtensionSettingsHandler> { |
| 78 public: | 76 public: |
| 79 ExtensionSettingsHandler(); | 77 ExtensionSettingsHandler(); |
| 80 virtual ~ExtensionSettingsHandler(); | 78 virtual ~ExtensionSettingsHandler(); |
| 81 | 79 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 102 const GURL& url, | 100 const GURL& url, |
| 103 content::NavigationController::ReloadType reload_type) OVERRIDE; | 101 content::NavigationController::ReloadType reload_type) OVERRIDE; |
| 104 | 102 |
| 105 // Allows injection for testing by friend classes. | 103 // Allows injection for testing by friend classes. |
| 106 ExtensionSettingsHandler(ExtensionService* service, | 104 ExtensionSettingsHandler(ExtensionService* service, |
| 107 ManagementPolicy* policy); | 105 ManagementPolicy* policy); |
| 108 | 106 |
| 109 // WebUIMessageHandler implementation. | 107 // WebUIMessageHandler implementation. |
| 110 virtual void RegisterMessages() OVERRIDE; | 108 virtual void RegisterMessages() OVERRIDE; |
| 111 | 109 |
| 112 // Loads an unpacked extension from |path|. | |
| 113 void LoadUnpackedExtension(const base::FilePath& path); | |
| 114 | |
| 115 // Returns the index of the given FilePath in the vector of currently loading | |
| 116 // extensions. Returns -1 if not found. | |
| 117 int IndexOfLoadingPath(const base::FilePath& path); | |
| 118 | |
| 119 // Adds |path| to the vector of currently loading extensions. Registers | |
| 120 // for the load retry notification if vector is empty before call. | |
| 121 void AddLoadingPath(const base::FilePath& path); | |
| 122 | |
| 123 // Removes |path| from the vector of currently loading extensions. Unregisters | |
| 124 // for the load retry notification if vector is empty after call. | |
| 125 void RemoveLoadingPath(const base::FilePath& path); | |
| 126 | |
| 127 // SelectFileDialog::Listener implementation. | |
| 128 virtual void FileSelected(const base::FilePath& path, | |
| 129 int index, | |
| 130 void* params) OVERRIDE; | |
| 131 virtual void MultiFilesSelected( | |
| 132 const std::vector<base::FilePath>& files, void* params) OVERRIDE; | |
| 133 virtual void FileSelectionCanceled(void* params) OVERRIDE; | |
| 134 | |
| 135 // ErrorConsole::Observer implementation. | 110 // ErrorConsole::Observer implementation. |
| 136 virtual void OnErrorAdded(const ExtensionError* error) OVERRIDE; | 111 virtual void OnErrorAdded(const ExtensionError* error) OVERRIDE; |
| 137 | 112 |
| 138 // content::NotificationObserver implementation. | 113 // content::NotificationObserver implementation. |
| 139 virtual void Observe(int type, | 114 virtual void Observe(int type, |
| 140 const content::NotificationSource& source, | 115 const content::NotificationSource& source, |
| 141 const content::NotificationDetails& details) OVERRIDE; | 116 const content::NotificationDetails& details) OVERRIDE; |
| 142 | 117 |
| 143 // ExtensionPrefsObserver implementation. | 118 // ExtensionPrefsObserver implementation. |
| 144 virtual void OnExtensionDisableReasonsChanged(const std::string& extension_id, | 119 virtual void OnExtensionDisableReasonsChanged(const std::string& extension_id, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 169 |
| 195 // Callback for "permissions" message. | 170 // Callback for "permissions" message. |
| 196 void HandlePermissionsMessage(const base::ListValue* args); | 171 void HandlePermissionsMessage(const base::ListValue* args); |
| 197 | 172 |
| 198 // Callback for "showButton" message. | 173 // Callback for "showButton" message. |
| 199 void HandleShowButtonMessage(const base::ListValue* args); | 174 void HandleShowButtonMessage(const base::ListValue* args); |
| 200 | 175 |
| 201 // Callback for "autoupdate" message. | 176 // Callback for "autoupdate" message. |
| 202 void HandleAutoUpdateMessage(const base::ListValue* args); | 177 void HandleAutoUpdateMessage(const base::ListValue* args); |
| 203 | 178 |
| 204 // Callback for "loadUnpackedExtension" message. | |
| 205 void HandleLoadUnpackedExtensionMessage(const base::ListValue* args); | |
| 206 | |
| 207 // Callback for the "dismissADTPromo" message. | 179 // Callback for the "dismissADTPromo" message. |
| 208 void HandleDismissADTPromoMessage(const base::ListValue* args); | 180 void HandleDismissADTPromoMessage(const base::ListValue* args); |
| 209 | 181 |
| 210 // Utility for calling JavaScript window.alert in the page. | 182 // Utility for calling JavaScript window.alert in the page. |
| 211 void ShowAlert(const std::string& message); | 183 void ShowAlert(const std::string& message); |
| 212 | 184 |
| 213 // Utility for callbacks that get an extension ID as the sole argument. | 185 // Utility for callbacks that get an extension ID as the sole argument. |
| 214 // Returns NULL if the extension isn't active. | 186 // Returns NULL if the extension isn't active. |
| 215 const Extension* GetActiveExtension(const base::ListValue* args); | 187 const Extension* GetActiveExtension(const base::ListValue* args); |
| 216 | 188 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 247 // Does nothing if |path| is not a currently loading extension this object is | 219 // Does nothing if |path| is not a currently loading extension this object is |
| 248 // tracking. | 220 // tracking. |
| 249 void HandleLoadRetryMessage(bool retry, const base::FilePath& path); | 221 void HandleLoadRetryMessage(bool retry, const base::FilePath& path); |
| 250 | 222 |
| 251 // Our model. Outlives us since it's owned by our containing profile. | 223 // Our model. Outlives us since it's owned by our containing profile. |
| 252 ExtensionService* extension_service_; | 224 ExtensionService* extension_service_; |
| 253 | 225 |
| 254 // A convenience member, filled once the extension_service_ is known. | 226 // A convenience member, filled once the extension_service_ is known. |
| 255 ManagementPolicy* management_policy_; | 227 ManagementPolicy* management_policy_; |
| 256 | 228 |
| 257 // Used to pick the directory when loading an extension. | |
| 258 scoped_refptr<ui::SelectFileDialog> load_extension_dialog_; | |
| 259 | |
| 260 // Used to start the |load_extension_dialog_| in the last directory that was | |
| 261 // loaded. | |
| 262 base::FilePath last_unpacked_directory_; | |
| 263 | |
| 264 // Used to keep track of FilePaths for all extensions in the process of | |
| 265 // loading for the purpose of retrying on load failure. | |
| 266 std::vector<base::FilePath> loading_extension_directories_; | |
| 267 | |
| 268 // Used to show confirmation UI for uninstalling extensions in incognito mode. | 229 // Used to show confirmation UI for uninstalling extensions in incognito mode. |
| 269 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 230 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 270 | 231 |
| 271 // The id of the extension we are prompting the user about. | 232 // The id of the extension we are prompting the user about. |
| 272 std::string extension_id_prompting_; | 233 std::string extension_id_prompting_; |
| 273 | 234 |
| 274 // If true, we will ignore notifications in ::Observe(). This is needed | 235 // If true, we will ignore notifications in ::Observe(). This is needed |
| 275 // to prevent reloading the page when we were the cause of the | 236 // to prevent reloading the page when we were the cause of the |
| 276 // notification. | 237 // notification. |
| 277 bool ignore_notifications_; | 238 bool ignore_notifications_; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off | 279 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off |
| 319 // a verification check to try and rescue them. | 280 // a verification check to try and rescue them. |
| 320 bool should_do_verification_check_; | 281 bool should_do_verification_check_; |
| 321 | 282 |
| 322 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 283 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
| 323 }; | 284 }; |
| 324 | 285 |
| 325 } // namespace extensions | 286 } // namespace extensions |
| 326 | 287 |
| 327 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 288 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |