Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 103 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 104 #include "extensions/browser/view_type_utils.h" | 104 #include "extensions/browser/view_type_utils.h" |
| 105 #include "extensions/common/extension.h" | 105 #include "extensions/common/extension.h" |
| 106 #include "net/base/escape.h" | 106 #include "net/base/escape.h" |
| 107 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 107 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| 108 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" | 108 #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
| 109 #include "third_party/WebKit/public/web/WebPluginAction.h" | 109 #include "third_party/WebKit/public/web/WebPluginAction.h" |
| 110 #include "ui/base/clipboard/clipboard.h" | 110 #include "ui/base/clipboard/clipboard.h" |
| 111 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 111 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 112 #include "ui/base/l10n/l10n_util.h" | 112 #include "ui/base/l10n/l10n_util.h" |
| 113 #include "ui/gfx/canvas.h" | |
| 113 #include "ui/gfx/favicon_size.h" | 114 #include "ui/gfx/favicon_size.h" |
| 114 #include "ui/gfx/geometry/point.h" | 115 #include "ui/gfx/geometry/point.h" |
| 115 #include "ui/gfx/geometry/size.h" | 116 #include "ui/gfx/geometry/size.h" |
| 117 #include "ui/gfx/path.h" | |
| 116 #include "ui/gfx/text_elider.h" | 118 #include "ui/gfx/text_elider.h" |
| 117 | 119 |
| 118 #if defined(ENABLE_EXTENSIONS) | 120 #if defined(ENABLE_EXTENSIONS) |
| 119 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" | 121 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" |
| 120 #endif | 122 #endif |
| 121 | 123 |
| 122 #if defined(ENABLE_PRINTING) | 124 #if defined(ENABLE_PRINTING) |
| 123 #include "chrome/browser/printing/print_view_manager_common.h" | 125 #include "chrome/browser/printing/print_view_manager_common.h" |
| 124 #include "components/printing/common/print_messages.h" | 126 #include "components/printing/common/print_messages.h" |
| 125 | 127 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 void WriteTextToClipboard(const base::string16& text) { | 383 void WriteTextToClipboard(const base::string16& text) { |
| 382 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); | 384 ui::ScopedClipboardWriter scw(ui::CLIPBOARD_TYPE_COPY_PASTE); |
| 383 scw.WriteText(text); | 385 scw.WriteText(text); |
| 384 } | 386 } |
| 385 | 387 |
| 386 bool g_custom_id_ranges_initialized = false; | 388 bool g_custom_id_ranges_initialized = false; |
| 387 | 389 |
| 388 void AddIconToLastMenuItem(gfx::Image icon, ui::SimpleMenuModel* menu) { | 390 void AddIconToLastMenuItem(gfx::Image icon, ui::SimpleMenuModel* menu) { |
| 389 int width = icon.Width(); | 391 int width = icon.Width(); |
| 390 int height = icon.Height(); | 392 int height = icon.Height(); |
| 393 gfx::Path circular_mask; | |
|
Bernhard Bauer
2015/10/27 09:44:14
Add a comment that explains what you do here?
| |
| 394 gfx::Canvas canvas(icon.Size(), 1.0f, true); | |
| 395 circular_mask.addCircle(SkIntToScalar(width) / 2, SkIntToScalar(height) / 2, | |
| 396 SkIntToScalar(std::min(width, height)) / 2); | |
| 397 canvas.ClipPath(circular_mask, true); | |
| 398 canvas.DrawImageInt(*icon.ToImageSkia(), 0, 0); | |
| 399 | |
| 391 gfx::CalculateFaviconTargetSize(&width, &height); | 400 gfx::CalculateFaviconTargetSize(&width, &height); |
| 392 menu->SetIcon(menu->GetItemCount() - 1, | 401 gfx::Image sized_icon = profiles::GetSizedAvatarIcon( |
| 393 profiles::GetSizedAvatarIcon(icon, true, width, height)); | 402 gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())), true, width, |
| 403 height); | |
| 404 menu->SetIcon(menu->GetItemCount() - 1, sized_icon); | |
| 394 } | 405 } |
| 395 | 406 |
| 396 void OnProfileCreated(chrome::HostDesktopType desktop_type, | 407 void OnProfileCreated(chrome::HostDesktopType desktop_type, |
| 397 const GURL& link_url, | 408 const GURL& link_url, |
| 398 const content::Referrer& referrer, | 409 const content::Referrer& referrer, |
| 399 Profile* profile, | 410 Profile* profile, |
| 400 Profile::CreateStatus status) { | 411 Profile::CreateStatus status) { |
| 401 if (status == Profile::CREATE_STATUS_INITIALIZED) { | 412 if (status == Profile::CREATE_STATUS_INITIALIZED) { |
| 402 Browser* browser = chrome::FindLastActiveWithProfile(profile, desktop_type); | 413 Browser* browser = chrome::FindLastActiveWithProfile(profile, desktop_type); |
| 403 chrome::NavigateParams nav_params(browser, link_url, | 414 chrome::NavigateParams nav_params(browser, link_url, |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2127 source_web_contents_->GetRenderViewHost()-> | 2138 source_web_contents_->GetRenderViewHost()-> |
| 2128 ExecuteMediaPlayerActionAtLocation(location, action); | 2139 ExecuteMediaPlayerActionAtLocation(location, action); |
| 2129 } | 2140 } |
| 2130 | 2141 |
| 2131 void RenderViewContextMenu::PluginActionAt( | 2142 void RenderViewContextMenu::PluginActionAt( |
| 2132 const gfx::Point& location, | 2143 const gfx::Point& location, |
| 2133 const WebPluginAction& action) { | 2144 const WebPluginAction& action) { |
| 2134 source_web_contents_->GetRenderViewHost()-> | 2145 source_web_contents_->GetRenderViewHost()-> |
| 2135 ExecutePluginActionAtLocation(location, action); | 2146 ExecutePluginActionAtLocation(location, action); |
| 2136 } | 2147 } |
| OLD | NEW |