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.
5 #include "chrome/browser/android/chrome_jni_registrar.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_registrar.h"
9 #include "base/trace_event/trace_event.h"
10 #include "chrome/browser/after_startup_task_utils_android.h"
11 #include "chrome/browser/android/accessibility/font_size_prefs_android.h"
12 #include "chrome/browser/android/accessibility_util.h"
13 #include "chrome/browser/android/appmenu/app_menu_drag_helper.h"
14 #include "chrome/browser/android/banners/app_banner_infobar_delegate_android.h"
15 #include "chrome/browser/android/banners/app_banner_manager_android.h"
16 #include "chrome/browser/android/bookmarks/bookmarks_bridge.h"
17 #include "chrome/browser/android/bookmarks/edit_bookmark_helper.h"
18 #include "chrome/browser/android/bookmarks/partner_bookmarks_reader.h"
19 #include "chrome/browser/android/bottombar/contextualsearch/contextual_search_panel.h"
20 #include "chrome/browser/android/chrome_application.h"
21 #include "chrome/browser/android/chrome_web_contents_delegate_android.h"
22 #include "chrome/browser/android/compositor/compositor_view.h"
23 #include "chrome/browser/android/compositor/layer_title_cache.h"
24 #include "chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.h"
25 #include "chrome/browser/android/compositor/scene_layer/reader_mode_scene_layer.h"
26 #include "chrome/browser/android/compositor/scene_layer/scene_layer.h"
27 #include "chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.h"
28 #include "chrome/browser/android/compositor/scene_layer/tab_list_scene_layer.h"
29 #include "chrome/browser/android/compositor/scene_layer/tab_strip_scene_layer.h"
30 #include "chrome/browser/android/compositor/tab_content_manager.h"
31 #include "chrome/browser/android/contextualsearch/contextual_search_manager.h"
32 #include "chrome/browser/android/contextualsearch/contextual_search_tab_helper.h"
33 #include "chrome/browser/android/cookies/cookies_fetcher.h"
34 #include "chrome/browser/android/dev_tools_server.h"
35 #include "chrome/browser/android/document/document_web_contents_delegate.h"
36 #include "chrome/browser/android/dom_distiller/external_feedback_reporter_android.h"
37 #include "chrome/browser/android/download/chrome_download_delegate.h"
38 #include "chrome/browser/android/favicon_helper.h"
39 #include "chrome/browser/android/feature_utilities.h"
40 #include "chrome/browser/android/feedback/connectivity_checker.h"
41 #include "chrome/browser/android/find_in_page/find_in_page_bridge.h"
42 #include "chrome/browser/android/foreign_session_helper.h"
43 #include "chrome/browser/android/fullscreen/fullscreen_infobar_delegate.h"
44 #include "chrome/browser/android/history_report/history_report_jni_bridge.h"
45 #include "chrome/browser/android/intent_helper.h"
46 #include "chrome/browser/android/java_exception_reporter.h"
47 #include "chrome/browser/android/large_icon_bridge.h"
48 #include "chrome/browser/android/location_settings_impl.h"
49 #include "chrome/browser/android/logo_bridge.h"
50 #include "chrome/browser/android/metrics/launch_metrics.h"
51 #include "chrome/browser/android/metrics/uma_session_stats.h"
52 #include "chrome/browser/android/metrics/uma_utils.h"
53 #include "chrome/browser/android/metrics/variations_session.h"
54 #include "chrome/browser/android/most_visited_sites.h"
55 #include "chrome/browser/android/net/external_estimate_provider_android.h"
56 #include "chrome/browser/android/new_tab_page_prefs.h"
57 #include "chrome/browser/android/offline_pages/offline_page_bridge.h"
58 #include "chrome/browser/android/omnibox/answers_image_bridge.h"
59 #include "chrome/browser/android/omnibox/autocomplete_controller_android.h"
60 #include "chrome/browser/android/omnibox/omnibox_prerender.h"
61 #include "chrome/browser/android/password_ui_view_android.h"
62 #include "chrome/browser/android/precache/precache_launcher.h"
63 #include "chrome/browser/android/preferences/autofill/autofill_profile_bridge.h"
64 #include "chrome/browser/android/preferences/pref_service_bridge.h"
65 #include "chrome/browser/android/preferences/website_preference_bridge.h"
66 #include "chrome/browser/android/profiles/profile_downloader_android.h"
67 #include "chrome/browser/android/provider/chrome_browser_provider.h"
68 #include "chrome/browser/android/rappor/rappor_service_bridge.h"
69 #include "chrome/browser/android/recently_closed_tabs_bridge.h"
70 #include "chrome/browser/android/rlz/revenue_stats.h"
71 #include "chrome/browser/android/shortcut_helper.h"
72 #include "chrome/browser/android/signin/account_management_screen_helper.h"
73 #include "chrome/browser/android/signin/account_tracker_service_android.h"
74 #include "chrome/browser/android/signin/signin_manager_android.h"
75 #include "chrome/browser/android/tab/thumbnail_tab_helper_android.h"
76 #include "chrome/browser/android/tab_android.h"
77 #include "chrome/browser/android/tab_state.h"
78 #include "chrome/browser/android/url_utilities.h"
79 #include "chrome/browser/android/voice_search_tab_helper.h"
80 #include "chrome/browser/android/warmup_manager.h"
81 #include "chrome/browser/android/web_contents_factory.h"
82 #include "chrome/browser/android/webapps/add_to_homescreen_dialog_helper.h"
83 #include "chrome/browser/android/webapps/webapp_registry.h"
84 #include "chrome/browser/autofill/android/personal_data_manager_android.h"
85 #include "chrome/browser/dom_distiller/dom_distiller_service_factory_android.h"
86 #include "chrome/browser/dom_distiller/tab_utils_android.h"
87 #include "chrome/browser/history/android/sqlite_cursor.h"
88 #include "chrome/browser/invalidation/invalidation_service_factory_android.h"
89 #include "chrome/browser/lifetime/application_lifetime_android.h"
90 #include "chrome/browser/media/android/remote/record_cast_action.h"
91 #include "chrome/browser/media/android/remote/remote_media_player_bridge.h"
92 #include "chrome/browser/media/android/router/media_router_android.h"
93 #include "chrome/browser/media/android/router/media_router_dialog_controller_android.h"
94 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h"
95 #include "chrome/browser/notifications/notification_ui_manager_android.h"
96 #include "chrome/browser/password_manager/credential_android.h"
97 #include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
98 #include "chrome/browser/platform_util.h"
99 #include "chrome/browser/prerender/external_prerender_handler_android.h"
100 #include "chrome/browser/profiles/profile_android.h"
101 #include "chrome/browser/search_engines/template_url_service_android.h"
102 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h"
103 #include "chrome/browser/speech/tts_android.h"
104 #include "chrome/browser/spellchecker/spellchecker_session_bridge_android.h"
105 #include "chrome/browser/ssl/security_state_model_android.h"
106 #include "chrome/browser/supervised_user/child_accounts/child_account_feedback_reporter_android.h"
107 #include "chrome/browser/supervised_user/child_accounts/child_account_service_android.h"
108 #include "chrome/browser/sync/profile_sync_service_android.h"
109 #include "chrome/browser/ui/android/autofill/autofill_dialog_controller_android.h"
110 #include "chrome/browser/ui/android/autofill/autofill_dialog_result.h"
111 #include "chrome/browser/ui/android/autofill/autofill_keyboard_accessory_view.h"
112 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
113 #include "chrome/browser/ui/android/autofill/autofill_popup_view_android.h"
114 #include "chrome/browser/ui/android/autofill/card_unmask_prompt_view_android.h"
115 #include "chrome/browser/ui/android/autofill/credit_card_scanner_view_android.h"
116 #include "chrome/browser/ui/android/autofill/password_generation_popup_view_android.h"
117 #include "chrome/browser/ui/android/bluetooth_chooser_android.h"
118 #include "chrome/browser/ui/android/certificate_viewer_android.h"
119 #include "chrome/browser/ui/android/chrome_http_auth_handler.h"
120 #include "chrome/browser/ui/android/connection_info_popup_android.h"
121 #include "chrome/browser/ui/android/context_menu_helper.h"
122 #include "chrome/browser/ui/android/infobars/account_chooser_infobar.h"
123 #include "chrome/browser/ui/android/infobars/app_banner_infobar_android.h"
124 #include "chrome/browser/ui/android/infobars/confirm_infobar.h"
125 #include "chrome/browser/ui/android/infobars/data_reduction_proxy_infobar.h"
126 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
127 #include "chrome/browser/ui/android/infobars/generated_password_saved_infobar.h"
128 #include "chrome/browser/ui/android/infobars/infobar_android.h"
129 #include "chrome/browser/ui/android/infobars/infobar_container_android.h"
130 #include "chrome/browser/ui/android/infobars/save_password_infobar.h"
131 #include "chrome/browser/ui/android/infobars/translate_infobar.h"
132 #include "chrome/browser/ui/android/javascript_app_modal_dialog_android.h"
133 #include "chrome/browser/ui/android/omnibox/omnibox_url_emphasizer.h"
134 #include "chrome/browser/ui/android/omnibox/omnibox_view_util.h"
135 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h"
136 #include "chrome/browser/ui/android/ssl_client_certificate_request.h"
137 #include "chrome/browser/ui/android/tab_model/single_tab_model.h"
138 #include "chrome/browser/ui/android/tab_model/tab_model_jni_bridge.h"
139 #include "chrome/browser/ui/android/toolbar/toolbar_model_android.h"
140 #include "chrome/browser/ui/android/website_settings_popup_android.h"
141 #include "components/bookmarks/common/android/component_jni_registrar.h"
142 #include "components/dom_distiller/android/component_jni_registrar.h"
143 #include "components/gcm_driver/android/component_jni_registrar.h"
144 #include "components/invalidation/impl/android/component_jni_registrar.h"
145 #include "components/navigation_interception/component_jni_registrar.h"
146 #include "components/policy/core/browser/android/component_jni_registrar.h"
147 #include "components/safe_json/android/component_jni_registrar.h"
148 #include "components/service_tab_launcher/component_jni_registrar.h"
149 #include "components/signin/core/browser/android/component_jni_registrar.h"
150 #include "components/variations/android/component_jni_registrar.h"
151 #include "components/web_contents_delegate_android/component_jni_registrar.h"
152 #include "sync/android/sync_jni_registrar.h"
154 #if defined(ENABLE_PRINTING) && !defined(ENABLE_PRINT_PREVIEW)
155 #include "printing/printing_context_android.h"
161 static base::android::RegistrationMethod kChromeRegisteredMethods
[] = {
162 // Register JNI for components we depend on.
163 {"AppMenuDragHelper", RegisterAppMenuDragHelper
},
164 {"Bookmarks", bookmarks::android::RegisterBookmarks
},
165 {"DomDistiller", dom_distiller::android::RegisterDomDistiller
},
166 {"ChromeDownloadDelegate", RegisterChromeDownloadDelegate
},
167 {"GCMDriver", gcm::android::RegisterGCMDriverJni
},
168 {"Invalidation", invalidation::android::RegisterInvalidationJni
},
169 {"NavigationInterception",
170 navigation_interception::RegisterNavigationInterceptionJni
},
171 {"Policy", policy::android::RegisterPolicy
},
172 {"SafeJson", safe_json::android::RegisterSafeJsonJni
},
173 {"Signin", signin::android::RegisterSigninJni
},
174 {"WebContentsDelegateAndroid",
175 web_contents_delegate_android::RegisterWebContentsDelegateAndroidJni
},
176 // Register JNI for chrome classes.
177 {"AccessibilityUtils", AccessibilityUtil::Register
},
178 {"AccountChooserInfoBar", RegisterAccountChooserInfoBar
},
179 {"AccountManagementScreenHelper", AccountManagementScreenHelper::Register
},
180 {"AccountTrackerService", AccountTrackerServiceAndroid::Register
},
181 {"AddToHomescreenDialogHelper",
182 AddToHomescreenDialogHelper::RegisterAddToHomescreenDialogHelper
},
183 {"AfterStartupTaskUtils", RegisterAfterStartupTaskUtilsJNI
},
184 {"AnswersImageBridge", RegisterAnswersImageBridge
},
185 {"AppBannerInfoBarAndroid", RegisterAppBannerInfoBarAndroid
},
186 {"AppBannerInfoBarDelegateAndroid",
187 banners::RegisterAppBannerInfoBarDelegateAndroid
},
188 {"AppBannerManagerAndroid", banners::AppBannerManagerAndroid::Register
},
189 {"ApplicationLifetime", RegisterApplicationLifetimeAndroid
},
190 {"AutocompleteControllerAndroid", RegisterAutocompleteControllerAndroid
},
191 {"AutofillDialogControllerAndroid",
192 autofill::AutofillDialogControllerAndroid::
193 RegisterAutofillDialogControllerAndroid
},
194 {"AutofillDialogResult",
195 autofill::AutofillDialogResult::RegisterAutofillDialogResult
},
196 {"AutofillKeyboardAccessory", autofill::AutofillKeyboardAccessoryView::
197 RegisterAutofillKeyboardAccessoryView
},
198 {"AutofillLoggerAndroid", autofill::AutofillLoggerAndroid::Register
},
200 autofill::AutofillPopupViewAndroid::RegisterAutofillPopupViewAndroid
},
201 {"AutofillProfileBridge", autofill::RegisterAutofillProfileBridge
},
202 {"AutoSigninSnackbarController", RegisterAutoSigninSnackbarController
},
203 {"BluetoothChooserAndroid", BluetoothChooserAndroid::Register
},
204 {"BookmarksBridge", BookmarksBridge::RegisterBookmarksBridge
},
205 {"CardUnmaskPrompt", autofill::CardUnmaskPromptViewAndroid::Register
},
206 {"CertificateViewer", RegisterCertificateViewer
},
207 {"ChildAccountFeedbackReporter", RegisterChildAccountFeedbackReporter
},
208 {"ChildAccountService", RegisterChildAccountService
},
209 {"ChromeApplication", ChromeApplication::RegisterBindings
},
210 {"ChromeBrowserProvider",
211 ChromeBrowserProvider::RegisterChromeBrowserProvider
},
212 {"ChromeHttpAuthHandler",
213 ChromeHttpAuthHandler::RegisterChromeHttpAuthHandler
},
214 #if defined(ENABLE_MEDIA_ROUTER)
215 {"ChromeMediaRouter", media_router::MediaRouterAndroid::Register
},
216 {"ChromeMediaRouterDialogController",
217 media_router::MediaRouterDialogControllerAndroid::Register
},
219 {"ChromeWebContentsDelegateAndroid",
220 RegisterChromeWebContentsDelegateAndroid
},
221 {"CompositorView", RegisterCompositorView
},
222 {"ConfirmInfoBarDelegate", RegisterConfirmInfoBarDelegate
},
223 {"ConnectionInfoPopupAndroid",
224 ConnectionInfoPopupAndroid::RegisterConnectionInfoPopupAndroid
},
225 {"SecurityStateModel", RegisterSecurityStateModelAndroid
},
226 {"ConnectivityChecker", RegisterConnectivityChecker
},
227 {"ContextMenuHelper", RegisterContextMenuHelper
},
228 {"ContextualSearchManager", RegisterContextualSearchManager
},
229 {"ContextualSearchPanel", RegisterContextualSearchPanel
},
230 {"ContextualSearchSceneLayer", RegisterContextualSearchSceneLayer
},
231 {"ContextualSearchTabHelper", RegisterContextualSearchTabHelper
},
232 {"CookiesFetcher", RegisterCookiesFetcher
},
233 {"Credential", RegisterCredential
},
234 {"CreditCardScanner", autofill::CreditCardScannerViewAndroid::Register
},
235 {"DataReductionProxyInfoBarDelegate", DataReductionProxyInfoBar::Register
},
236 {"DataReductionProxySettings", DataReductionProxySettingsAndroid::Register
},
237 {"DevToolsServer", RegisterDevToolsServer
},
238 {"DocumentWebContentsDelegate", DocumentWebContentsDelegate::Register
},
239 {"DomDistillerServiceFactory",
240 dom_distiller::android::DomDistillerServiceFactoryAndroid::Register
},
241 {"DomDistillerTabUtils", RegisterDomDistillerTabUtils
},
242 {"DownloadOverwriteInfoBarDelegate",
243 RegisterDownloadOverwriteInfoBarDelegate
},
244 {"EditBookmarkHelper", RegisterEditBookmarkHelper
},
245 {"ExternalPrerenderRequestHandler",
246 prerender::ExternalPrerenderHandlerAndroid::
247 RegisterExternalPrerenderHandlerAndroid
},
248 {"FaviconHelper", FaviconHelper::RegisterFaviconHelper
},
249 {"FeatureUtilities", RegisterFeatureUtilities
},
250 {"FeedbackReporter", dom_distiller::android::RegisterFeedbackReporter
},
251 {"FindInPageBridge", FindInPageBridge::RegisterFindInPageBridge
},
252 {"FontSizePrefsAndroid", FontSizePrefsAndroid::Register
},
253 {"ForeignSessionHelper",
254 ForeignSessionHelper::RegisterForeignSessionHelper
},
255 {"FullscreenInfoBarDelegate",
256 FullscreenInfoBarDelegate::RegisterFullscreenInfoBarDelegate
},
257 {"GeneratedPasswordSavedInfoBarDelegate",
258 RegisterGeneratedPasswordSavedInfoBarDelegate
},
259 {"HistoryReportJniBridge", history_report::RegisterHistoryReportJniBridge
},
260 {"InfoBarContainer", RegisterInfoBarContainer
},
261 {"InvalidationServiceFactory",
262 invalidation::InvalidationServiceFactoryAndroid::Register
},
263 {"ShortcutHelper", ShortcutHelper::RegisterShortcutHelper
},
264 {"IntentHelper", RegisterIntentHelper
},
265 {"JavaExceptionReporter", RegisterJavaExceptionReporterJni
},
266 {"JavascriptAppModalDialog",
267 JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog
},
268 {"LargeIconBridge", LargeIconBridge::RegisterLargeIconBridge
},
269 {"LaunchMetrics", metrics::RegisterLaunchMetrics
},
270 {"LayerTitleCache", chrome::android::RegisterLayerTitleCache
},
271 {"LocationSettings", LocationSettingsImpl::Register
},
272 {"LogoBridge", RegisterLogoBridge
},
273 {"MostVisitedSites", MostVisitedSites::Register
},
274 {"NativeInfoBar", RegisterNativeInfoBar
},
275 {"ExternalEstimateProviderAndroid",
276 RegisterExternalEstimateProviderAndroid
},
277 {"NewTabPagePrefs", NewTabPagePrefs::RegisterNewTabPagePrefs
},
278 {"NotificationUIManager",
279 NotificationUIManagerAndroid::RegisterNotificationUIManager
},
280 {"OAuth2TokenServiceDelegateAndroid",
281 OAuth2TokenServiceDelegateAndroid::Register
},
282 {"OfflinePageBridge", offline_pages::android::RegisterOfflinePageBridge
},
283 {"OmniboxPrerender", RegisterOmniboxPrerender
},
284 {"OmniboxUrlEmphasizer",
285 OmniboxUrlEmphasizer::RegisterOmniboxUrlEmphasizer
},
286 {"OmniboxViewUtil", OmniboxViewUtil::RegisterOmniboxViewUtil
},
287 {"PlatformUtil", platform_util::RegisterPlatformUtil
},
288 {"PartnerBookmarksReader",
289 PartnerBookmarksReader::RegisterPartnerBookmarksReader
},
290 {"PasswordGenerationPopup",
291 autofill::PasswordGenerationPopupViewAndroid::Register
},
292 {"PasswordUIViewAndroid",
293 PasswordUIViewAndroid::RegisterPasswordUIViewAndroid
},
294 {"PermissionUpdateInfoBarDelegate",
295 PermissionUpdateInfoBarDelegate::RegisterPermissionUpdateInfoBarDelegate
},
296 {"PersonalDataManagerAndroid",
297 autofill::PersonalDataManagerAndroid::Register
},
298 {"PrecacheLauncher", RegisterPrecacheLauncher
},
299 {"PrefServiceBridge", PrefServiceBridge::RegisterPrefServiceBridge
},
300 {"ProfileAndroid", ProfileAndroid::RegisterProfileAndroid
},
301 {"ProfileDownloader", RegisterProfileDownloader
},
302 {"ProfileSyncService", ProfileSyncServiceAndroid::Register
},
303 {"RapporServiceBridge", rappor::RegisterRapporServiceBridge
},
304 {"ReaderModeSceneLayer", RegisterReaderModeSceneLayer
},
305 {"RecentlyClosedBridge", RecentlyClosedTabsBridge::Register
},
306 {"RecordCastAction", remote_media::RegisterRecordCastAction
},
307 {"RemoteMediaPlayerBridge",
308 remote_media::RemoteMediaPlayerBridge::RegisterRemoteMediaPlayerBridge
},
309 {"RevenueStats", RegisterRevenueStats
},
310 {"SavePasswordInfoBar", SavePasswordInfoBar::Register
},
311 {"SceneLayer", chrome::android::RegisterSceneLayer
},
312 {"ServiceTabLauncher", service_tab_launcher::RegisterServiceTabLauncherJni
},
313 {"SigninManager", SigninManagerAndroid::Register
},
314 {"SingleTabModel", RegisterSingleTabModel
},
315 {"SpellCheckerSessionBridge", SpellCheckerSessionBridge::RegisterJNI
},
316 {"SqliteCursor", SQLiteCursor::RegisterSqliteCursor
},
317 {"SSLClientCertificateRequest", RegisterSSLClientCertificateRequestAndroid
},
318 {"StartupMetricUtils", RegisterStartupMetricUtils
},
319 {"StaticTabSceneLayer", chrome::android::RegisterStaticTabSceneLayer
},
320 {"Sync", syncer::RegisterSyncJni
},
321 {"TabAndroid", TabAndroid::RegisterTabAndroid
},
322 {"TabContentManager", chrome::android::RegisterTabContentManager
},
323 {"TabListSceneLayer", RegisterTabListSceneLayer
},
324 {"TabModelJniBridge", TabModelJniBridge::Register
},
325 {"TabState", RegisterTabState
},
326 {"TabStripSceneLayer", RegisterTabStripSceneLayer
},
327 {"TemplateUrlServiceAndroid", TemplateUrlServiceAndroid::Register
},
328 {"ThumbnailTabHelperAndroid", RegisterThumbnailTabHelperAndroid
},
329 {"ToolbarModelAndroid", ToolbarModelAndroid::RegisterToolbarModelAndroid
},
330 {"TranslateInfoBarDelegate", RegisterTranslateInfoBarDelegate
},
331 {"TtsPlatformImpl", TtsPlatformImplAndroid::Register
},
332 {"UmaSessionStats", RegisterUmaSessionStats
},
333 {"UrlUtilities", RegisterUrlUtilities
},
334 {"Variations", variations::android::RegisterVariations
},
335 {"VariationsSession", chrome::android::RegisterVariationsSession
},
336 {"WarmupManager", RegisterWarmupManager
},
337 {"WebappRegistry", WebappRegistry::RegisterWebappRegistry
},
338 {"WebContentsFactory", RegisterWebContentsFactory
},
339 {"WebsitePreferenceBridge", RegisterWebsitePreferenceBridge
},
340 {"WebsiteSettingsPopupAndroid",
341 WebsiteSettingsPopupAndroid::RegisterWebsiteSettingsPopupAndroid
},
342 #if defined(ENABLE_PRINTING) && !defined(ENABLE_PRINT_PREVIEW)
344 printing::PrintingContextAndroid::RegisterPrintingContext
},
348 bool RegisterBrowserJNI(JNIEnv
* env
) {
349 TRACE_EVENT0("startup", "chrome_android::RegisterJni");
350 return RegisterNativeMethods(env
, kChromeRegisteredMethods
,
351 arraysize(kChromeRegisteredMethods
));
354 } // namespace android
355 } // namespace chrome