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

Unified Diff: chrome/browser/ui/views/avatar_menu_button.cc

Issue 12212053: Moves calling TaskbarList::SetOverlayIcon to a separate thread. It (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 7 years, 10 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
Index: chrome/browser/ui/views/avatar_menu_button.cc
diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc
index bd3cb1c71a83c26f6f72cbb1301f4dd70e7bab67..3045ac850f3c7426dada0c97bebd9a2d612fbcf7 100644
--- a/chrome/browser/ui/views/avatar_menu_button.cc
+++ b/chrome/browser/ui/views/avatar_menu_button.cc
@@ -20,73 +20,10 @@
#include "ui/gfx/canvas.h"
#include "ui/views/widget/widget.h"
-
-#if defined(OS_WIN)
-#include <shobjidl.h>
-#include "base/win/scoped_comptr.h"
-#include "base/win/windows_version.h"
-#include "skia/ext/image_operations.h"
-#include "ui/gfx/icon_util.h"
-#endif
-
static inline int Round(double x) {
return static_cast<int>(x + 0.5);
}
-// The Windows 7 taskbar supports dynamic overlays and effects, we use this
-// to ovelay the avatar icon there. The overlay only applies if the taskbar
-// is in "default large icon mode". This function is a best effort deal so
-// we bail out silently at any error condition.
-// See http://msdn.microsoft.com/en-us/library/dd391696(VS.85).aspx for
-// more information.
-void DrawTaskBarDecoration(gfx::NativeWindow window, const gfx::Image* image) {
-#if defined(OS_WIN) && !defined(USE_AURA)
- if (base::win::GetVersion() < base::win::VERSION_WIN7)
- return;
-
- // SetOverlayIcon does nothing if the window is not visible so testing
- // here avoids all the wasted effort of the image resizing.
- if (!::IsWindowVisible(window))
- return;
-
- base::win::ScopedComPtr<ITaskbarList3> taskbar;
- HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL,
- CLSCTX_INPROC_SERVER);
- if (FAILED(result) || FAILED(taskbar->HrInit()))
- return;
- HICON icon = NULL;
- if (image) {
- const SkBitmap* bitmap = image->ToSkBitmap();
- const SkBitmap* source_bitmap = NULL;
- SkBitmap squarer_bitmap;
- if ((bitmap->width() == profiles::kAvatarIconWidth) &&
- (bitmap->height() == profiles::kAvatarIconHeight)) {
- // Shave a couple of columns so the bitmap is more square. So when
- // resized to a square aspect ratio it looks pretty.
- int x = 2;
- bitmap->extractSubset(&squarer_bitmap, SkIRect::MakeXYWH(x, 0,
- profiles::kAvatarIconWidth - x * 2, profiles::kAvatarIconHeight));
- source_bitmap = &squarer_bitmap;
- } else {
- // The image's size has changed. Resize what we have.
- source_bitmap = bitmap;
- }
- // Since the target size is so small, we use our best resizer. Never pass
- // windows a different size because it will badly hammer it to 16x16.
- SkBitmap sk_icon = skia::ImageOperations::Resize(
- *source_bitmap,
- skia::ImageOperations::RESIZE_LANCZOS3,
- 16, 16);
- icon = IconUtil::CreateHICONFromSkBitmap(sk_icon);
- if (!icon)
- return;
- }
- taskbar->SetOverlayIcon(window, icon, L"");
- if (icon)
- DestroyIcon(icon);
-#endif
-}
-
AvatarMenuButton::AvatarMenuButton(Browser* browser, bool incognito)
: MenuButton(NULL, string16(), this, false),
browser_(browser),
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_button.h ('k') | chrome/browser/ui/views/frame/browser_non_client_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698