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

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: Replace in .mm files 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/android/signin/signin_manager_android.cc ('k') | chrome/browser/app_controller_mac_browsertest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698