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 <string> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/scoped_observer.h" | |
12 #include "chrome/browser/extensions/extension_management.h" | |
13 #include "content/public/browser/navigation_controller.h" | 8 #include "content/public/browser/navigation_controller.h" |
14 #include "content/public/browser/web_contents_observer.h" | 9 #include "content/public/browser/web_contents_observer.h" |
15 #include "content/public/browser/web_ui_message_handler.h" | 10 #include "content/public/browser/web_ui_message_handler.h" |
16 #include "extensions/browser/extension_prefs_observer.h" | |
17 #include "extensions/browser/warning_service.h" | |
18 | 11 |
19 class ExtensionService; | 12 class ExtensionService; |
20 class GURL; | 13 class GURL; |
21 | 14 |
22 namespace base { | |
23 class FilePath; | |
24 class ListValue; | |
25 } | |
26 | |
27 namespace content { | 15 namespace content { |
28 class WebUIDataSource; | 16 class WebUIDataSource; |
29 } | 17 } |
30 | 18 |
31 namespace user_prefs { | 19 namespace user_prefs { |
32 class PrefRegistrySyncable; | 20 class PrefRegistrySyncable; |
33 } | 21 } |
34 | 22 |
35 namespace extensions { | 23 namespace extensions { |
36 class Extension; | |
37 class ExtensionPrefs; | |
38 | 24 |
39 // Extension Settings UI handler. | 25 // Extension Settings UI handler. |
40 class ExtensionSettingsHandler | 26 class ExtensionSettingsHandler : public content::WebUIMessageHandler, |
41 : public content::WebUIMessageHandler, | 27 public content::WebContentsObserver { |
42 public content::WebContentsObserver, | |
43 public ExtensionManagement::Observer, | |
44 public ExtensionPrefsObserver, | |
45 public WarningService::Observer, | |
46 public base::SupportsWeakPtr<ExtensionSettingsHandler> { | |
47 public: | 28 public: |
48 ExtensionSettingsHandler(); | 29 ExtensionSettingsHandler(); |
49 ~ExtensionSettingsHandler() override; | 30 ~ExtensionSettingsHandler() override; |
50 | 31 |
51 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 32 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
52 | 33 |
53 void GetLocalizedValues(content::WebUIDataSource* source); | 34 void GetLocalizedValues(content::WebUIDataSource* source); |
54 | 35 |
55 private: | 36 private: |
56 // content::WebContentsObserver implementation. | 37 // WebContentsObserver implementation. |
57 void RenderViewDeleted(content::RenderViewHost* render_view_host) override; | |
58 void DidStartNavigationToPendingEntry( | 38 void DidStartNavigationToPendingEntry( |
59 const GURL& url, | 39 const GURL& url, |
60 content::NavigationController::ReloadType reload_type) override; | 40 content::NavigationController::ReloadType reload_type) override; |
61 | 41 |
62 // WebUIMessageHandler implementation. | 42 // WebUIMessageHandler implementation. |
63 void RegisterMessages() override; | 43 void RegisterMessages() override; |
64 | 44 |
65 // ExtensionPrefsObserver implementation. | |
66 void OnExtensionDisableReasonsChanged(const std::string& extension_id, | |
67 int disable_reasons) override; | |
68 | |
69 // ExtensionManagement::Observer implementation. | |
70 void OnExtensionManagementSettingsChanged() override; | |
71 | |
72 // WarningService::Observer implementation. | |
73 void ExtensionWarningsChanged() override; | |
74 | |
75 // Helper method that reloads all unpacked extensions. | 45 // Helper method that reloads all unpacked extensions. |
76 void ReloadUnpackedExtensions(); | 46 void ReloadUnpackedExtensions(); |
77 | 47 |
78 // Callback for the "extensionSettingsRegister" message. | |
79 void HandleRegisterMessage(const base::ListValue* args); | |
80 | |
81 // Forces a UI update if appropriate after a notification is received. | |
82 void MaybeUpdateAfterNotification(); | |
83 | |
84 // Our model. Outlives us since it's owned by our containing profile. | 48 // Our model. Outlives us since it's owned by our containing profile. |
85 ExtensionService* extension_service_; | 49 ExtensionService* extension_service_; |
86 | 50 |
87 ScopedObserver<WarningService, WarningService::Observer> | |
88 warning_service_observer_; | |
89 | |
90 // An observer to listen for notable changes in the ExtensionPrefs, like | |
91 // a change in Disable Reasons. | |
92 ScopedObserver<ExtensionPrefs, ExtensionPrefsObserver> | |
93 extension_prefs_observer_; | |
94 | |
95 ScopedObserver<ExtensionManagement, ExtensionManagement::Observer> | |
96 extension_management_observer_; | |
97 | |
98 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 51 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
99 }; | 52 }; |
100 | 53 |
101 } // namespace extensions | 54 } // namespace extensions |
102 | 55 |
103 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 56 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
OLD | NEW |