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()); |