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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) { | 749 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) { |
750 url = offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( | 750 url = offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( |
751 profile, url); | 751 profile, url); |
752 } | 752 } |
753 | 753 |
754 // Get all the nodes for |url| and sort them by date added. | 754 // Get all the nodes for |url| and sort them by date added. |
755 std::vector<const bookmarks::BookmarkNode*> nodes; | 755 std::vector<const bookmarks::BookmarkNode*> nodes; |
756 bookmarks::ManagedBookmarkService* managed = | 756 bookmarks::ManagedBookmarkService* managed = |
757 ManagedBookmarkServiceFactory::GetForProfile(profile); | 757 ManagedBookmarkServiceFactory::GetForProfile(profile); |
758 bookmarks::BookmarkModel* model = | 758 bookmarks::BookmarkModel* model = |
759 BookmarkModelFactory::GetForProfile(profile); | 759 BookmarkModelFactory::GetForBrowserContext(profile); |
760 | 760 |
761 model->GetNodesByURL(url, &nodes); | 761 model->GetNodesByURL(url, &nodes); |
762 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); | 762 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); |
763 | 763 |
764 // Return the first node matching the search criteria. | 764 // Return the first node matching the search criteria. |
765 for (size_t i = 0; i < nodes.size(); ++i) { | 765 for (size_t i = 0; i < nodes.size(); ++i) { |
766 if (only_editable && !managed->CanBeEditedByUser(nodes[i])) | 766 if (only_editable && !managed->CanBeEditedByUser(nodes[i])) |
767 continue; | 767 continue; |
768 return nodes[i]->id(); | 768 return nodes[i]->id(); |
769 } | 769 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 894 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
895 TRACE_EVENT0("native", "TabAndroid::Init"); | 895 TRACE_EVENT0("native", "TabAndroid::Init"); |
896 // This will automatically bind to the Java object and pass ownership there. | 896 // This will automatically bind to the Java object and pass ownership there. |
897 new TabAndroid(env, obj); | 897 new TabAndroid(env, obj); |
898 } | 898 } |
899 | 899 |
900 // static | 900 // static |
901 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { | 901 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { |
902 return RegisterNativesImpl(env); | 902 return RegisterNativesImpl(env); |
903 } | 903 } |
OLD | NEW |