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

Unified Diff: chrome/browser/ui/webui/web_ui_util.cc

Issue 10532048: [cros] Initial WebRTC-enabled implementation of user image picker on OOBE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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/ui/webui/web_ui_util.cc
diff --git a/chrome/browser/ui/webui/web_ui_util.cc b/chrome/browser/ui/webui/web_ui_util.cc
index 160ba0affe917651847c838cf8d3687689d815d8..81456080658352f08abdaba6b3d870a5f0d4ad9a 100644
--- a/chrome/browser/ui/webui/web_ui_util.cc
+++ b/chrome/browser/ui/webui/web_ui_util.cc
@@ -11,6 +11,8 @@
#include "base/memory/ref_counted_memory.h"
#include "base/values.h"
#include "chrome/browser/disposition_utils.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/data_url.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/codec/png_codec.h"
@@ -46,6 +48,26 @@ std::string GetImageDataUrlFromResource(int res) {
return str_url;
}
+gfx::ImageSkia GetImageFromDataUrl(const std::string& data_url) {
+ std::string mime_type, charset, raw_data;
+ if (!net::DataURL::Parse(GURL(data_url), &mime_type, &charset, &raw_data)) {
+ LOG(ERROR) << "Invalid data URL: " << data_url;
+ return gfx::ImageSkia();
+ }
+ if (mime_type != "image/png") {
+ LOG(WARNING) << "Data URL MIME type not supported: " << mime_type;
+ return gfx::ImageSkia();
+ }
+ SkBitmap image;
+ if (!gfx::PNGCodec::Decode(
+ reinterpret_cast<const unsigned char*>(raw_data.data()),
+ raw_data.size(), &image)) {
+ LOG(ERROR) << "Invalid image in data URL: " << data_url;
+ return gfx::ImageSkia();
+ }
+ return gfx::ImageSkia(image);
+}
+
WindowOpenDisposition GetDispositionFromClick(const ListValue* args,
int start_index) {
double button = 0.0;

Powered by Google App Engine
This is Rietveld 408576698