| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/extensions/extension_install_ui.h" | 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 14 #include "chrome/browser/extensions/pack_extension_job.h" | 14 #include "chrome/browser/extensions/pack_extension_job.h" |
| 15 #include "chrome/browser/ui/shell_dialogs.h" | 15 #include "chrome/browser/ui/shell_dialogs.h" |
| 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 17 #include "chrome/common/extensions/extension_resource.h" | 17 #include "chrome/common/extensions/extension_resource.h" |
| 18 #include "content/browser/webui/web_ui.h" | 18 #include "content/browser/webui/web_ui.h" |
| 19 #include "content/common/notification_observer.h" | 19 #include "content/common/notification_observer.h" |
| 20 #include "content/common/notification_registrar.h" | 20 #include "content/common/notification_registrar.h" |
| 21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 22 | 22 |
| 23 class DictionaryValue; | 23 class DictionaryValue; |
| 24 class Extension; | 24 class Extension; |
| 25 class ExtensionService; | 25 class ExtensionService; |
| 26 class FilePath; | 26 class FilePath; |
| 27 class ListValue; | 27 class ListValue; |
| 28 class PrefService; | 28 class PrefService; |
| 29 class RenderProcessHost; | 29 class RenderProcessHost; |
| 30 class UserScript; | 30 class UserScript; |
| 31 | 31 |
| 32 // Information about a page running in an extension, for example a toolstrip, | 32 // Information about a page running in an extension, for example a toolstrip, |
| 33 // a background page, or a tab contents. | 33 // a background page, or a tab contents. |
| 34 struct ExtensionPage { | 34 struct ExtensionPage { |
| 35 ExtensionPage(const GURL& url, int render_process_id, int render_view_id, | 35 ExtensionPage(const GURL& url, int render_process_id, int render_view_id, |
| 36 bool incognito) | 36 bool incognito) |
| 37 : url(url), render_process_id(render_process_id), | 37 : url(url), |
| 38 render_view_id(render_view_id), incognito(incognito) {} | 38 render_process_id(render_process_id), |
| 39 render_view_id(render_view_id), |
| 40 incognito(incognito) {} |
| 39 GURL url; | 41 GURL url; |
| 40 int render_process_id; | 42 int render_process_id; |
| 41 int render_view_id; | 43 int render_view_id; |
| 42 bool incognito; | 44 bool incognito; |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 class ExtensionsUIHTMLSource : public ChromeURLDataManager::DataSource { | 47 class ExtensionsUIHTMLSource : public ChromeURLDataManager::DataSource { |
| 46 public: | 48 public: |
| 47 ExtensionsUIHTMLSource(); | 49 ExtensionsUIHTMLSource(); |
| 48 | 50 |
| 49 // Called when the network layer has requested a resource underneath | 51 // Called when the network layer has requested a resource underneath |
| 50 // the path we registered. | 52 // the path we registered. |
| 51 virtual void StartDataRequest(const std::string& path, | 53 virtual void StartDataRequest(const std::string& path, |
| 52 bool is_off_the_record, | 54 bool is_off_the_record, |
| 53 int request_id); | 55 int request_id); |
| 54 virtual std::string GetMimeType(const std::string&) const; | 56 virtual std::string GetMimeType(const std::string&) const; |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 ~ExtensionsUIHTMLSource() {} | 59 ~ExtensionsUIHTMLSource() {} |
| 58 | 60 |
| 59 DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource); | 61 DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource); |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 // The handler for JavaScript messages related to the "extensions" view. | 64 // The handler for JavaScript messages related to the "extensions" view. |
| 63 class ExtensionsDOMHandler | 65 class ExtensionsDOMHandler : public WebUIMessageHandler, |
| 64 : public WebUIMessageHandler, | 66 public NotificationObserver, |
| 65 public NotificationObserver, | 67 public PackExtensionJob::Client, |
| 66 public PackExtensionJob::Client, | 68 public SelectFileDialog::Listener, |
| 67 public SelectFileDialog::Listener, | 69 public ExtensionUninstallDialog::Delegate { |
| 68 public ExtensionInstallUI::Delegate { | |
| 69 public: | 70 public: |
| 70 | 71 |
| 71 // Helper class that loads the icons for the extensions in the management UI. | 72 // Helper class that loads the icons for the extensions in the management UI. |
| 72 // We do this with native code instead of just using chrome-extension:// URLs | 73 // We do this with native code instead of just using chrome-extension:// URLs |
| 73 // for two reasons: | 74 // for two reasons: |
| 74 // | 75 // |
| 75 // 1. We need to support the disabled extensions, too, and using URLs won't | 76 // 1. We need to support the disabled extensions, too, and using URLs won't |
| 76 // work for them. | 77 // work for them. |
| 77 // 2. We want to desaturate the icons of the disabled extensions to make them | 78 // 2. We want to desaturate the icons of the disabled extensions to make them |
| 78 // look disabled. | 79 // look disabled. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 static DictionaryValue* CreateContentScriptDetailValue( | 122 static DictionaryValue* CreateContentScriptDetailValue( |
| 122 const UserScript& script, | 123 const UserScript& script, |
| 123 const FilePath& extension_path); | 124 const FilePath& extension_path); |
| 124 | 125 |
| 125 // ExtensionPackJob::Client | 126 // ExtensionPackJob::Client |
| 126 virtual void OnPackSuccess(const FilePath& crx_file, | 127 virtual void OnPackSuccess(const FilePath& crx_file, |
| 127 const FilePath& key_file); | 128 const FilePath& key_file); |
| 128 | 129 |
| 129 virtual void OnPackFailure(const std::string& error); | 130 virtual void OnPackFailure(const std::string& error); |
| 130 | 131 |
| 131 // ExtensionInstallUI::Delegate implementation, used for receiving | 132 // ExtensionUninstallDialog::Delegate: |
| 132 // notification about uninstall confirmation dialog selections. | 133 virtual void ExtensionDialogAccepted(); |
| 133 virtual void InstallUIProceed(); | 134 virtual void ExtensionDialogCanceled(); |
| 134 virtual void InstallUIAbort(); | |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 // Callback for "requestExtensionsData" message. | 137 // Callback for "requestExtensionsData" message. |
| 138 void HandleRequestExtensionsData(const ListValue* args); | 138 void HandleRequestExtensionsData(const ListValue* args); |
| 139 | 139 |
| 140 // Callback for "toggleDeveloperMode" message. | 140 // Callback for "toggleDeveloperMode" message. |
| 141 void HandleToggleDeveloperMode(const ListValue* args); | 141 void HandleToggleDeveloperMode(const ListValue* args); |
| 142 | 142 |
| 143 // Callback for "inspect" message. | 143 // Callback for "inspect" message. |
| 144 void HandleInspectMessage(const ListValue* args); | 144 void HandleInspectMessage(const ListValue* args); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Loads the extension resources into the json data, then calls OnIconsLoaded. | 212 // Loads the extension resources into the json data, then calls OnIconsLoaded. |
| 213 // Takes ownership of |icons|. | 213 // Takes ownership of |icons|. |
| 214 // Called on the file thread. | 214 // Called on the file thread. |
| 215 void LoadExtensionIcons(std::vector<ExtensionResource>* icons, | 215 void LoadExtensionIcons(std::vector<ExtensionResource>* icons, |
| 216 DictionaryValue* json_data); | 216 DictionaryValue* json_data); |
| 217 | 217 |
| 218 // Takes ownership of |json_data| and tells HTML about it. | 218 // Takes ownership of |json_data| and tells HTML about it. |
| 219 // Called on the UI thread. | 219 // Called on the UI thread. |
| 220 void OnIconsLoaded(DictionaryValue* json_data); | 220 void OnIconsLoaded(DictionaryValue* json_data); |
| 221 | 221 |
| 222 // Returns the ExtensionInstallUI object for this class, creating it if | 222 // Returns the ExtensionUninstallDialog object for this class, creating it if |
| 223 // needed. | 223 // needed. |
| 224 ExtensionInstallUI* GetExtensionInstallUI(); | 224 ExtensionUninstallDialog* GetExtensionUninstallDialog(); |
| 225 | 225 |
| 226 // Our model. | 226 // Our model. |
| 227 scoped_refptr<ExtensionService> extensions_service_; | 227 scoped_refptr<ExtensionService> extensions_service_; |
| 228 | 228 |
| 229 // Used to pick the directory when loading an extension. | 229 // Used to pick the directory when loading an extension. |
| 230 scoped_refptr<SelectFileDialog> load_extension_dialog_; | 230 scoped_refptr<SelectFileDialog> load_extension_dialog_; |
| 231 | 231 |
| 232 // Used to package the extension. | 232 // Used to package the extension. |
| 233 scoped_refptr<PackExtensionJob> pack_job_; | 233 scoped_refptr<PackExtensionJob> pack_job_; |
| 234 | 234 |
| 235 // Used to load icons asynchronously on the file thread. | 235 // Used to load icons asynchronously on the file thread. |
| 236 scoped_refptr<IconLoader> icon_loader_; | 236 scoped_refptr<IconLoader> icon_loader_; |
| 237 | 237 |
| 238 // Used to show confirmation UI for uninstalling/enabling extensions in | 238 // Used to show confirmation UI for uninstalling extensions in incognito mode. |
| 239 // incognito mode. | 239 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
| 240 scoped_ptr<ExtensionInstallUI> install_ui_; | |
| 241 | 240 |
| 242 // The id of the extension we are prompting the user about. | 241 // The id of the extension we are prompting the user about. |
| 243 std::string extension_id_prompting_; | 242 std::string extension_id_prompting_; |
| 244 | 243 |
| 245 // We monitor changes to the extension system so that we can reload when | 244 // We monitor changes to the extension system so that we can reload when |
| 246 // necessary. | 245 // necessary. |
| 247 NotificationRegistrar registrar_; | 246 NotificationRegistrar registrar_; |
| 248 | 247 |
| 249 // If true, we will ignore notifications in ::Observe(). This is needed | 248 // If true, we will ignore notifications in ::Observe(). This is needed |
| 250 // to prevent reloading the page when we were the cause of the | 249 // to prevent reloading the page when we were the cause of the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 267 | 266 |
| 268 static RefCountedMemory* GetFaviconResourceBytes(); | 267 static RefCountedMemory* GetFaviconResourceBytes(); |
| 269 | 268 |
| 270 static void RegisterUserPrefs(PrefService* prefs); | 269 static void RegisterUserPrefs(PrefService* prefs); |
| 271 | 270 |
| 272 private: | 271 private: |
| 273 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); | 272 DISALLOW_COPY_AND_ASSIGN(ExtensionsUI); |
| 274 }; | 273 }; |
| 275 | 274 |
| 276 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 275 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |