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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Extension Detail JSON Struct for page. (static for ease of testing). | 62 // Extension Detail JSON Struct for page. (static for ease of testing). |
63 // Note: |service| and |warnings| can be NULL in unit tests. | 63 // Note: |service| and |warnings| can be NULL in unit tests. |
64 static base::DictionaryValue* CreateExtensionDetailValue( | 64 static base::DictionaryValue* CreateExtensionDetailValue( |
65 ExtensionService* service, | 65 ExtensionService* service, |
66 const Extension* extension, | 66 const Extension* extension, |
67 const std::vector<ExtensionPage>& pages, | 67 const std::vector<ExtensionPage>& pages, |
68 const ExtensionWarningSet* warnings, | 68 const ExtensionWarningSet* warnings, |
69 bool enabled, | 69 bool enabled, |
70 bool terminated); | 70 bool terminated); |
71 | 71 |
72 // ContentScript JSON Struct for page. (static for ease of testing). | 72 void GetLocalizedValues(base::DictionaryValue* localized_strings); |
73 static base::DictionaryValue* CreateContentScriptDetailValue( | 73 |
74 const UserScript& script, | 74 private: |
75 const FilePath& extension_path); | 75 // WebUIMessageHandler implementation. |
| 76 virtual void RegisterMessages() OVERRIDE; |
| 77 |
| 78 // SelectFileDialog::Listener implementation. |
| 79 virtual void FileSelected(const FilePath& path, |
| 80 int index, void* params) OVERRIDE; |
| 81 virtual void MultiFilesSelected( |
| 82 const std::vector<FilePath>& files, void* params) OVERRIDE; |
| 83 virtual void FileSelectionCanceled(void* params) OVERRIDE {} |
| 84 |
| 85 // content::NotificationObserver implementation. |
| 86 virtual void Observe(int type, |
| 87 const content::NotificationSource& source, |
| 88 const content::NotificationDetails& details) OVERRIDE; |
| 89 |
| 90 // ExtensionUninstallDialog::Delegate implementation, used for receiving |
| 91 // notification about uninstall confirmation dialog selections. |
| 92 virtual void ExtensionUninstallAccepted() OVERRIDE; |
| 93 virtual void ExtensionUninstallCanceled() OVERRIDE; |
76 | 94 |
77 // Callback for "requestExtensionsData" message. | 95 // Callback for "requestExtensionsData" message. |
78 void HandleRequestExtensionsData(const base::ListValue* args); | 96 void HandleRequestExtensionsData(const base::ListValue* args); |
79 | 97 |
80 // Callback for "toggleDeveloperMode" message. | 98 // Callback for "toggleDeveloperMode" message. |
81 void HandleToggleDeveloperMode(const base::ListValue* args); | 99 void HandleToggleDeveloperMode(const base::ListValue* args); |
82 | 100 |
83 // Callback for "inspect" message. | 101 // Callback for "inspect" message. |
84 void HandleInspectMessage(const base::ListValue* args); | 102 void HandleInspectMessage(const base::ListValue* args); |
85 | 103 |
(...skipping 11 matching lines...) Expand all Loading... |
97 | 115 |
98 // Callback for "uninstall" message. | 116 // Callback for "uninstall" message. |
99 void HandleUninstallMessage(const base::ListValue* args); | 117 void HandleUninstallMessage(const base::ListValue* args); |
100 | 118 |
101 // Callback for "options" message. | 119 // Callback for "options" message. |
102 void HandleOptionsMessage(const base::ListValue* args); | 120 void HandleOptionsMessage(const base::ListValue* args); |
103 | 121 |
104 // Callback for "showButton" message. | 122 // Callback for "showButton" message. |
105 void HandleShowButtonMessage(const base::ListValue* args); | 123 void HandleShowButtonMessage(const base::ListValue* args); |
106 | 124 |
107 // Callback for "load" message. | |
108 void HandleLoadMessage(const base::ListValue* args); | |
109 | |
110 // Callback for "pack" message. | |
111 void HandlePackMessage(const base::ListValue* args); | |
112 | |
113 // Callback for "autoupdate" message. | 125 // Callback for "autoupdate" message. |
114 void HandleAutoUpdateMessage(const base::ListValue* args); | 126 void HandleAutoUpdateMessage(const base::ListValue* args); |
115 | 127 |
116 // Utility for calling javascript window.alert in the page. | 128 // Callback for "loadUnpackedExtension" message. |
| 129 void HandleLoadUnpackedExtensionMessage(const base::ListValue* args); |
| 130 |
| 131 // Utility for calling JavaScript window.alert in the page. |
117 void ShowAlert(const std::string& message); | 132 void ShowAlert(const std::string& message); |
118 | 133 |
119 // Callback for "selectFilePath" message. | |
120 void HandleSelectFilePathMessage(const base::ListValue* args); | |
121 | |
122 // Utility for callbacks that get an extension ID as the sole argument. | 134 // Utility for callbacks that get an extension ID as the sole argument. |
123 const Extension* GetExtension(const base::ListValue* args); | 135 const Extension* GetExtension(const base::ListValue* args); |
124 | 136 |
125 // Forces a UI update if appropriate after a notification is received. | 137 // Forces a UI update if appropriate after a notification is received. |
126 void MaybeUpdateAfterNotification(); | 138 void MaybeUpdateAfterNotification(); |
127 | 139 |
128 // Register for notifications that we need to reload the page. | 140 // Register for notifications that we need to reload the page. |
129 void MaybeRegisterForNotifications(); | 141 void MaybeRegisterForNotifications(); |
130 | 142 |
131 // SelectFileDialog::Listener | |
132 virtual void FileSelected(const FilePath& path, | |
133 int index, void* params) OVERRIDE; | |
134 virtual void MultiFilesSelected( | |
135 const std::vector<FilePath>& files, void* params) OVERRIDE; | |
136 virtual void FileSelectionCanceled(void* params) OVERRIDE {} | |
137 | |
138 // WebUIMessageHandler implementation. | |
139 virtual void RegisterMessages() OVERRIDE; | |
140 | |
141 void GetLocalizedValues(base::DictionaryValue* localized_strings); | |
142 | |
143 // content::NotificationObserver implementation. | |
144 virtual void Observe(int type, | |
145 const content::NotificationSource& source, | |
146 const content::NotificationDetails& details) OVERRIDE; | |
147 | |
148 // ExtensionUninstallDialog::Delegate implementation, used for receiving | |
149 // notification about uninstall confirmation dialog selections. | |
150 virtual void ExtensionUninstallAccepted() OVERRIDE; | |
151 virtual void ExtensionUninstallCanceled() OVERRIDE; | |
152 | |
153 private: | |
154 // Helper that lists the current active html pages for an extension. | 143 // Helper that lists the current active html pages for an extension. |
155 std::vector<ExtensionPage> GetActivePagesForExtension( | 144 std::vector<ExtensionPage> GetActivePagesForExtension( |
156 const Extension* extension); | 145 const Extension* extension); |
157 void GetActivePagesForExtensionProcess( | 146 void GetActivePagesForExtensionProcess( |
158 const std::set<content::RenderViewHost*>& views, | 147 const std::set<content::RenderViewHost*>& views, |
159 std::vector<ExtensionPage> *result); | 148 std::vector<ExtensionPage> *result); |
160 | 149 |
161 // Returns the ExtensionUninstallDialog object for this class, creating it if | 150 // Returns the ExtensionUninstallDialog object for this class, creating it if |
162 // needed. | 151 // needed. |
163 ExtensionUninstallDialog* GetExtensionUninstallDialog(); | 152 ExtensionUninstallDialog* GetExtensionUninstallDialog(); |
(...skipping 16 matching lines...) Expand all Loading... |
180 bool ignore_notifications_; | 169 bool ignore_notifications_; |
181 | 170 |
182 // The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED, | 171 // The page may be refreshed in response to a RENDER_VIEW_HOST_DELETED, |
183 // but the iteration over RenderViewHosts will include the host because the | 172 // but the iteration over RenderViewHosts will include the host because the |
184 // notification is sent when it is in the process of being deleted (and before | 173 // notification is sent when it is in the process of being deleted (and before |
185 // it is removed from the process). Keep a pointer to it so we can exclude | 174 // it is removed from the process). Keep a pointer to it so we can exclude |
186 // it from the active views. | 175 // it from the active views. |
187 content::RenderViewHost* deleting_rvh_; | 176 content::RenderViewHost* deleting_rvh_; |
188 | 177 |
189 // We want to register for notifications only after we've responded at least | 178 // We want to register for notifications only after we've responded at least |
190 // once to the page, otherwise we'd be calling javacsript functions on objects | 179 // once to the page, otherwise we'd be calling JavaScript functions on objects |
191 // that don't exist yet when notifications come in. This variable makes sure | 180 // that don't exist yet when notifications come in. This variable makes sure |
192 // we do so only once. | 181 // we do so only once. |
193 bool registered_for_notifications_; | 182 bool registered_for_notifications_; |
194 | 183 |
195 content::NotificationRegistrar registrar_; | 184 content::NotificationRegistrar registrar_; |
196 | 185 |
197 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 186 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
198 }; | 187 }; |
199 | 188 |
200 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ | 189 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_HANDLER_H_ |
OLD | NEW |