| 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_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "components/bookmarks/browser/bookmark_utils.h" | 55 #include "components/bookmarks/browser/bookmark_utils.h" |
| 56 #include "components/bookmarks/managed/managed_bookmark_service.h" | 56 #include "components/bookmarks/managed/managed_bookmark_service.h" |
| 57 #include "components/dom_distiller/core/url_utils.h" | 57 #include "components/dom_distiller/core/url_utils.h" |
| 58 #include "components/favicon/content/content_favicon_driver.h" | 58 #include "components/favicon/content/content_favicon_driver.h" |
| 59 #include "components/navigation_interception/intercept_navigation_delegate.h" | 59 #include "components/navigation_interception/intercept_navigation_delegate.h" |
| 60 #include "components/navigation_interception/navigation_params.h" | 60 #include "components/navigation_interception/navigation_params.h" |
| 61 #include "components/offline_pages/offline_page_feature.h" | 61 #include "components/offline_pages/offline_page_feature.h" |
| 62 #include "components/offline_pages/offline_page_item.h" | 62 #include "components/offline_pages/offline_page_item.h" |
| 63 #include "components/offline_pages/offline_page_model.h" | 63 #include "components/offline_pages/offline_page_model.h" |
| 64 #include "components/sessions/content/content_live_tab.h" | 64 #include "components/sessions/content/content_live_tab.h" |
| 65 #include "components/sessions/content/content_platform_specific_tab_data.h" |
| 65 #include "components/sessions/core/tab_restore_service.h" | 66 #include "components/sessions/core/tab_restore_service.h" |
| 66 #include "components/url_formatter/url_fixer.h" | 67 #include "components/url_formatter/url_fixer.h" |
| 67 #include "content/public/browser/android/compositor.h" | 68 #include "content/public/browser/android/compositor.h" |
| 68 #include "content/public/browser/android/content_view_core.h" | 69 #include "content/public/browser/android/content_view_core.h" |
| 69 #include "content/public/browser/browser_thread.h" | 70 #include "content/public/browser/browser_thread.h" |
| 70 #include "content/public/browser/interstitial_page.h" | 71 #include "content/public/browser/interstitial_page.h" |
| 71 #include "content/public/browser/navigation_entry.h" | 72 #include "content/public/browser/navigation_entry.h" |
| 72 #include "content/public/browser/notification_service.h" | 73 #include "content/public/browser/notification_service.h" |
| 73 #include "content/public/browser/render_frame_host.h" | 74 #include "content/public/browser/render_frame_host.h" |
| 74 #include "content/public/browser/render_process_host.h" | 75 #include "content/public/browser/render_process_host.h" |
| 75 #include "content/public/browser/render_view_host.h" | 76 #include "content/public/browser/render_view_host.h" |
| 76 #include "content/public/browser/user_metrics.h" | 77 #include "content/public/browser/user_metrics.h" |
| 77 #include "content/public/browser/web_contents.h" | 78 #include "content/public/browser/web_contents.h" |
| 78 #include "content/public/common/resource_request_body.h" | 79 #include "content/public/common/resource_request_body.h" |
| 79 #include "content/public/common/top_controls_state.h" | 80 #include "content/public/common/top_controls_state.h" |
| 80 #include "jni/Tab_jni.h" | 81 #include "jni/Tab_jni.h" |
| 81 #include "net/base/escape.h" | 82 #include "net/base/escape.h" |
| 82 #include "skia/ext/image_operations.h" | 83 #include "skia/ext/image_operations.h" |
| 83 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 84 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 84 #include "ui/base/resource/resource_bundle.h" | 85 #include "ui/base/resource/resource_bundle.h" |
| 85 #include "ui/base/window_open_disposition.h" | 86 #include "ui/base/window_open_disposition.h" |
| 86 #include "ui/gfx/android/device_display_info.h" | 87 #include "ui/gfx/android/device_display_info.h" |
| 87 #include "ui/gfx/android/java_bitmap.h" | 88 #include "ui/gfx/android/java_bitmap.h" |
| 88 #include "ui/gfx/favicon_size.h" | 89 #include "ui/gfx/favicon_size.h" |
| 89 #include "ui/gfx/image/image_skia.h" | 90 #include "ui/gfx/image/image_skia.h" |
| 90 | 91 |
| 92 |
| 93 |
| 94 |
| 91 using base::android::AttachCurrentThread; | 95 using base::android::AttachCurrentThread; |
| 92 using base::android::ConvertUTF8ToJavaString; | 96 using base::android::ConvertUTF8ToJavaString; |
| 93 using content::BrowserThread; | 97 using content::BrowserThread; |
| 94 using content::GlobalRequestID; | 98 using content::GlobalRequestID; |
| 95 using content::NavigationController; | 99 using content::NavigationController; |
| 96 using content::WebContents; | 100 using content::WebContents; |
| 97 using navigation_interception::InterceptNavigationDelegate; | 101 using navigation_interception::InterceptNavigationDelegate; |
| 98 using navigation_interception::NavigationParams; | 102 using navigation_interception::NavigationParams; |
| 99 | 103 |
| 100 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 104 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 if (!service) | 701 if (!service) |
| 698 return; | 702 return; |
| 699 | 703 |
| 700 // Exclude internal pages from being marked as recent when they are closed. | 704 // Exclude internal pages from being marked as recent when they are closed. |
| 701 const GURL& tab_url = web_contents->GetURL(); | 705 const GURL& tab_url = web_contents->GetURL(); |
| 702 if (tab_url.SchemeIs(content::kChromeUIScheme) || | 706 if (tab_url.SchemeIs(content::kChromeUIScheme) || |
| 703 tab_url.SchemeIs(chrome::kChromeNativeScheme) || | 707 tab_url.SchemeIs(chrome::kChromeNativeScheme) || |
| 704 tab_url.SchemeIs(url::kAboutScheme)) { | 708 tab_url.SchemeIs(url::kAboutScheme)) { |
| 705 return; | 709 return; |
| 706 } | 710 } |
| 711 sessions::ContentLiveTab* content_live_tab = |
| 712 sessions::ContentLiveTab::GetForWebContents(web_contents); |
| 713 |
| 714 // write window id so we know tab model id when recover tab. |
| 715 using ContentData = sessions::ContentPlatformSpecificTabData; |
| 716 ContentData* platform_data = |
| 717 static_cast<ContentData*> |
| 718 (content_live_tab->GetPlatformSpecificTabData().get()); |
| 719 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 720 |
| 721 platform_data->SetWindowId(tab_android->window_id().id()); |
| 707 | 722 |
| 708 // TODO(jcivelli): is the index important? | 723 // TODO(jcivelli): is the index important? |
| 709 service->CreateHistoricalTab( | 724 service->CreateHistoricalTab(content_live_tab, -1); |
| 710 sessions::ContentLiveTab::GetForWebContents(web_contents), -1); | |
| 711 } | 725 } |
| 712 | 726 |
| 713 void TabAndroid::CreateHistoricalTab(JNIEnv* env, | 727 void TabAndroid::CreateHistoricalTab(JNIEnv* env, |
| 714 const JavaParamRef<jobject>& obj) { | 728 const JavaParamRef<jobject>& obj) { |
| 715 TabAndroid::CreateHistoricalTabFromContents(web_contents()); | 729 TabAndroid::CreateHistoricalTabFromContents(web_contents()); |
| 716 } | 730 } |
| 717 | 731 |
| 718 void TabAndroid::UpdateTopControlsState(JNIEnv* env, | 732 void TabAndroid::UpdateTopControlsState(JNIEnv* env, |
| 719 const JavaParamRef<jobject>& obj, | 733 const JavaParamRef<jobject>& obj, |
| 720 jint constraints, | 734 jint constraints, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 915 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 902 TRACE_EVENT0("native", "TabAndroid::Init"); | 916 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 903 // This will automatically bind to the Java object and pass ownership there. | 917 // This will automatically bind to the Java object and pass ownership there. |
| 904 new TabAndroid(env, obj); | 918 new TabAndroid(env, obj); |
| 905 } | 919 } |
| 906 | 920 |
| 907 // static | 921 // static |
| 908 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 922 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 909 return RegisterNativesImpl(env); | 923 return RegisterNativesImpl(env); |
| 910 } | 924 } |
| OLD | NEW |