| 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 "chrome/browser/extensions/extension_install_ui.h" | 12 #include "chrome/browser/extensions/extension_install_ui.h" |
| 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 13 #include "chrome/browser/extensions/extension_uninstall_ui.h" |
| 14 #include "chrome/browser/ui/shell_dialogs.h" | 14 #include "chrome/browser/ui/shell_dialogs.h" |
| 15 #include "chrome/browser/ui/webui/options/options_ui.h" | 15 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 16 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 16 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 17 #include "chrome/common/extensions/extension_resource.h" | 17 #include "chrome/common/extensions/extension_resource.h" |
| 18 #include "content/common/notification_observer.h" | 18 #include "content/common/notification_observer.h" |
| 19 #include "content/common/notification_registrar.h" | 19 #include "content/common/notification_registrar.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 | 21 |
| 22 class Extension; | 22 class Extension; |
| 23 class ExtensionService; | 23 class ExtensionService; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 incognito(incognito) {} | 42 incognito(incognito) {} |
| 43 GURL url; | 43 GURL url; |
| 44 int render_process_id; | 44 int render_process_id; |
| 45 int render_view_id; | 45 int render_view_id; |
| 46 bool incognito; | 46 bool incognito; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // Extension Settings UI handler. | 49 // Extension Settings UI handler. |
| 50 class ExtensionSettingsHandler : public OptionsPageUIHandler, | 50 class ExtensionSettingsHandler : public OptionsPageUIHandler, |
| 51 public SelectFileDialog::Listener, | 51 public SelectFileDialog::Listener, |
| 52 public ExtensionUninstallDialog::Delegate { | 52 public ExtensionUninstallUI::Delegate { |
| 53 public: | 53 public: |
| 54 ExtensionSettingsHandler(); | 54 ExtensionSettingsHandler(); |
| 55 virtual ~ExtensionSettingsHandler(); | 55 virtual ~ExtensionSettingsHandler(); |
| 56 | 56 |
| 57 // Extension Detail JSON Struct for page. (static for ease of testing). | 57 // Extension Detail JSON Struct for page. (static for ease of testing). |
| 58 // Note: service can be NULL in unit tests. | 58 // Note: service can be NULL in unit tests. |
| 59 static base::DictionaryValue* CreateExtensionDetailValue( | 59 static base::DictionaryValue* CreateExtensionDetailValue( |
| 60 ExtensionService* service, | 60 ExtensionService* service, |
| 61 const Extension* extension, | 61 const Extension* extension, |
| 62 const std::vector<ExtensionPage>& pages, | 62 const std::vector<ExtensionPage>& pages, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // OptionsUIHandler implementation. | 136 // OptionsUIHandler implementation. |
| 137 virtual void GetLocalizedValues( | 137 virtual void GetLocalizedValues( |
| 138 base::DictionaryValue* localized_strings) OVERRIDE; | 138 base::DictionaryValue* localized_strings) OVERRIDE; |
| 139 virtual void Initialize() OVERRIDE; | 139 virtual void Initialize() OVERRIDE; |
| 140 | 140 |
| 141 // NotificationObserver implementation. | 141 // NotificationObserver implementation. |
| 142 virtual void Observe(int type, | 142 virtual void Observe(int type, |
| 143 const NotificationSource& source, | 143 const NotificationSource& source, |
| 144 const NotificationDetails& details) OVERRIDE; | 144 const NotificationDetails& details) OVERRIDE; |
| 145 | 145 |
| 146 // ExtensionUninstallDialog::Delegate implementation, used for receiving | 146 // ExtensionUninstallUI::Delegate implementation, used for receiving |
| 147 // notification about uninstall confirmation dialog selections. | 147 // notification about uninstall confirmation dialog selections. |
| 148 virtual void ExtensionDialogAccepted() OVERRIDE; | 148 virtual void ExtensionUninstallAccepted() OVERRIDE; |
| 149 virtual void ExtensionDialogCanceled() OVERRIDE; | 149 virtual void ExtensionUninstallCanceled() OVERRIDE; |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 // Helper that lists the current active html pages for an extension. | 152 // Helper that lists the current active html pages for an extension. |
| 153 std::vector<ExtensionPage> GetActivePagesForExtension( | 153 std::vector<ExtensionPage> GetActivePagesForExtension( |
| 154 const Extension* extension); | 154 const Extension* extension); |
| 155 void GetActivePagesForExtensionProcess( | 155 void GetActivePagesForExtensionProcess( |
| 156 RenderProcessHost* process, | 156 RenderProcessHost* process, |
| 157 const Extension* extension, | 157 const Extension* extension, |
| 158 std::vector<ExtensionPage> *result); | 158 std::vector<ExtensionPage> *result); |
| 159 | 159 |
| 160 // Returns the ExtensionUninstallDialog object for this class, creating it if | 160 // Returns the ExtensionUninstallUI object for this class, creating it if |
| 161 // needed. | 161 // needed. |
| 162 ExtensionUninstallDialog* GetExtensionUninstallDialog(); | 162 ExtensionUninstallUI* GetExtensionUninstallUI(); |
| 163 | 163 |
| 164 // Our model. Outlives us since it's owned by our containing profile. | 164 // Our model. Outlives us since it's owned by our containing profile. |
| 165 ExtensionService* extension_service_; | 165 ExtensionService* extension_service_; |
| 166 | 166 |
| 167 // Used to pick the directory when loading an extension. | 167 // Used to pick the directory when loading an extension. |
| 168 scoped_refptr<SelectFileDialog> load_extension_dialog_; | 168 scoped_refptr<SelectFileDialog> load_extension_dialog_; |
| 169 | 169 |
| 170 // Used to show confirmation UI for uninstalling extensions in incognito mode. | 170 // Used to show confirmation UI for uninstalling extensions in incognito mode. |
| 171 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 171 scoped_ptr<ExtensionUninstallUI> extension_uninstall_ui_; |
| 172 | 172 |
| 173 // The id of the extension we are prompting the user about. | 173 // The id of the extension we are prompting the user about. |
| 174 std::string extension_id_prompting_; | 174 std::string extension_id_prompting_; |
| 175 | 175 |
| 176 // If true, we will ignore notifications in ::Observe(). This is needed | 176 // If true, we will ignore notifications in ::Observe(). This is needed |
| 177 // to prevent reloading the page when we were the cause of the | 177 // to prevent reloading the page when we were the cause of the |
| 178 // notification. | 178 // notification. |
| 179 bool ignore_notifications_; | 179 bool ignore_notifications_; |
| 180 | 180 |
| 181 // The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED, | 181 // The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED, |
| 182 // but the iteration over RenderViewHosts will include the host because the | 182 // but the iteration over RenderViewHosts will include the host because the |
| 183 // notification is sent when it is in the process of being deleted (and before | 183 // notification is sent when it is in the process of being deleted (and before |
| 184 // it is removed from the process). Keep a pointer to it so we can exclude | 184 // it is removed from the process). Keep a pointer to it so we can exclude |
| 185 // it from the active views. | 185 // it from the active views. |
| 186 RenderViewHost* deleting_rvh_; | 186 RenderViewHost* deleting_rvh_; |
| 187 | 187 |
| 188 // We want to register for notifications only after we've responded at least | 188 // We want to register for notifications only after we've responded at least |
| 189 // once to the page, otherwise we'd be calling javacsript functions on objects | 189 // once to the page, otherwise we'd be calling javacsript functions on objects |
| 190 // that don't exist yet when notifications come in. This variable makes sure | 190 // that don't exist yet when notifications come in. This variable makes sure |
| 191 // we do so only once. | 191 // we do so only once. |
| 192 bool registered_for_notifications_; | 192 bool registered_for_notifications_; |
| 193 | 193 |
| 194 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 194 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 197 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |