Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: chrome/browser/extensions/extension_function_registry.cc

Issue 9701105: Revert 127159 - Refactor extension_function_dispatcher to extract ExtensionFunctionRegistry. This a… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_function_registry.h"
6
7 #include "chrome/browser/accessibility/accessibility_extension_api.h"
8 #include "chrome/browser/bookmarks/bookmark_extension_api.h"
9 #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h"
10 #include "chrome/browser/download/download_extension_api.h"
11 #include "chrome/browser/extensions/api/app/app_api.h"
12 #include "chrome/browser/extensions/api/browsingdata/browsing_data_api.h"
13 #include "chrome/browser/extensions/api/declarative/declarative_api.h"
14 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
15 #include "chrome/browser/extensions/api/serial/serial_api.h"
16 #include "chrome/browser/extensions/api/socket/socket_api.h"
17 #include "chrome/browser/extensions/api/webrequest/webrequest_api.h"
18 #include "chrome/browser/extensions/execute_code_in_tab_function.h"
19 #include "chrome/browser/extensions/extension_browser_actions_api.h"
20 #include "chrome/browser/extensions/extension_chrome_auth_private_api.h"
21 #include "chrome/browser/extensions/extension_content_settings_api.h"
22 #include "chrome/browser/extensions/extension_context_menu_api.h"
23 #include "chrome/browser/extensions/extension_cookies_api.h"
24 #include "chrome/browser/extensions/extension_debugger_api.h"
25 #include "chrome/browser/extensions/extension_font_settings_api.h"
26 #include "chrome/browser/extensions/extension_i18n_api.h"
27 #include "chrome/browser/extensions/extension_idle_api.h"
28 #include "chrome/browser/extensions/extension_managed_mode_api.h"
29 #include "chrome/browser/extensions/extension_management_api.h"
30 #include "chrome/browser/extensions/extension_metrics_module.h"
31 #include "chrome/browser/extensions/extension_module.h"
32 #include "chrome/browser/extensions/extension_omnibox_api.h"
33 #include "chrome/browser/extensions/extension_page_actions_module.h"
34 #include "chrome/browser/extensions/extension_page_capture_api.h"
35 #include "chrome/browser/extensions/extension_preference_api.h"
36 #include "chrome/browser/extensions/extension_processes_api.h"
37 #include "chrome/browser/extensions/extension_tabs_module.h"
38 #include "chrome/browser/extensions/extension_test_api.h"
39 #include "chrome/browser/extensions/extension_tts_api.h"
40 #include "chrome/browser/extensions/extension_tts_engine_api.h"
41 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h"
42 #include "chrome/browser/extensions/extension_webnavigation_api.h"
43 #include "chrome/browser/extensions/extension_webstore_private_api.h"
44 #include "chrome/browser/extensions/settings/settings_api.h"
45 #include "chrome/browser/extensions/system/system_api.h"
46 #include "chrome/browser/history/history_extension_api.h"
47 #include "chrome/browser/history/top_sites_extension_api.h"
48 #include "chrome/browser/infobars/infobar_extension_api.h"
49 #include "chrome/browser/rlz/rlz_extension_api.h"
50 #include "chrome/browser/speech/speech_input_extension_api.h"
51 #include "chrome/common/extensions/api/generated_api.h"
52
53 #if defined(TOOLKIT_VIEWS)
54 #include "chrome/browser/extensions/extension_input_api.h"
55 #endif
56
57 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD)
58 #include "chrome/browser/extensions/extension_input_ui_api.h"
59 #endif
60
61 #if defined(OS_CHROMEOS)
62 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h"
63 #include "chrome/browser/chromeos/media/media_player_extension_api.h"
64 #include "chrome/browser/extensions/api/terminal/terminal_private_api.h"
65 #include "chrome/browser/extensions/extension_info_private_api_chromeos.h"
66 #include "chrome/browser/extensions/extension_input_ime_api.h"
67 #include "chrome/browser/extensions/extension_input_method_api.h"
68 #endif
69
70 // static
71 ExtensionFunctionRegistry* ExtensionFunctionRegistry::GetInstance() {
72 return Singleton<ExtensionFunctionRegistry>::get();
73 }
74
75 ExtensionFunctionRegistry::ExtensionFunctionRegistry() {
76 ResetFunctions();
77 }
78
79 ExtensionFunctionRegistry::~ExtensionFunctionRegistry() {
80 }
81
82 void ExtensionFunctionRegistry::ResetFunctions() {
83 // Register all functions here.
84
85 // Windows
86 RegisterFunction<GetWindowFunction>();
87 RegisterFunction<GetCurrentWindowFunction>();
88 RegisterFunction<GetLastFocusedWindowFunction>();
89 RegisterFunction<GetAllWindowsFunction>();
90 RegisterFunction<CreateWindowFunction>();
91 RegisterFunction<UpdateWindowFunction>();
92 RegisterFunction<RemoveWindowFunction>();
93
94 // Tabs
95 RegisterFunction<GetTabFunction>();
96 RegisterFunction<GetCurrentTabFunction>();
97 RegisterFunction<GetSelectedTabFunction>();
98 RegisterFunction<GetAllTabsInWindowFunction>();
99 RegisterFunction<QueryTabsFunction>();
100 RegisterFunction<HighlightTabsFunction>();
101 RegisterFunction<CreateTabFunction>();
102 RegisterFunction<UpdateTabFunction>();
103 RegisterFunction<MoveTabsFunction>();
104 RegisterFunction<ReloadTabFunction>();
105 RegisterFunction<RemoveTabsFunction>();
106 RegisterFunction<DetectTabLanguageFunction>();
107 RegisterFunction<CaptureVisibleTabFunction>();
108 RegisterFunction<TabsExecuteScriptFunction>();
109 RegisterFunction<TabsInsertCSSFunction>();
110
111 // Page Actions.
112 RegisterFunction<EnablePageActionFunction>();
113 RegisterFunction<DisablePageActionFunction>();
114 RegisterFunction<PageActionShowFunction>();
115 RegisterFunction<PageActionHideFunction>();
116 RegisterFunction<PageActionSetIconFunction>();
117 RegisterFunction<PageActionSetTitleFunction>();
118 RegisterFunction<PageActionSetPopupFunction>();
119
120 // Browser Actions.
121 RegisterFunction<BrowserActionSetIconFunction>();
122 RegisterFunction<BrowserActionSetTitleFunction>();
123 RegisterFunction<BrowserActionSetBadgeTextFunction>();
124 RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>();
125 RegisterFunction<BrowserActionSetPopupFunction>();
126
127 // Browsing Data.
128 RegisterFunction<RemoveBrowsingDataFunction>();
129 RegisterFunction<RemoveAppCacheFunction>();
130 RegisterFunction<RemoveCacheFunction>();
131 RegisterFunction<RemoveCookiesFunction>();
132 RegisterFunction<RemoveDownloadsFunction>();
133 RegisterFunction<RemoveFileSystemsFunction>();
134 RegisterFunction<RemoveFormDataFunction>();
135 RegisterFunction<RemoveHistoryFunction>();
136 RegisterFunction<RemoveIndexedDBFunction>();
137 RegisterFunction<RemoveLocalStorageFunction>();
138 RegisterFunction<RemoveOriginBoundCertsFunction>();
139 RegisterFunction<RemovePluginDataFunction>();
140 RegisterFunction<RemovePasswordsFunction>();
141 RegisterFunction<RemoveWebSQLFunction>();
142
143 // Bookmarks.
144 RegisterFunction<GetBookmarksFunction>();
145 RegisterFunction<GetBookmarkChildrenFunction>();
146 RegisterFunction<GetBookmarkRecentFunction>();
147 RegisterFunction<GetBookmarkTreeFunction>();
148 RegisterFunction<GetBookmarkSubTreeFunction>();
149 RegisterFunction<SearchBookmarksFunction>();
150 RegisterFunction<RemoveBookmarkFunction>();
151 RegisterFunction<RemoveTreeBookmarkFunction>();
152 RegisterFunction<CreateBookmarkFunction>();
153 RegisterFunction<MoveBookmarkFunction>();
154 RegisterFunction<UpdateBookmarkFunction>();
155
156 // Infobars.
157 RegisterFunction<ShowInfoBarFunction>();
158
159 // BookmarkManager
160 RegisterFunction<CopyBookmarkManagerFunction>();
161 RegisterFunction<CutBookmarkManagerFunction>();
162 RegisterFunction<PasteBookmarkManagerFunction>();
163 RegisterFunction<CanPasteBookmarkManagerFunction>();
164 RegisterFunction<ImportBookmarksFunction>();
165 RegisterFunction<ExportBookmarksFunction>();
166 RegisterFunction<SortChildrenBookmarkManagerFunction>();
167 RegisterFunction<BookmarkManagerGetStringsFunction>();
168 RegisterFunction<StartDragBookmarkManagerFunction>();
169 RegisterFunction<DropBookmarkManagerFunction>();
170 RegisterFunction<GetSubtreeBookmarkManagerFunction>();
171 RegisterFunction<CanEditBookmarkManagerFunction>();
172
173 // History
174 RegisterFunction<AddUrlHistoryFunction>();
175 RegisterFunction<DeleteAllHistoryFunction>();
176 RegisterFunction<DeleteRangeHistoryFunction>();
177 RegisterFunction<DeleteUrlHistoryFunction>();
178 RegisterFunction<GetVisitsHistoryFunction>();
179 RegisterFunction<SearchHistoryFunction>();
180
181 // Idle
182 RegisterFunction<ExtensionIdleQueryStateFunction>();
183
184 // I18N.
185 RegisterFunction<GetAcceptLanguagesFunction>();
186
187 // Processes.
188 RegisterFunction<GetProcessIdForTabFunction>();
189
190 // Metrics.
191 RegisterFunction<MetricsRecordUserActionFunction>();
192 RegisterFunction<MetricsRecordValueFunction>();
193 RegisterFunction<MetricsRecordPercentageFunction>();
194 RegisterFunction<MetricsRecordCountFunction>();
195 RegisterFunction<MetricsRecordSmallCountFunction>();
196 RegisterFunction<MetricsRecordMediumCountFunction>();
197 RegisterFunction<MetricsRecordTimeFunction>();
198 RegisterFunction<MetricsRecordMediumTimeFunction>();
199 RegisterFunction<MetricsRecordLongTimeFunction>();
200
201 // RLZ.
202 #if defined(OS_WIN)
203 RegisterFunction<RlzRecordProductEventFunction>();
204 RegisterFunction<RlzGetAccessPointRlzFunction>();
205 RegisterFunction<RlzSendFinancialPingFunction>();
206 RegisterFunction<RlzClearProductStateFunction>();
207 #endif
208
209 // Cookies.
210 RegisterFunction<GetCookieFunction>();
211 RegisterFunction<GetAllCookiesFunction>();
212 RegisterFunction<SetCookieFunction>();
213 RegisterFunction<RemoveCookieFunction>();
214 RegisterFunction<GetAllCookieStoresFunction>();
215
216 // Test.
217 RegisterFunction<ExtensionTestPassFunction>();
218 RegisterFunction<ExtensionTestFailFunction>();
219 RegisterFunction<ExtensionTestLogFunction>();
220 RegisterFunction<ExtensionTestQuotaResetFunction>();
221 RegisterFunction<ExtensionTestCreateIncognitoTabFunction>();
222 RegisterFunction<ExtensionTestSendMessageFunction>();
223 RegisterFunction<ExtensionTestGetConfigFunction>();
224
225 // Accessibility.
226 RegisterFunction<GetFocusedControlFunction>();
227 RegisterFunction<SetAccessibilityEnabledFunction>();
228 RegisterFunction<GetAlertsForTabFunction>();
229
230 // Text-to-speech.
231 RegisterFunction<ExtensionTtsEngineSendTtsEventFunction>();
232 RegisterFunction<ExtensionTtsGetVoicesFunction>();
233 RegisterFunction<ExtensionTtsIsSpeakingFunction>();
234 RegisterFunction<ExtensionTtsSpeakFunction>();
235 RegisterFunction<ExtensionTtsStopSpeakingFunction>();
236
237 // Context Menus.
238 RegisterFunction<CreateContextMenuFunction>();
239 RegisterFunction<UpdateContextMenuFunction>();
240 RegisterFunction<RemoveContextMenuFunction>();
241 RegisterFunction<RemoveAllContextMenusFunction>();
242
243 // Omnibox.
244 RegisterFunction<OmniboxSendSuggestionsFunction>();
245 RegisterFunction<OmniboxSetDefaultSuggestionFunction>();
246
247 // Speech input.
248 RegisterFunction<StartSpeechInputFunction>();
249 RegisterFunction<StopSpeechInputFunction>();
250 RegisterFunction<IsRecordingSpeechInputFunction>();
251
252 #if defined(TOOLKIT_VIEWS)
253 // Input.
254 RegisterFunction<SendKeyboardEventInputFunction>();
255 #endif
256
257 #if defined(USE_VIRTUAL_KEYBOARD)
258 RegisterFunction<HideKeyboardFunction>();
259 RegisterFunction<SetKeyboardHeightFunction>();
260 #endif
261
262 #if defined(OS_CHROMEOS)
263 // IME
264 RegisterFunction<SetCompositionFunction>();
265 RegisterFunction<ClearCompositionFunction>();
266 RegisterFunction<CommitTextFunction>();
267 RegisterFunction<SetCandidateWindowPropertiesFunction>();
268 RegisterFunction<SetCandidatesFunction>();
269 RegisterFunction<SetCursorPositionFunction>();
270 RegisterFunction<SetMenuItemsFunction>();
271 RegisterFunction<UpdateMenuItemsFunction>();
272
273 RegisterFunction<InputEventHandled>();
274 #if defined(USE_VIRTUAL_KEYBOARD)
275 RegisterFunction<CandidateClickedInputUiFunction>();
276 RegisterFunction<CursorUpInputUiFunction>();
277 RegisterFunction<CursorDownInputUiFunction>();
278 RegisterFunction<PageUpInputUiFunction>();
279 RegisterFunction<PageDownInputUiFunction>();
280 RegisterFunction<RegisterInputUiFunction>();
281 RegisterFunction<PageUpInputUiFunction>();
282 RegisterFunction<PageDownInputUiFunction>();
283 #endif
284 #endif
285
286 // Managed mode.
287 RegisterFunction<GetManagedModeFunction>();
288 RegisterFunction<EnterManagedModeFunction>();
289
290 // Management.
291 RegisterFunction<GetAllExtensionsFunction>();
292 RegisterFunction<GetExtensionByIdFunction>();
293 RegisterFunction<GetPermissionWarningsByIdFunction>();
294 RegisterFunction<GetPermissionWarningsByManifestFunction>();
295 RegisterFunction<LaunchAppFunction>();
296 RegisterFunction<SetEnabledFunction>();
297 RegisterFunction<UninstallFunction>();
298
299 // Extension module.
300 RegisterFunction<SetUpdateUrlDataFunction>();
301 RegisterFunction<IsAllowedIncognitoAccessFunction>();
302 RegisterFunction<IsAllowedFileSchemeAccessFunction>();
303
304 // WebstorePrivate.
305 RegisterFunction<GetBrowserLoginFunction>();
306 RegisterFunction<GetStoreLoginFunction>();
307 RegisterFunction<SetStoreLoginFunction>();
308 RegisterFunction<InstallBundleFunction>();
309 RegisterFunction<BeginInstallWithManifestFunction>();
310 RegisterFunction<CompleteInstallFunction>();
311 RegisterFunction<SilentlyInstallFunction>();
312 RegisterFunction<GetWebGLStatusFunction>();
313
314 // WebNavigation.
315 RegisterFunction<GetFrameFunction>();
316 RegisterFunction<GetAllFramesFunction>();
317
318 // WebRequest.
319 RegisterFunction<WebRequestAddEventListener>();
320 RegisterFunction<WebRequestEventHandled>();
321 RegisterFunction<WebRequestHandlerBehaviorChanged>();
322
323 // Preferences.
324 RegisterFunction<GetPreferenceFunction>();
325 RegisterFunction<SetPreferenceFunction>();
326 RegisterFunction<ClearPreferenceFunction>();
327
328 // ChromeOS-specific part of the API.
329 #if defined(OS_CHROMEOS)
330 // Device Customization.
331 RegisterFunction<GetChromeosInfoFunction>();
332
333 // FileBrowserPrivate functions.
334 // TODO(jamescook): Expose these on non-ChromeOS platforms so we can use
335 // the extension-based file picker on Aura. crbug.com/97424
336 RegisterFunction<CancelFileDialogFunction>();
337 RegisterFunction<ExecuteTasksFileBrowserFunction>();
338 RegisterFunction<FileDialogStringsFunction>();
339 RegisterFunction<GetFileTasksFileBrowserFunction>();
340 RegisterFunction<GetVolumeMetadataFunction>();
341 RegisterFunction<RequestLocalFileSystemFunction>();
342 RegisterFunction<AddFileWatchBrowserFunction>();
343 RegisterFunction<RemoveFileWatchBrowserFunction>();
344 RegisterFunction<SelectFileFunction>();
345 RegisterFunction<SelectFilesFunction>();
346 RegisterFunction<AddMountFunction>();
347 RegisterFunction<RemoveMountFunction>();
348 RegisterFunction<GetMountPointsFunction>();
349 RegisterFunction<GetSizeStatsFunction>();
350 RegisterFunction<FormatDeviceFunction>();
351 RegisterFunction<ViewFilesFunction>();
352 RegisterFunction<ToggleFullscreenFunction>();
353 RegisterFunction<IsFullscreenFunction>();
354 RegisterFunction<GetGDataFilePropertiesFunction>();
355 RegisterFunction<PinGDataFileFunction>();
356 RegisterFunction<GetFileLocationsFunction>();
357 RegisterFunction<GetGDataFilesFunction>();
358
359 // Mediaplayer
360 RegisterFunction<PlayMediaplayerFunction>();
361 RegisterFunction<GetPlaylistMediaplayerFunction>();
362 RegisterFunction<SetWindowHeightMediaplayerFunction>();
363 RegisterFunction<CloseWindowMediaplayerFunction>();
364
365 // InputMethod
366 RegisterFunction<GetInputMethodFunction>();
367
368 // Terminal
369 RegisterFunction<OpenTerminalProcessFunction>();
370 RegisterFunction<SendInputToTerminalProcessFunction>();
371 RegisterFunction<CloseTerminalProcessFunction>();
372 RegisterFunction<OnTerminalResizeFunction>();
373
374 #if defined(USE_VIRTUAL_KEYBOARD)
375 // Input
376 RegisterFunction<SendHandwritingStrokeFunction>();
377 RegisterFunction<CancelHandwritingStrokesFunction>();
378 #endif
379 #endif
380
381 // Websocket to TCP proxy. Currently noop on anything other than ChromeOS.
382 RegisterFunction<WebSocketProxyPrivateGetPassportForTCPFunction>();
383 RegisterFunction<WebSocketProxyPrivateGetURLForTCPFunction>();
384
385 // Debugger
386 RegisterFunction<AttachDebuggerFunction>();
387 RegisterFunction<DetachDebuggerFunction>();
388 RegisterFunction<SendCommandDebuggerFunction>();
389
390 // Settings
391 RegisterFunction<extensions::GetSettingsFunction>();
392 RegisterFunction<extensions::SetSettingsFunction>();
393 RegisterFunction<extensions::RemoveSettingsFunction>();
394 RegisterFunction<extensions::ClearSettingsFunction>();
395 RegisterFunction<extensions::GetBytesInUseSettingsFunction>();
396
397 // Content settings.
398 RegisterFunction<GetResourceIdentifiersFunction>();
399 RegisterFunction<ClearContentSettingsFunction>();
400 RegisterFunction<GetContentSettingFunction>();
401 RegisterFunction<SetContentSettingFunction>();
402
403 // Font settings.
404 RegisterFunction<GetFontListFunction>();
405 RegisterFunction<GetFontNameFunction>();
406 RegisterFunction<SetFontNameFunction>();
407
408 // ChromeAuth settings.
409 RegisterFunction<SetCloudPrintCredentialsFunction>();
410
411 // Experimental App API.
412 RegisterFunction<AppNotifyFunction>();
413 RegisterFunction<AppClearAllNotificationsFunction>();
414
415 // Permissions
416 RegisterFunction<ContainsPermissionsFunction>();
417 RegisterFunction<GetAllPermissionsFunction>();
418 RegisterFunction<RemovePermissionsFunction>();
419 RegisterFunction<RequestPermissionsFunction>();
420
421 // Downloads
422 RegisterFunction<DownloadsDownloadFunction>();
423 RegisterFunction<DownloadsSearchFunction>();
424 RegisterFunction<DownloadsPauseFunction>();
425 RegisterFunction<DownloadsResumeFunction>();
426 RegisterFunction<DownloadsCancelFunction>();
427 RegisterFunction<DownloadsEraseFunction>();
428 RegisterFunction<DownloadsSetDestinationFunction>();
429 RegisterFunction<DownloadsAcceptDangerFunction>();
430 RegisterFunction<DownloadsShowFunction>();
431 RegisterFunction<DownloadsDragFunction>();
432 RegisterFunction<DownloadsGetFileIconFunction>();
433
434 // PageCapture
435 RegisterFunction<PageCaptureSaveAsMHTMLFunction>();
436
437 // TopSites
438 RegisterFunction<GetTopSitesFunction>();
439
440 // Serial
441 RegisterFunction<extensions::SerialOpenFunction>();
442 RegisterFunction<extensions::SerialCloseFunction>();
443 RegisterFunction<extensions::SerialReadFunction>();
444 RegisterFunction<extensions::SerialWriteFunction>();
445
446 // Sockets
447 RegisterFunction<extensions::SocketCreateFunction>();
448 RegisterFunction<extensions::SocketDestroyFunction>();
449 RegisterFunction<extensions::SocketConnectFunction>();
450 RegisterFunction<extensions::SocketDisconnectFunction>();
451 RegisterFunction<extensions::SocketReadFunction>();
452 RegisterFunction<extensions::SocketWriteFunction>();
453
454 // System
455 RegisterFunction<extensions::GetIncognitoModeAvailabilityFunction>();
456 RegisterFunction<extensions::GetUpdateStatusFunction>();
457
458 // Net
459 RegisterFunction<extensions::AddRulesFunction>();
460 RegisterFunction<extensions::RemoveRulesFunction>();
461 RegisterFunction<extensions::GetRulesFunction>();
462
463 // Generated APIs
464 extensions::api::GeneratedFunctionRegistry::RegisterAll(this);
465 }
466
467 void ExtensionFunctionRegistry::GetAllNames(std::vector<std::string>* names) {
468 for (FactoryMap::iterator iter = factories_.begin();
469 iter != factories_.end(); ++iter) {
470 names->push_back(iter->first);
471 }
472 }
473
474 bool ExtensionFunctionRegistry::OverrideFunction(
475 const std::string& name,
476 ExtensionFunctionFactory factory) {
477 FactoryMap::iterator iter = factories_.find(name);
478 if (iter == factories_.end()) {
479 return false;
480 } else {
481 iter->second = factory;
482 return true;
483 }
484 }
485
486 ExtensionFunction* ExtensionFunctionRegistry::NewFunction(
487 const std::string& name) {
488 FactoryMap::iterator iter = factories_.find(name);
489 DCHECK(iter != factories_.end());
490 ExtensionFunction* function = iter->second();
491 function->set_name(name);
492 return function;
493 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_registry.h ('k') | chrome/chrome_browser_extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698