| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 render_frame_host->GetRoutingID())); | 776 render_frame_host->GetRoutingID())); |
| 777 } | 777 } |
| 778 | 778 |
| 779 jlong TabAndroid::GetBookmarkId(JNIEnv* env, | 779 jlong TabAndroid::GetBookmarkId(JNIEnv* env, |
| 780 const JavaParamRef<jobject>& obj, | 780 const JavaParamRef<jobject>& obj, |
| 781 jboolean only_editable) { | 781 jboolean only_editable) { |
| 782 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( | 782 GURL url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( |
| 783 web_contents()->GetURL()); | 783 web_contents()->GetURL()); |
| 784 Profile* profile = GetProfile(); | 784 Profile* profile = GetProfile(); |
| 785 | 785 |
| 786 // If the url points to an offline page, then we need to get its original URL. | |
| 787 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) { | |
| 788 url = offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( | |
| 789 profile, url); | |
| 790 } | |
| 791 | |
| 792 // Get all the nodes for |url| and sort them by date added. | 786 // Get all the nodes for |url| and sort them by date added. |
| 793 std::vector<const bookmarks::BookmarkNode*> nodes; | 787 std::vector<const bookmarks::BookmarkNode*> nodes; |
| 794 bookmarks::ManagedBookmarkService* managed = | 788 bookmarks::ManagedBookmarkService* managed = |
| 795 ManagedBookmarkServiceFactory::GetForProfile(profile); | 789 ManagedBookmarkServiceFactory::GetForProfile(profile); |
| 796 bookmarks::BookmarkModel* model = | 790 bookmarks::BookmarkModel* model = |
| 797 BookmarkModelFactory::GetForBrowserContext(profile); | 791 BookmarkModelFactory::GetForBrowserContext(profile); |
| 798 | 792 |
| 799 model->GetNodesByURL(url, &nodes); | 793 model->GetNodesByURL(url, &nodes); |
| 800 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); | 794 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); |
| 801 | 795 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 882 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 889 TRACE_EVENT0("native", "TabAndroid::Init"); | 883 TRACE_EVENT0("native", "TabAndroid::Init"); |
| 890 // This will automatically bind to the Java object and pass ownership there. | 884 // This will automatically bind to the Java object and pass ownership there. |
| 891 new TabAndroid(env, obj); | 885 new TabAndroid(env, obj); |
| 892 } | 886 } |
| 893 | 887 |
| 894 // static | 888 // static |
| 895 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 889 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
| 896 return RegisterNativesImpl(env); | 890 return RegisterNativesImpl(env); |
| 897 } | 891 } |
| OLD | NEW |