| 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" |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 | 756 |
| 757 jlong TabAndroid::GetBookmarkId(JNIEnv* env, | 757 jlong TabAndroid::GetBookmarkId(JNIEnv* env, |
| 758 const JavaParamRef<jobject>& obj, | 758 const JavaParamRef<jobject>& obj, |
| 759 jboolean only_editable) { | 759 jboolean only_editable) { |
| 760 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( | 760 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( |
| 761 web_contents()->GetURL()); | 761 web_contents()->GetURL()); |
| 762 Profile* profile = GetProfile(); | 762 Profile* profile = GetProfile(); |
| 763 | 763 |
| 764 // If the url points to an offline page, then we need to get its original URL. | 764 // If the url points to an offline page, then we need to get its original URL. |
| 765 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) { | 765 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) { |
| 766 url = offline_pages::OfflinePageUtils::GetOnlineURLForOfflineURL(profile, | 766 url = offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( |
| 767 url); | 767 profile, url); |
| 768 } | 768 } |
| 769 | 769 |
| 770 // Get all the nodes for |url| and sort them by date added. | 770 // Get all the nodes for |url| and sort them by date added. |
| 771 std::vector<const bookmarks::BookmarkNode*> nodes; | 771 std::vector<const bookmarks::BookmarkNode*> nodes; |
| 772 bookmarks::ManagedBookmarkService* managed = | 772 bookmarks::ManagedBookmarkService* managed = |
| 773 ManagedBookmarkServiceFactory::GetForProfile(profile); | 773 ManagedBookmarkServiceFactory::GetForProfile(profile); |
| 774 bookmarks::BookmarkModel* model = | 774 bookmarks::BookmarkModel* model = |
| 775 BookmarkModelFactory::GetForProfile(profile); | 775 BookmarkModelFactory::GetForProfile(profile); |
| 776 | 776 |
| 777 model->GetNodesByURL(url, &nodes); | 777 model->GetNodesByURL(url, &nodes); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 web_contents()->GetURL()); | 812 web_contents()->GetURL()); |
| 813 return offline_pages::OfflinePageUtils::IsOfflinePage(GetProfile(), url); | 813 return offline_pages::OfflinePageUtils::IsOfflinePage(GetProfile(), url); |
| 814 } | 814 } |
| 815 | 815 |
| 816 ScopedJavaLocalRef<jstring> TabAndroid::GetOfflinePageOriginalUrl( | 816 ScopedJavaLocalRef<jstring> TabAndroid::GetOfflinePageOriginalUrl( |
| 817 JNIEnv* env, | 817 JNIEnv* env, |
| 818 const JavaParamRef<jobject>& obj) { | 818 const JavaParamRef<jobject>& obj) { |
| 819 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( | 819 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( |
| 820 web_contents()->GetURL()); | 820 web_contents()->GetURL()); |
| 821 GURL original_url = | 821 GURL original_url = |
| 822 offline_pages::OfflinePageUtils::GetOnlineURLForOfflineURL(GetProfile(), | 822 offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( |
| 823 url); | 823 GetProfile(), url); |
| 824 if (!original_url.is_valid()) | 824 if (!original_url.is_valid()) |
| 825 return ScopedJavaLocalRef<jstring>(); | 825 return ScopedJavaLocalRef<jstring>(); |
| 826 | 826 |
| 827 return ScopedJavaLocalRef<jstring>( | 827 return ScopedJavaLocalRef<jstring>( |
| 828 ConvertUTF8ToJavaString(env, original_url.spec())); | 828 ConvertUTF8ToJavaString(env, original_url.spec())); |
| 829 } | 829 } |
| 830 | 830 |
| 831 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, | 831 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, |
| 832 const JavaParamRef<jobject>& obj, | 832 const JavaParamRef<jobject>& obj, |
| 833 const JavaParamRef<jstring>& url) { | 833 const JavaParamRef<jstring>& url) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 910 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 911 TRACE_EVENT0("native", "TabAndroid::Init"); | 911 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 912 // This will automatically bind to the Java object and pass ownership there. | 912 // This will automatically bind to the Java object and pass ownership there. |
| 913 new TabAndroid(env, obj); | 913 new TabAndroid(env, obj); |
| 914 } | 914 } |
| 915 | 915 |
| 916 // static | 916 // static |
| 917 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 917 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 918 return RegisterNativesImpl(env); | 918 return RegisterNativesImpl(env); |
| 919 } | 919 } |
| OLD | NEW |