OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" | 5 #include "chrome/browser/renderer_context_menu/render_view_context_menu.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 448 |
449 // Don't try to scale too small icons. | 449 // Don't try to scale too small icons. |
450 if (width < 16 || height < 16) | 450 if (width < 16 || height < 16) |
451 return; | 451 return; |
452 | 452 |
453 // Profile avatars are supposed to be displayed with a circular mask, so apply | 453 // Profile avatars are supposed to be displayed with a circular mask, so apply |
454 // one. | 454 // one. |
455 gfx::Path circular_mask; | 455 gfx::Path circular_mask; |
456 gfx::Canvas canvas(icon.Size(), 1.0f, true); | 456 gfx::Canvas canvas(icon.Size(), 1.0f, true); |
457 canvas.FillRect(gfx::Rect(icon.Size()), SK_ColorTRANSPARENT, | 457 canvas.FillRect(gfx::Rect(icon.Size()), SK_ColorTRANSPARENT, |
458 SkXfermode::kClear_Mode); | 458 SkBlendMode::kClear); |
459 circular_mask.addCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2, | 459 circular_mask.addCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2, |
460 SkIntToScalar(std::min(width, height)) / 2); | 460 SkIntToScalar(std::min(width, height)) / 2); |
461 canvas.ClipPath(circular_mask, true); | 461 canvas.ClipPath(circular_mask, true); |
462 canvas.DrawImageInt(*icon.ToImageSkia(), 0, 0); | 462 canvas.DrawImageInt(*icon.ToImageSkia(), 0, 0); |
463 | 463 |
464 gfx::CalculateFaviconTargetSize(&width, &height); | 464 gfx::CalculateFaviconTargetSize(&width, &height); |
465 gfx::Image sized_icon = profiles::GetSizedAvatarIcon( | 465 gfx::Image sized_icon = profiles::GetSizedAvatarIcon( |
466 gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())), true, width, | 466 gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())), true, width, |
467 height); | 467 height); |
468 menu->SetIcon(menu->GetItemCount() - 1, sized_icon); | 468 menu->SetIcon(menu->GetItemCount() - 1, sized_icon); |
(...skipping 2038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2507 void RenderViewContextMenu::PluginActionAt( | 2507 void RenderViewContextMenu::PluginActionAt( |
2508 const gfx::Point& location, | 2508 const gfx::Point& location, |
2509 const WebPluginAction& action) { | 2509 const WebPluginAction& action) { |
2510 source_web_contents_->GetRenderViewHost()-> | 2510 source_web_contents_->GetRenderViewHost()-> |
2511 ExecutePluginActionAtLocation(location, action); | 2511 ExecutePluginActionAtLocation(location, action); |
2512 } | 2512 } |
2513 | 2513 |
2514 Browser* RenderViewContextMenu::GetBrowser() const { | 2514 Browser* RenderViewContextMenu::GetBrowser() const { |
2515 return chrome::FindBrowserWithWebContents(embedder_web_contents_); | 2515 return chrome::FindBrowserWithWebContents(embedder_web_contents_); |
2516 } | 2516 } |
OLD | NEW |