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

Unified Diff: chrome/browser/ui/webui/options/personal_options_handler.cc

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 1 month 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/ui/webui/options/manage_profile_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/personal_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/personal_options_handler.cc b/chrome/browser/ui/webui/options/personal_options_handler.cc
index 281dfc2173391c3a5c3d2378f9127a58be1e9b8d..877220ebc00ab61be65cec6dac71e1d91c21e026 100644
--- a/chrome/browser/ui/webui/options/personal_options_handler.cc
+++ b/chrome/browser/ui/webui/options/personal_options_handler.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -51,6 +52,18 @@
#include "chrome/browser/ui/gtk/gtk_theme_service.h"
#endif // defined(TOOLKIT_GTK)
+#include "skia/ext/image_operations.h"
+#include "ui/gfx/canvas_skia.h"
+
+SkBitmap FixGAIABmp(const SkBitmap& bmp) {
+ SkBitmap rimage = skia::ImageOperations::Resize(
+ bmp, skia::ImageOperations::RESIZE_BEST, 29, 29);
+
+ gfx::CanvasSkia canvas(38, 31, false);
+ canvas.DrawBitmapInt(rimage, 4, 1);
+ return canvas.ExtractBitmap();
+}
+
PersonalOptionsHandler::PersonalOptionsHandler() {
multiprofile_ = ProfileManager::IsMultipleProfilesEnabled();
#if defined(OS_CHROMEOS)
@@ -408,11 +421,20 @@ void PersonalOptionsHandler::SendProfilesInfo() {
web_ui_->tab_contents()->browser_context()->GetPath();
for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
DictionaryValue* profile_value = new DictionaryValue();
- size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i));
- profile_value->SetString("iconURL",
- cache.GetDefaultAvatarIconUrl(icon_index));
+
+ std::string bmp_url;
+ if (!cache.IsUsingCustomAvatarIconForProfileAtIndex(i)) {
+ size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
+ bmp_url = cache.GetDefaultAvatarIconUrl(icon_index);
+ } else {
+ SkBitmap bmp = cache.GetGAIAPictureOfProfileAtIndex(i);
+ SkBitmap bmp2 = FixGAIABmp(bmp);
+ bmp_url = web_ui_util::GetImageDataUrl(bmp2);
+ }
+ profile_value->SetString("iconURL", bmp_url);
+
profile_value->Set("filePath", base::CreateFilePathValue(profile_path));
profile_value->SetBoolean("isCurrentProfile",
profile_path == current_profile_path);
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698