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

Unified Diff: chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc

Issue 896093007: [Android] Open up API in jni bridge to fetch images from tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits fixes 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/enhanced_bookmarks/android/enhanced_bookmarks_bridge.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc
diff --git a/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc b/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc
index eadcae76c0445fef41133af2fa8a0302d15dfd04..ba6b942379e4ccfda1d75e40ba32d93dce2eb316 100644
--- a/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc
+++ b/chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.cc
@@ -8,6 +8,7 @@
#include "base/android/jni_string.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/enhanced_bookmarks/android/bookmark_image_service_android.h"
#include "chrome/browser/enhanced_bookmarks/android/bookmark_image_service_factory.h"
#include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service.h"
#include "chrome/browser/enhanced_bookmarks/chrome_bookmark_server_cluster_service_factory.h"
@@ -21,11 +22,11 @@
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/common/android/bookmark_id.h"
#include "components/bookmarks/common/android/bookmark_type.h"
-#include "components/enhanced_bookmarks/bookmark_image_service.h"
#include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
#include "components/enhanced_bookmarks/image_record.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/web_contents.h"
#include "jni/EnhancedBookmarksBridge_jni.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/image/image.h"
@@ -37,6 +38,7 @@ using bookmarks::android::JavaBookmarkIdGetId;
using bookmarks::android::JavaBookmarkIdGetType;
using bookmarks::BookmarkNode;
using bookmarks::BookmarkType;
+using content::WebContents;
using content::BrowserThread;
using enhanced_bookmarks::ImageRecord;
@@ -75,8 +77,8 @@ EnhancedBookmarksBridge::EnhancedBookmarksBridge(JNIEnv* env,
cluster_service_ =
ChromeBookmarkServerClusterServiceFactory::GetForBrowserContext(profile_);
cluster_service_->AddObserver(this);
- bookmark_image_service_ =
- BookmarkImageServiceFactory::GetForBrowserContext(profile_);
+ bookmark_image_service_ = static_cast<BookmarkImageServiceAndroid*>(
+ BookmarkImageServiceFactory::GetForBrowserContext(profile_));
search_service_.reset(new BookmarkServerSearchService(
profile_->GetRequestContext(),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
@@ -108,6 +110,14 @@ void EnhancedBookmarksBridge::SalientImageForUrl(JNIEnv* env,
url, base::Bind(&Callback, j_callback_ptr.release()));
}
+void EnhancedBookmarksBridge::FetchImageForTab(JNIEnv* env,
+ jobject obj,
+ jobject j_web_contents) {
+ WebContents* web_contents = WebContents::FromJavaWebContents(j_web_contents);
+ bookmark_image_service_->RetrieveSalientImageFromContext(
+ web_contents->GetMainFrame(), web_contents->GetURL(), true);
+}
+
ScopedJavaLocalRef<jstring> EnhancedBookmarksBridge::GetBookmarkDescription(
JNIEnv* env, jobject obj, jlong id, jint type) {
DCHECK(enhanced_bookmark_model_->loaded());
« no previous file with comments | « chrome/browser/enhanced_bookmarks/android/enhanced_bookmarks_bridge.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698