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

Unified Diff: chrome/browser/renderer_context_menu/render_view_context_menu.cc

Issue 1415413009: Use a circular profile icon in "open link as user" context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_context_menu/render_view_context_menu.cc
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index 7330cf235ae7ca0d0053819d1eb4418270005e12..ffe8270cbc239f9f6a7cc1ce34010aecf4e2140a 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -110,9 +110,11 @@
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/canvas.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/path.h"
#include "ui/gfx/text_elider.h"
#if defined(ENABLE_EXTENSIONS)
@@ -388,9 +390,21 @@ bool g_custom_id_ranges_initialized = false;
void AddIconToLastMenuItem(gfx::Image icon, ui::SimpleMenuModel* menu) {
int width = icon.Width();
int height = icon.Height();
+
+ // Profile avatars are supposed to be displayed with a circular mask, so apply
+ // one.
+ gfx::Path circular_mask;
+ gfx::Canvas canvas(icon.Size(), 1.0f, true);
+ circular_mask.addCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2,
+ SkIntToScalar(std::min(width, height)) / 2);
+ canvas.ClipPath(circular_mask, true);
+ canvas.DrawImageInt(*icon.ToImageSkia(), 0, 0);
+
gfx::CalculateFaviconTargetSize(&width, &height);
- menu->SetIcon(menu->GetItemCount() - 1,
- profiles::GetSizedAvatarIcon(icon, true, width, height));
+ gfx::Image sized_icon = profiles::GetSizedAvatarIcon(
+ gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())), true, width,
+ height);
+ menu->SetIcon(menu->GetItemCount() - 1, sized_icon);
}
void OnProfileCreated(chrome::HostDesktopType desktop_type,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698