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

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

Issue 364793005: Implementation of GetFavicon for current tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Scaled favicon image to 16x16 size Created 6 years, 5 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 baa0a000cb2aeef6856c7b08386b17534184d8da..2c8553045d4f545065da94864d23b0576747a69f 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
+#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/google/google_url_tracker_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/prerender/prerender_contents.h"
@@ -46,7 +47,10 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "jni/Tab_jni.h"
+#include "skia/ext/image_operations.h"
#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
+#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/favicon_size.h"
TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(web_contents);
@@ -517,6 +521,30 @@ bool TabAndroid::Print(JNIEnv* env, jobject obj) {
return true;
}
+ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env, jobject obj) {
+ ScopedJavaLocalRef<jobject> bitmap;
+ FaviconTabHelper* favicon_tab_helper =
+ FaviconTabHelper::FromWebContents(web_contents_.get());
+ if (!favicon_tab_helper)
+ return bitmap;
+ if (!favicon_tab_helper->FaviconIsValid())
+ return bitmap;
+
+ SkBitmap favicon = favicon_tab_helper->GetFavicon().AsBitmap();
+
+ if (!favicon.isNull()) {
+ if (favicon.width() != gfx::kFaviconSize ||
+ favicon.height() != gfx::kFaviconSize)
+ favicon =
+ skia::ImageOperations::Resize(favicon,
+ skia::ImageOperations::RESIZE_BEST,
+ gfx::kFaviconSize,
+ gfx::kFaviconSize);
+ bitmap = gfx::ConvertToJavaBitmap(&favicon);
David Trainor- moved to gerrit 2014/07/09 20:34:51 I think this is still incorrect. It looks like yo
+ }
+ return bitmap;
+}
+
prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const {
Profile* profile = GetProfile();
if (!profile)
« 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