Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chrome/browser/android/tab_android.cc

Issue 2216713002: Use BookmarkModelFactory::GetForBrowserContext everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks
Patch Set: Eliminate Profile::FromBrowserContext in some places Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) { 748 if (offline_pages::OfflinePageUtils::IsOfflinePage(profile, url)) {
749 url = offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL( 749 url = offline_pages::OfflinePageUtils::MaybeGetOnlineURLForOfflineURL(
750 profile, url); 750 profile, url);
751 } 751 }
752 752
753 // Get all the nodes for |url| and sort them by date added. 753 // Get all the nodes for |url| and sort them by date added.
754 std::vector<const bookmarks::BookmarkNode*> nodes; 754 std::vector<const bookmarks::BookmarkNode*> nodes;
755 bookmarks::ManagedBookmarkService* managed = 755 bookmarks::ManagedBookmarkService* managed =
756 ManagedBookmarkServiceFactory::GetForProfile(profile); 756 ManagedBookmarkServiceFactory::GetForProfile(profile);
757 bookmarks::BookmarkModel* model = 757 bookmarks::BookmarkModel* model =
758 BookmarkModelFactory::GetForProfile(profile); 758 BookmarkModelFactory::GetForBrowserContext(profile);
759 759
760 model->GetNodesByURL(url, &nodes); 760 model->GetNodesByURL(url, &nodes);
761 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); 761 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded);
762 762
763 // Return the first node matching the search criteria. 763 // Return the first node matching the search criteria.
764 for (size_t i = 0; i < nodes.size(); ++i) { 764 for (size_t i = 0; i < nodes.size(); ++i) {
765 if (only_editable && !managed->CanBeEditedByUser(nodes[i])) 765 if (only_editable && !managed->CanBeEditedByUser(nodes[i]))
766 continue; 766 continue;
767 return nodes[i]->id(); 767 return nodes[i]->id();
768 } 768 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 893 static void Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
894 TRACE_EVENT0("native", "TabAndroid::Init"); 894 TRACE_EVENT0("native", "TabAndroid::Init");
895 // This will automatically bind to the Java object and pass ownership there. 895 // This will automatically bind to the Java object and pass ownership there.
896 new TabAndroid(env, obj); 896 new TabAndroid(env, obj);
897 } 897 }
898 898
899 // static 899 // static
900 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) { 900 bool TabAndroid::RegisterTabAndroid(JNIEnv* env) {
901 return RegisterNativesImpl(env); 901 return RegisterNativesImpl(env);
902 } 902 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698