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_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 // Extension Detail JSON Struct for page. (static for ease of testing). | 59 // Extension Detail JSON Struct for page. (static for ease of testing). |
60 // Note: |service| and |warnings| can be NULL in unit tests. | 60 // Note: |service| and |warnings| can be NULL in unit tests. |
61 static base::DictionaryValue* CreateExtensionDetailValue( | 61 static base::DictionaryValue* CreateExtensionDetailValue( |
62 ExtensionService* service, | 62 ExtensionService* service, |
63 const Extension* extension, | 63 const Extension* extension, |
64 const std::vector<ExtensionPage>& pages, | 64 const std::vector<ExtensionPage>& pages, |
65 const ExtensionWarningSet* warnings, | 65 const ExtensionWarningSet* warnings, |
66 bool enabled, | 66 bool enabled, |
67 bool terminated); | 67 bool terminated); |
68 | 68 |
69 // ContentScript JSON Struct for page. (static for ease of testing). | 69 // OptionsUIHandler implementation. |
70 static base::DictionaryValue* CreateContentScriptDetailValue( | 70 virtual void GetLocalizedValues( |
71 const UserScript& script, | 71 base::DictionaryValue* localized_strings) OVERRIDE; |
72 const FilePath& extension_path); | 72 virtual void Initialize() OVERRIDE; |
73 | |
74 private: | |
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; | |
73 | 94 |
74 // Callback for "requestExtensionsData" message. | 95 // Callback for "requestExtensionsData" message. |
75 void HandleRequestExtensionsData(const base::ListValue* args); | 96 void HandleRequestExtensionsData(const base::ListValue* args); |
76 | 97 |
77 // Callback for "toggleDeveloperMode" message. | 98 // Callback for "toggleDeveloperMode" message. |
78 void HandleToggleDeveloperMode(const base::ListValue* args); | 99 void HandleToggleDeveloperMode(const base::ListValue* args); |
79 | 100 |
80 // Callback for "inspect" message. | 101 // Callback for "inspect" message. |
81 void HandleInspectMessage(const base::ListValue* args); | 102 void HandleInspectMessage(const base::ListValue* args); |
82 | 103 |
(...skipping 11 matching lines...) Expand all Loading... | |
94 | 115 |
95 // Callback for "uninstall" message. | 116 // Callback for "uninstall" message. |
96 void HandleUninstallMessage(const base::ListValue* args); | 117 void HandleUninstallMessage(const base::ListValue* args); |
97 | 118 |
98 // Callback for "options" message. | 119 // Callback for "options" message. |
99 void HandleOptionsMessage(const base::ListValue* args); | 120 void HandleOptionsMessage(const base::ListValue* args); |
100 | 121 |
101 // Callback for "showButton" message. | 122 // Callback for "showButton" message. |
102 void HandleShowButtonMessage(const base::ListValue* args); | 123 void HandleShowButtonMessage(const base::ListValue* args); |
103 | 124 |
104 // Callback for "load" message. | |
105 void HandleLoadMessage(const base::ListValue* args); | |
106 | |
107 // Callback for "pack" message. | |
108 void HandlePackMessage(const base::ListValue* args); | |
109 | |
110 // Callback for "autoupdate" message. | 125 // Callback for "autoupdate" message. |
111 void HandleAutoUpdateMessage(const base::ListValue* args); | 126 void HandleAutoUpdateMessage(const base::ListValue* args); |
112 | 127 |
113 // 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. | |
114 void ShowAlert(const std::string& message); | 132 void ShowAlert(const std::string& message); |
115 | 133 |
116 // Callback for "selectFilePath" message. | |
117 void HandleSelectFilePathMessage(const base::ListValue* args); | |
118 | |
119 // 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. |
120 const Extension* GetExtension(const base::ListValue* args); | 135 const Extension* GetExtension(const base::ListValue* args); |
121 | 136 |
122 // Forces a UI update if appropriate after a notification is received. | 137 // Forces a UI update if appropriate after a notification is received. |
123 void MaybeUpdateAfterNotification(); | 138 void MaybeUpdateAfterNotification(); |
124 | 139 |
125 // Register for notifications that we need to reload the page. | 140 // Register for notifications that we need to reload the page. |
126 void MaybeRegisterForNotifications(); | 141 void MaybeRegisterForNotifications(); |
127 | 142 |
128 // SelectFileDialog::Listener | 143 // Helpers that list the current active html pages for an extension. |
129 virtual void FileSelected(const FilePath& path, | |
130 int index, void* params) OVERRIDE; | |
131 virtual void MultiFilesSelected( | |
132 const std::vector<FilePath>& files, void* params) OVERRIDE; | |
133 virtual void FileSelectionCanceled(void* params) OVERRIDE {} | |
134 | |
135 // WebUIMessageHandler implementation. | |
136 virtual void RegisterMessages() OVERRIDE; | |
137 | |
138 // OptionsUIHandler implementation. | |
139 virtual void GetLocalizedValues( | |
140 base::DictionaryValue* localized_strings) OVERRIDE; | |
141 virtual void Initialize() OVERRIDE; | |
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. | |
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(); |
164 | 153 |
(...skipping 15 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 |
Aaron Boodman
2012/03/14 23:12:44
yay for properly capitalizing this word :)
| |
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 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); | 184 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsHandler); |
196 }; | 185 }; |
197 | 186 |
198 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ | 187 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_EXTENSION_SETTINGS_HANDLER_H_ |
OLD | NEW |