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

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

Issue 1124023004: [DevTools] Fix favicon images on chrome://inspect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
Index: chrome/browser/android/tab_android.cc
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index 7ea7eb6dc4dc62ec567ef3a8488282443d143c9c..4d207433d38b67c55dd51c951b1f49a927cfc407 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -7,6 +7,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
+#include "base/base64.h"
#include "base/metrics/histogram.h"
#include "base/trace_event/trace_event.h"
#include "cc/layers/layer.h"
@@ -76,6 +77,7 @@
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/android/device_display_info.h"
#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image_skia.h"
@@ -687,6 +689,33 @@ ScopedJavaLocalRef<jobject> TabAndroid::GetFavicon(JNIEnv* env,
return bitmap;
}
+GURL TabAndroid::GetFaviconURL() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> javaBitmap =
+ Java_Tab_getFavicon(env, weak_java_tab_.get(env).obj());
+ if (!javaBitmap.obj())
+ return GURL();
+
+ SkBitmap bitmap = gfx::CreateSkBitmapFromJavaBitmap(
+ gfx::JavaBitmap(javaBitmap.obj()));
+ std::vector<unsigned char> data;
+ SkAutoLockPixels lock_image(bitmap);
+ bool encoded = gfx::PNGCodec::Encode(
+ reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
+ gfx::PNGCodec::FORMAT_SkBitmap,
+ gfx::Size(bitmap.width(), bitmap.height()),
+ bitmap.width() * bitmap.bytesPerPixel(),
+ false, std::vector<gfx::PNGCodec::Comment>(), &data);
+ if (!encoded)
+ return GURL();
+
+ std::string base_64_data;
+ base::Base64Encode(
+ base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()),
+ &base_64_data);
+ return GURL("data:image/png;base64," + base_64_data);
michaelbai 2015/05/08 15:25:42 Should the png and URL encoding be in dev_tools_di
vkuzkokov 2015/05/12 12:16:46 Moved.
+}
+
prerender::PrerenderManager* TabAndroid::GetPrerenderManager() const {
Profile* profile = GetProfile();
if (!profile)
« chrome/browser/android/tab_android.h ('K') | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698