Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/android/tab_android.h" | 5 #include "chrome/browser/android/tab_android.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| 11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
| 16 #include "chrome/browser/android/compositor/tab_content_manager.h" | 16 #include "chrome/browser/android/compositor/tab_content_manager.h" |
| 17 #include "chrome/browser/android/download/chrome_download_delegate.h" | |
| 17 #include "chrome/browser/android/metrics/uma_utils.h" | 18 #include "chrome/browser/android/metrics/uma_utils.h" |
| 18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 19 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 19 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 20 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 20 #include "chrome/browser/android/tab_web_contents_delegate_android.h" | 21 #include "chrome/browser/android/tab_web_contents_delegate_android.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 22 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" | 23 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" |
| 23 #include "chrome/browser/browser_about_handler.h" | 24 #include "chrome/browser/browser_about_handler.h" |
| 24 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
| 25 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 26 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 26 #include "chrome/browser/infobars/infobar_service.h" | 27 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 void TabAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 373 void TabAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 373 delete this; | 374 delete this; |
| 374 } | 375 } |
| 375 | 376 |
| 376 void TabAndroid::InitWebContents( | 377 void TabAndroid::InitWebContents( |
| 377 JNIEnv* env, | 378 JNIEnv* env, |
| 378 const JavaParamRef<jobject>& obj, | 379 const JavaParamRef<jobject>& obj, |
| 379 jboolean incognito, | 380 jboolean incognito, |
| 380 const JavaParamRef<jobject>& jcontent_view_core, | 381 const JavaParamRef<jobject>& jcontent_view_core, |
| 381 const JavaParamRef<jobject>& jweb_contents_delegate, | 382 const JavaParamRef<jobject>& jweb_contents_delegate, |
| 383 const JavaParamRef<jobject>& jdownload_delegate, | |
| 382 const JavaParamRef<jobject>& jcontext_menu_populator) { | 384 const JavaParamRef<jobject>& jcontext_menu_populator) { |
| 383 content::ContentViewCore* content_view_core = | 385 content::ContentViewCore* content_view_core = |
| 384 content::ContentViewCore::GetNativeContentViewCore(env, | 386 content::ContentViewCore::GetNativeContentViewCore(env, |
| 385 jcontent_view_core); | 387 jcontent_view_core); |
| 386 DCHECK(content_view_core); | 388 DCHECK(content_view_core); |
| 387 DCHECK(content_view_core->GetWebContents()); | 389 DCHECK(content_view_core->GetWebContents()); |
| 388 | 390 |
| 389 web_contents_.reset(content_view_core->GetWebContents()); | 391 web_contents_.reset(content_view_core->GetWebContents()); |
| 390 AttachTabHelpers(web_contents_.get()); | 392 AttachTabHelpers(web_contents_.get()); |
| 391 | 393 |
| 392 SetWindowSessionID(session_window_id_.id()); | 394 SetWindowSessionID(session_window_id_.id()); |
| 393 | 395 |
| 394 session_tab_id_.set_id( | 396 session_tab_id_.set_id( |
| 395 SessionTabHelper::FromWebContents(web_contents())->session_id().id()); | 397 SessionTabHelper::FromWebContents(web_contents())->session_id().id()); |
| 396 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( | 398 ContextMenuHelper::FromWebContents(web_contents())->SetPopulator( |
| 397 jcontext_menu_populator); | 399 jcontext_menu_populator); |
| 398 ViewAndroidHelper::FromWebContents(web_contents())-> | 400 ViewAndroidHelper::FromWebContents(web_contents())-> |
| 399 SetViewAndroid(content_view_core); | 401 SetViewAndroid(content_view_core); |
| 400 CoreTabHelper::FromWebContents(web_contents())->set_delegate(this); | 402 CoreTabHelper::FromWebContents(web_contents())->set_delegate(this); |
| 401 SearchTabHelper::FromWebContents(web_contents())->set_delegate(this); | 403 SearchTabHelper::FromWebContents(web_contents())->set_delegate(this); |
| 404 ChromeDownloadDelegate::FromWebContents(web_contents())-> | |
| 405 SetDelegate(env, jdownload_delegate); | |
|
no sievers
2016/06/07 21:35:23
nit: I'd call this Init() or something instead of
Jinsuk Kim
2016/06/08 06:29:08
Done.
| |
| 402 web_contents_delegate_.reset( | 406 web_contents_delegate_.reset( |
| 403 new chrome::android::TabWebContentsDelegateAndroid( | 407 new chrome::android::TabWebContentsDelegateAndroid( |
| 404 env, jweb_contents_delegate)); | 408 env, jweb_contents_delegate)); |
| 405 web_contents_delegate_->LoadProgressChanged(web_contents(), 0); | 409 web_contents_delegate_->LoadProgressChanged(web_contents(), 0); |
| 406 web_contents()->SetDelegate(web_contents_delegate_.get()); | 410 web_contents()->SetDelegate(web_contents_delegate_.get()); |
| 407 | 411 |
| 408 notification_registrar_.Add( | 412 notification_registrar_.Add( |
| 409 this, | 413 this, |
| 410 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 414 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 411 content::Source<content::WebContents>(web_contents())); | 415 content::Source<content::WebContents>(web_contents())); |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 914 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 911 TRACE_EVENT0("native", "TabAndroid::Init"); | 915 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 912 // This will automatically bind to the Java object and pass ownership there. | 916 // This will automatically bind to the Java object and pass ownership there. |
| 913 new TabAndroid(env, obj); | 917 new TabAndroid(env, obj); |
| 914 } | 918 } |
| 915 | 919 |
| 916 // static | 920 // static |
| 917 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 921 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 918 return RegisterNativesImpl(env); | 922 return RegisterNativesImpl(env); |
| 919 } | 923 } |
| OLD | NEW |