| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 447 |
| 448 // Don't try to scale too small icons. | 448 // Don't try to scale too small icons. |
| 449 if (width < 16 || height < 16) | 449 if (width < 16 || height < 16) |
| 450 return; | 450 return; |
| 451 | 451 |
| 452 // Profile avatars are supposed to be displayed with a circular mask, so apply | 452 // Profile avatars are supposed to be displayed with a circular mask, so apply |
| 453 // one. | 453 // one. |
| 454 gfx::Path circular_mask; | 454 gfx::Path circular_mask; |
| 455 gfx::Canvas canvas(icon.Size(), 1.0f, true); | 455 gfx::Canvas canvas(icon.Size(), 1.0f, true); |
| 456 canvas.FillRect(gfx::Rect(icon.Size()), SK_ColorTRANSPARENT, | 456 canvas.FillRect(gfx::Rect(icon.Size()), SK_ColorTRANSPARENT, |
| 457 SkXfermode::kClear_Mode); | 457 SkBlendMode::kClear); |
| 458 circular_mask.addCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2, | 458 circular_mask.addCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2, |
| 459 SkIntToScalar(std::min(width, height)) / 2); | 459 SkIntToScalar(std::min(width, height)) / 2); |
| 460 canvas.ClipPath(circular_mask, true); | 460 canvas.ClipPath(circular_mask, true); |
| 461 canvas.DrawImageInt(*icon.ToImageSkia(), 0, 0); | 461 canvas.DrawImageInt(*icon.ToImageSkia(), 0, 0); |
| 462 | 462 |
| 463 gfx::CalculateFaviconTargetSize(&width, &height); | 463 gfx::CalculateFaviconTargetSize(&width, &height); |
| 464 gfx::Image sized_icon = profiles::GetSizedAvatarIcon( | 464 gfx::Image sized_icon = profiles::GetSizedAvatarIcon( |
| 465 gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())), true, width, | 465 gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())), true, width, |
| 466 height); | 466 height); |
| 467 menu->SetIcon(menu->GetItemCount() - 1, sized_icon); | 467 menu->SetIcon(menu->GetItemCount() - 1, sized_icon); |
| (...skipping 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 void RenderViewContextMenu::PluginActionAt( | 2501 void RenderViewContextMenu::PluginActionAt( |
| 2502 const gfx::Point& location, | 2502 const gfx::Point& location, |
| 2503 const WebPluginAction& action) { | 2503 const WebPluginAction& action) { |
| 2504 source_web_contents_->GetRenderViewHost()-> | 2504 source_web_contents_->GetRenderViewHost()-> |
| 2505 ExecutePluginActionAtLocation(location, action); | 2505 ExecutePluginActionAtLocation(location, action); |
| 2506 } | 2506 } |
| 2507 | 2507 |
| 2508 Browser* RenderViewContextMenu::GetBrowser() const { | 2508 Browser* RenderViewContextMenu::GetBrowser() const { |
| 2509 return chrome::FindBrowserWithWebContents(embedder_web_contents_); | 2509 return chrome::FindBrowserWithWebContents(embedder_web_contents_); |
| 2510 } | 2510 } |
| OLD | NEW |