| 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 "chrome/browser/api/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/api/prefs/pref_change_registrar.h" |
| 14 #include "chrome/browser/extensions/extension_install_ui.h" | 14 #include "chrome/browser/extensions/extension_install_ui.h" |
| 15 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 15 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 16 #include "chrome/browser/extensions/extension_warning_set.h" | 16 #include "chrome/browser/extensions/extension_warning_set.h" |
| 17 #include "chrome/browser/extensions/requirements_checker.h" |
| 17 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 21 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "content/public/browser/web_ui_message_handler.h" | 24 #include "content/public/browser/web_ui_message_handler.h" |
| 24 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 25 #include "ui/base/dialogs/select_file_dialog.h" | 26 #include "ui/base/dialogs/select_file_dialog.h" |
| 26 | 27 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 render_process_id(render_process_id), | 49 render_process_id(render_process_id), |
| 49 render_view_id(render_view_id), | 50 render_view_id(render_view_id), |
| 50 incognito(incognito) {} | 51 incognito(incognito) {} |
| 51 GURL url; | 52 GURL url; |
| 52 int render_process_id; | 53 int render_process_id; |
| 53 int render_view_id; | 54 int render_view_id; |
| 54 bool incognito; | 55 bool incognito; |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 // Extension Settings UI handler. | 58 // Extension Settings UI handler. |
| 58 class ExtensionSettingsHandler : public content::WebUIMessageHandler, | 59 class ExtensionSettingsHandler |
| 59 public content::NotificationObserver, | 60 : public content::WebUIMessageHandler, |
| 60 public content::WebContentsObserver, | 61 public content::NotificationObserver, |
| 61 public ui::SelectFileDialog::Listener, | 62 public content::WebContentsObserver, |
| 62 public ExtensionUninstallDialog::Delegate { | 63 public ui::SelectFileDialog::Listener, |
| 64 public ExtensionUninstallDialog::Delegate, |
| 65 public base::SupportsWeakPtr<ExtensionSettingsHandler>{ |
| 63 public: | 66 public: |
| 64 ExtensionSettingsHandler(); | 67 ExtensionSettingsHandler(); |
| 65 virtual ~ExtensionSettingsHandler(); | 68 virtual ~ExtensionSettingsHandler(); |
| 66 | 69 |
| 67 static void RegisterUserPrefs(PrefService* prefs); | 70 static void RegisterUserPrefs(PrefService* prefs); |
| 68 | 71 |
| 69 // Extension Detail JSON Struct for page. |pages| is injected for unit | 72 // Extension Detail JSON Struct for page. |pages| is injected for unit |
| 70 // testing. | 73 // testing. |
| 71 // Note: |warning_set| can be NULL in unit tests. | 74 // Note: |warning_set| can be NULL in unit tests. |
| 72 base::DictionaryValue* CreateExtensionDetailValue( | 75 base::DictionaryValue* CreateExtensionDetailValue( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 const std::set<content::RenderViewHost*>& views, | 171 const std::set<content::RenderViewHost*>& views, |
| 169 std::vector<ExtensionPage> *result); | 172 std::vector<ExtensionPage> *result); |
| 170 | 173 |
| 171 // Returns the ExtensionUninstallDialog object for this class, creating it if | 174 // Returns the ExtensionUninstallDialog object for this class, creating it if |
| 172 // needed. | 175 // needed. |
| 173 ExtensionUninstallDialog* GetExtensionUninstallDialog(); | 176 ExtensionUninstallDialog* GetExtensionUninstallDialog(); |
| 174 | 177 |
| 175 // Helper to inspect an ExtensionHost after it has been loaded. | 178 // Helper to inspect an ExtensionHost after it has been loaded. |
| 176 void InspectExtensionHost(extensions::ExtensionHost* host); | 179 void InspectExtensionHost(extensions::ExtensionHost* host); |
| 177 | 180 |
| 181 // Callback for RequirementsChecker. |
| 182 void OnRequirementsChecked(std::string extension_id, |
| 183 std::vector<std::string> requirement_errors); |
| 184 |
| 178 // Our model. Outlives us since it's owned by our containing profile. | 185 // Our model. Outlives us since it's owned by our containing profile. |
| 179 ExtensionService* extension_service_; | 186 ExtensionService* extension_service_; |
| 180 | 187 |
| 181 // A convenience member, filled once the extension_service_ is known. | 188 // A convenience member, filled once the extension_service_ is known. |
| 182 extensions::ManagementPolicy* management_policy_; | 189 extensions::ManagementPolicy* management_policy_; |
| 183 | 190 |
| 184 // Used to pick the directory when loading an extension. | 191 // Used to pick the directory when loading an extension. |
| 185 scoped_refptr<ui::SelectFileDialog> load_extension_dialog_; | 192 scoped_refptr<ui::SelectFileDialog> load_extension_dialog_; |
| 186 | 193 |
| 187 // Used to start the |load_extension_dialog_| in the last directory that was | 194 // Used to start the |load_extension_dialog_| in the last directory that was |
| (...skipping 22 matching lines...) Expand all Loading... |
| 210 // once to the page, otherwise we'd be calling JavaScript functions on objects | 217 // once to the page, otherwise we'd be calling JavaScript functions on objects |
| 211 // that don't exist yet when notifications come in. This variable makes sure | 218 // that don't exist yet when notifications come in. This variable makes sure |
| 212 // we do so only once. | 219 // we do so only once. |
| 213 bool registered_for_notifications_; | 220 bool registered_for_notifications_; |
| 214 | 221 |
| 215 content::NotificationRegistrar registrar_; | 222 content::NotificationRegistrar registrar_; |
| 216 | 223 |
| 217 PrefChangeRegistrar pref_registrar_; | 224 PrefChangeRegistrar pref_registrar_; |
| 218 PrefChangeRegistrar local_state_pref_registrar_; | 225 PrefChangeRegistrar local_state_pref_registrar_; |
| 219 | 226 |
| 227 // This will not be empty when a requirements check is in progress. Doing |
| 228 // another Check() before the previous one is complete will cause the first |
| 229 // one to abort. |
| 230 scoped_ptr<extensions::RequirementsChecker> requirements_checker_; |
| 231 |
| 220 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 232 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
| 221 }; | 233 }; |
| 222 | 234 |
| 223 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 235 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |