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_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/extensions/extension_install_ui.h" | 14 #include "chrome/browser/extensions/extension_install_ui.h" |
14 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 15 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
15 #include "chrome/browser/extensions/extension_warning_set.h" | 16 #include "chrome/browser/extensions/extension_warning_set.h" |
16 #include "chrome/browser/ui/select_file_dialog.h" | 17 #include "chrome/browser/ui/select_file_dialog.h" |
17 #include "chrome/browser/ui/webui/options/options_ui.h" | |
18 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 21 #include "content/public/browser/render_view_host.h" |
| 22 #include "content/public/browser/web_ui_message_handler.h" |
21 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
22 | 24 |
23 class Extension; | 25 class Extension; |
24 class ExtensionService; | 26 class ExtensionService; |
25 class FilePath; | 27 class FilePath; |
26 class PrefService; | 28 class PrefService; |
27 class UserScript; | 29 class UserScript; |
28 | 30 |
29 namespace base { | 31 namespace base { |
30 class DictionaryValue; | 32 class DictionaryValue; |
31 class ListValue; | 33 class ListValue; |
32 } | 34 } |
33 | 35 |
34 // Information about a page running in an extension, for example a popup bubble, | 36 // Information about a page running in an extension, for example a popup bubble, |
35 // a background page, or a tab contents. | 37 // a background page, or a tab contents. |
36 struct ExtensionPage { | 38 struct ExtensionPage { |
37 ExtensionPage(const GURL& url, int render_process_id, int render_view_id, | 39 ExtensionPage(const GURL& url, int render_process_id, int render_view_id, |
38 bool incognito) | 40 bool incognito) |
39 : url(url), | 41 : url(url), |
40 render_process_id(render_process_id), | 42 render_process_id(render_process_id), |
41 render_view_id(render_view_id), | 43 render_view_id(render_view_id), |
42 incognito(incognito) {} | 44 incognito(incognito) {} |
43 GURL url; | 45 GURL url; |
44 int render_process_id; | 46 int render_process_id; |
45 int render_view_id; | 47 int render_view_id; |
46 bool incognito; | 48 bool incognito; |
47 }; | 49 }; |
48 | 50 |
49 // Extension Settings UI handler. | 51 // Extension Settings UI handler. |
50 class ExtensionSettingsHandler : public OptionsPageUIHandler, | 52 class ExtensionSettingsHandler : public content::WebUIMessageHandler, |
| 53 public content::NotificationObserver, |
51 public SelectFileDialog::Listener, | 54 public SelectFileDialog::Listener, |
52 public ExtensionUninstallDialog::Delegate { | 55 public ExtensionUninstallDialog::Delegate { |
53 public: | 56 public: |
54 ExtensionSettingsHandler(); | 57 ExtensionSettingsHandler(); |
55 virtual ~ExtensionSettingsHandler(); | 58 virtual ~ExtensionSettingsHandler(); |
56 | 59 |
57 static void RegisterUserPrefs(PrefService* prefs); | 60 static void RegisterUserPrefs(PrefService* prefs); |
58 | 61 |
59 // Extension Detail JSON Struct for page. (static for ease of testing). | 62 // Extension Detail JSON Struct for page. (static for ease of testing). |
60 // Note: |service| and |warnings| can be NULL in unit tests. | 63 // Note: |service| and |warnings| can be NULL in unit tests. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // SelectFileDialog::Listener | 131 // SelectFileDialog::Listener |
129 virtual void FileSelected(const FilePath& path, | 132 virtual void FileSelected(const FilePath& path, |
130 int index, void* params) OVERRIDE; | 133 int index, void* params) OVERRIDE; |
131 virtual void MultiFilesSelected( | 134 virtual void MultiFilesSelected( |
132 const std::vector<FilePath>& files, void* params) OVERRIDE; | 135 const std::vector<FilePath>& files, void* params) OVERRIDE; |
133 virtual void FileSelectionCanceled(void* params) OVERRIDE {} | 136 virtual void FileSelectionCanceled(void* params) OVERRIDE {} |
134 | 137 |
135 // WebUIMessageHandler implementation. | 138 // WebUIMessageHandler implementation. |
136 virtual void RegisterMessages() OVERRIDE; | 139 virtual void RegisterMessages() OVERRIDE; |
137 | 140 |
138 // OptionsUIHandler implementation. | 141 void GetLocalizedValues(base::DictionaryValue* localized_strings); |
139 virtual void GetLocalizedValues( | |
140 base::DictionaryValue* localized_strings) OVERRIDE; | |
141 | 142 |
142 // content::NotificationObserver implementation. | 143 // content::NotificationObserver implementation. |
143 virtual void Observe(int type, | 144 virtual void Observe(int type, |
144 const content::NotificationSource& source, | 145 const content::NotificationSource& source, |
145 const content::NotificationDetails& details) OVERRIDE; | 146 const content::NotificationDetails& details) OVERRIDE; |
146 | 147 |
147 // ExtensionUninstallDialog::Delegate implementation, used for receiving | 148 // ExtensionUninstallDialog::Delegate implementation, used for receiving |
148 // notification about uninstall confirmation dialog selections. | 149 // notification about uninstall confirmation dialog selections. |
149 virtual void ExtensionUninstallAccepted() OVERRIDE; | 150 virtual void ExtensionUninstallAccepted() OVERRIDE; |
150 virtual void ExtensionUninstallCanceled() OVERRIDE; | 151 virtual void ExtensionUninstallCanceled() OVERRIDE; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // it is removed from the process). Keep a pointer to it so we can exclude | 185 // it is removed from the process). Keep a pointer to it so we can exclude |
185 // it from the active views. | 186 // it from the active views. |
186 content::RenderViewHost* deleting_rvh_; | 187 content::RenderViewHost* deleting_rvh_; |
187 | 188 |
188 // We want to register for notifications only after we've responded at least | 189 // 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 | 190 // 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 | 191 // that don't exist yet when notifications come in. This variable makes sure |
191 // we do so only once. | 192 // we do so only once. |
192 bool registered_for_notifications_; | 193 bool registered_for_notifications_; |
193 | 194 |
| 195 content::NotificationRegistrar registrar_; |
| 196 |
194 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 197 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
195 }; | 198 }; |
196 | 199 |
197 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 200 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
OLD | NEW |