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

Unified Diff: chrome/browser/android/tab_android.cc

Issue 943643002: Pull up get{User,}BookmarkId from ChromeTab to Tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix indent Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index ed5094f94f9f08d7c1153d65fb4dcac1a2020199..f1cf821a2e1bb5894f365a19bb7478b10d605f10 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -13,6 +13,9 @@
#include "chrome/browser/android/chrome_web_contents_delegate_android.h"
#include "chrome/browser/android/compositor/tab_content_manager.h"
#include "chrome/browser/android/uma_utils.h"
+#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/bookmarks/chrome_bookmark_client.h"
+#include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
@@ -46,6 +49,10 @@
#include "chrome/common/instant_types.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
+#include "components/bookmarks/browser/bookmark_model.h"
+#include "components/bookmarks/browser/bookmark_node.h"
+#include "components/bookmarks/browser/bookmark_utils.h"
+#include "components/dom_distiller/core/url_utils.h"
#include "components/infobars/core/infobar_container.h"
#include "components/navigation_interception/intercept_navigation_delegate.h"
#include "components/navigation_interception/navigation_params.h"
@@ -730,6 +737,32 @@ void TabAndroid::SearchByImageInNewTabAsync(JNIEnv* env, jobject obj) {
kImageSearchThumbnailMaxHeight)));
}
+jlong TabAndroid::GetBookmarkId(JNIEnv* env,
+ jobject obj,
+ jboolean only_editable) {
+ const GURL& url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(
+ web_contents()->GetURL());
+ Profile* profile = GetProfile();
+
+ // Get all the nodes for |url| and sort them by date added.
+ std::vector<const bookmarks::BookmarkNode*> nodes;
+ ChromeBookmarkClient* client =
+ ChromeBookmarkClientFactory::GetForProfile(profile);
+ bookmarks::BookmarkModel* model =
+ BookmarkModelFactory::GetForProfile(profile);
+ model->GetNodesByURL(url, &nodes);
+ std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded);
+
+ // Return the first node matching the search criteria.
+ for (size_t i = 0; i < nodes.size(); ++i) {
+ if (only_editable && !client->CanBeEditedByUser(nodes[i]))
+ continue;
+ return nodes[i]->id();
+ }
+
+ return -1;
+}
+
namespace {
class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698