| 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/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "chrome/browser/extensions/api/developer_private/inspectable_views_find
er.h" |
| 14 #include "chrome/browser/extensions/error_console/error_console.h" | 15 #include "chrome/browser/extensions/error_console/error_console.h" |
| 15 #include "chrome/browser/extensions/extension_install_prompt.h" | 16 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 16 #include "chrome/browser/extensions/extension_management.h" | 17 #include "chrome/browser/extensions/extension_management.h" |
| 17 #include "chrome/common/extensions/webstore_install_result.h" | 18 #include "chrome/common/extensions/webstore_install_result.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/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 22 #include "content/public/browser/web_ui_message_handler.h" | 23 #include "content/public/browser/web_ui_message_handler.h" |
| 23 #include "extensions/browser/extension_prefs.h" | 24 #include "extensions/browser/extension_prefs.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 | 41 |
| 41 namespace user_prefs { | 42 namespace user_prefs { |
| 42 class PrefRegistrySyncable; | 43 class PrefRegistrySyncable; |
| 43 } | 44 } |
| 44 | 45 |
| 45 namespace extensions { | 46 namespace extensions { |
| 46 class Extension; | 47 class Extension; |
| 47 class ExtensionRegistry; | 48 class ExtensionRegistry; |
| 48 class ManagementPolicy; | 49 class ManagementPolicy; |
| 49 | 50 |
| 50 // Information about a page running in an extension, for example a popup bubble, | |
| 51 // a background page, or a tab contents. | |
| 52 struct ExtensionPage { | |
| 53 ExtensionPage(const GURL& url, | |
| 54 int render_process_id, | |
| 55 int render_view_id, | |
| 56 bool incognito, | |
| 57 bool generated_background_page); | |
| 58 GURL url; | |
| 59 int render_process_id; | |
| 60 int render_view_id; | |
| 61 bool incognito; | |
| 62 bool generated_background_page; | |
| 63 }; | |
| 64 | |
| 65 // Extension Settings UI handler. | 51 // Extension Settings UI handler. |
| 66 class ExtensionSettingsHandler | 52 class ExtensionSettingsHandler |
| 67 : public content::WebUIMessageHandler, | 53 : public content::WebUIMessageHandler, |
| 68 public content::NotificationObserver, | 54 public content::NotificationObserver, |
| 69 public content::WebContentsObserver, | 55 public content::WebContentsObserver, |
| 70 public ErrorConsole::Observer, | 56 public ErrorConsole::Observer, |
| 71 public ExtensionInstallPrompt::Delegate, | 57 public ExtensionInstallPrompt::Delegate, |
| 72 public ExtensionManagement::Observer, | 58 public ExtensionManagement::Observer, |
| 73 public ExtensionPrefsObserver, | 59 public ExtensionPrefsObserver, |
| 74 public ExtensionRegistryObserver, | 60 public ExtensionRegistryObserver, |
| 75 public WarningService::Observer, | 61 public WarningService::Observer, |
| 76 public base::SupportsWeakPtr<ExtensionSettingsHandler> { | 62 public base::SupportsWeakPtr<ExtensionSettingsHandler> { |
| 77 public: | 63 public: |
| 78 ExtensionSettingsHandler(); | 64 ExtensionSettingsHandler(); |
| 79 ~ExtensionSettingsHandler() override; | 65 ~ExtensionSettingsHandler() override; |
| 80 | 66 |
| 81 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 67 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 82 | 68 |
| 83 // Extension Detail JSON Struct for page. |pages| is injected for unit | 69 // Extension Detail JSON Struct for page. |pages| is injected for unit |
| 84 // testing. | 70 // testing. |
| 85 // Note: |warning_service| can be NULL in unit tests. | 71 // Note: |warning_service| can be NULL in unit tests. |
| 86 base::DictionaryValue* CreateExtensionDetailValue( | 72 base::DictionaryValue* CreateExtensionDetailValue( |
| 87 const Extension* extension, | 73 const Extension* extension, |
| 88 const std::vector<ExtensionPage>& pages, | 74 const InspectableViewsFinder::ViewList& pages, |
| 89 const WarningService* warning_service); | 75 const WarningService* warning_service); |
| 90 | 76 |
| 91 void GetLocalizedValues(content::WebUIDataSource* source); | 77 void GetLocalizedValues(content::WebUIDataSource* source); |
| 92 | 78 |
| 93 private: | 79 private: |
| 94 friend class ExtensionUITest; | 80 friend class ExtensionUITest; |
| 95 friend class BrokerDelegate; | 81 friend class BrokerDelegate; |
| 96 | 82 |
| 97 // content::WebContentsObserver implementation. | 83 // content::WebContentsObserver implementation. |
| 98 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | 84 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Utility for callbacks that get an extension ID as the sole argument. | 176 // Utility for callbacks that get an extension ID as the sole argument. |
| 191 // Returns NULL if the extension isn't active. | 177 // Returns NULL if the extension isn't active. |
| 192 const Extension* GetActiveExtension(const base::ListValue* args); | 178 const Extension* GetActiveExtension(const base::ListValue* args); |
| 193 | 179 |
| 194 // Forces a UI update if appropriate after a notification is received. | 180 // Forces a UI update if appropriate after a notification is received. |
| 195 void MaybeUpdateAfterNotification(); | 181 void MaybeUpdateAfterNotification(); |
| 196 | 182 |
| 197 // Register for notifications that we need to reload the page. | 183 // Register for notifications that we need to reload the page. |
| 198 void MaybeRegisterForNotifications(); | 184 void MaybeRegisterForNotifications(); |
| 199 | 185 |
| 200 // Helper that lists the current inspectable html pages for an extension. | |
| 201 std::vector<ExtensionPage> GetInspectablePagesForExtension( | |
| 202 const Extension* extension, bool extension_is_enabled); | |
| 203 void GetInspectablePagesForExtensionProcess( | |
| 204 const Extension* extension, | |
| 205 const std::set<content::RenderViewHost*>& views, | |
| 206 std::vector<ExtensionPage>* result); | |
| 207 void GetAppWindowPagesForExtensionProfile(const Extension* extension, | |
| 208 Profile* profile, | |
| 209 std::vector<ExtensionPage>* result); | |
| 210 | |
| 211 // Called when the reinstallation is complete. | 186 // Called when the reinstallation is complete. |
| 212 void OnReinstallComplete(bool success, | 187 void OnReinstallComplete(bool success, |
| 213 const std::string& error, | 188 const std::string& error, |
| 214 webstore_install::Result result); | 189 webstore_install::Result result); |
| 215 | 190 |
| 216 // Handles the load retry notification sent from | 191 // Handles the load retry notification sent from |
| 217 // ExtensionService::ReportExtensionLoadError. Attempts to retry loading | 192 // ExtensionService::ReportExtensionLoadError. Attempts to retry loading |
| 218 // extension from |path| if retry is true, otherwise removes |path| from the | 193 // extension from |path| if retry is true, otherwise removes |path| from the |
| 219 // vector of currently loading extensions. | 194 // vector of currently loading extensions. |
| 220 // | 195 // |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off | 252 // Whether we found any DISABLE_NOT_VERIFIED extensions and want to kick off |
| 278 // a verification check to try and rescue them. | 253 // a verification check to try and rescue them. |
| 279 bool should_do_verification_check_; | 254 bool should_do_verification_check_; |
| 280 | 255 |
| 281 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 256 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
| 282 }; | 257 }; |
| 283 | 258 |
| 284 } // namespace extensions | 259 } // namespace extensions |
| 285 | 260 |
| 286 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 261 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
| OLD | NEW |