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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 using base::android::AttachCurrentThread; | 88 using base::android::AttachCurrentThread; |
89 using base::android::ConvertUTF8ToJavaString; | 89 using base::android::ConvertUTF8ToJavaString; |
90 using base::android::ToJavaByteArray; | 90 using base::android::ToJavaByteArray; |
91 using content::BrowserThread; | 91 using content::BrowserThread; |
92 using content::GlobalRequestID; | 92 using content::GlobalRequestID; |
93 using content::NavigationController; | 93 using content::NavigationController; |
94 using content::WebContents; | 94 using content::WebContents; |
95 using navigation_interception::InterceptNavigationDelegate; | 95 using navigation_interception::InterceptNavigationDelegate; |
96 using navigation_interception::NavigationParams; | 96 using navigation_interception::NavigationParams; |
97 | 97 |
98 namespace { | |
99 | |
100 const int kImageSearchThumbnailMinSize = 300 * 300; | |
101 const int kImageSearchThumbnailMaxWidth = 600; | |
102 const int kImageSearchThumbnailMaxHeight = 600; | |
103 | |
104 } // namespace | |
105 | |
106 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { | 98 TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) { |
107 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); | 99 CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents); |
108 if (!core_tab_helper) | 100 if (!core_tab_helper) |
109 return NULL; | 101 return NULL; |
110 | 102 |
111 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); | 103 CoreTabHelperDelegate* core_delegate = core_tab_helper->delegate(); |
112 if (!core_delegate) | 104 if (!core_delegate) |
113 return NULL; | 105 return NULL; |
114 | 106 |
115 return static_cast<TabAndroid*>(core_delegate); | 107 return static_cast<TabAndroid*>(core_delegate); |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 } | 745 } |
754 } | 746 } |
755 | 747 |
756 void TabAndroid::LoadOriginalImage(JNIEnv* env, jobject obj) { | 748 void TabAndroid::LoadOriginalImage(JNIEnv* env, jobject obj) { |
757 content::RenderFrameHost* render_frame_host = | 749 content::RenderFrameHost* render_frame_host = |
758 web_contents()->GetFocusedFrame(); | 750 web_contents()->GetFocusedFrame(); |
759 render_frame_host->Send(new ChromeViewMsg_RequestReloadImageForContextNode( | 751 render_frame_host->Send(new ChromeViewMsg_RequestReloadImageForContextNode( |
760 render_frame_host->GetRoutingID())); | 752 render_frame_host->GetRoutingID())); |
761 } | 753 } |
762 | 754 |
763 void TabAndroid::SearchByImageInNewTabAsync(JNIEnv* env, jobject obj) { | |
764 content::RenderFrameHost* render_frame_host = | |
765 web_contents()->GetMainFrame(); | |
766 render_frame_host->Send( | |
767 new ChromeViewMsg_RequestThumbnailForContextNode( | |
768 render_frame_host->GetRoutingID(), | |
769 kImageSearchThumbnailMinSize, | |
770 gfx::Size(kImageSearchThumbnailMaxWidth, | |
771 kImageSearchThumbnailMaxHeight))); | |
772 } | |
773 | |
774 jlong TabAndroid::GetBookmarkId(JNIEnv* env, | 755 jlong TabAndroid::GetBookmarkId(JNIEnv* env, |
775 jobject obj, | 756 jobject obj, |
776 jboolean only_editable) { | 757 jboolean only_editable) { |
777 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( | 758 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( |
778 web_contents()->GetURL()); | 759 web_contents()->GetURL()); |
779 Profile* profile = GetProfile(); | 760 Profile* profile = GetProfile(); |
780 | 761 |
781 // If the url points to an offline page, replace it with the original url. | 762 // If the url points to an offline page, replace it with the original url. |
782 const offline_pages::OfflinePageItem* offline_page = GetOfflinePage(url); | 763 const offline_pages::OfflinePageItem* offline_page = GetOfflinePage(url); |
783 if (offline_page) | 764 if (offline_page) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 909 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
929 TRACE_EVENT0("native", "TabAndroid::Init"); | 910 TRACE_EVENT0("native", "TabAndroid::Init"); |
930 // This will automatically bind to the Java object and pass ownership there. | 911 // This will automatically bind to the Java object and pass ownership there. |
931 new TabAndroid(env, obj); | 912 new TabAndroid(env, obj); |
932 } | 913 } |
933 | 914 |
934 // static | 915 // static |
935 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 916 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
936 return RegisterNativesImpl(env); | 917 return RegisterNativesImpl(env); |
937 } | 918 } |
OLD | NEW |