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

Side by Side Diff: chrome/browser/ui/views/avatar_menu_button.cc

Issue 8141005: Multi-profile: Fix the avatar menu button on the windows taskbar (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/views/avatar_menu_button.h" 5 #include "chrome/browser/ui/views/avatar_menu_button.h"
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" 8 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "ui/gfx/canvas_skia.h" 10 #include "ui/gfx/canvas_skia.h"
(...skipping 29 matching lines...) Expand all
40 if (!window) 40 if (!window)
41 return; 41 return;
42 42
43 base::win::ScopedComPtr<ITaskbarList3> taskbar; 43 base::win::ScopedComPtr<ITaskbarList3> taskbar;
44 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL, 44 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL,
45 CLSCTX_INPROC_SERVER); 45 CLSCTX_INPROC_SERVER);
46 if (FAILED(result) || FAILED(taskbar->HrInit())) 46 if (FAILED(result) || FAILED(taskbar->HrInit()))
47 return; 47 return;
48 HICON icon = NULL; 48 HICON icon = NULL;
49 if (bitmap) { 49 if (bitmap) {
50 // Since the target size is so small, we use our best resizer. 50 const SkBitmap* source_bitmap = NULL;
51 SkBitmap squarer_bitmap;
52 if ((bitmap->width() == 38) && (bitmap->height() == 31)) {
53 // Shave a couple of columns so the bitmap is more square. So when
54 // resized to a square aspect ratio it looks pretty.
55 bitmap->extractSubset(&squarer_bitmap, SkIRect::MakeXYWH(2, 0, 34, 31));
56 source_bitmap = &squarer_bitmap;
57 } else {
58 // The bitmaps size has changed. Resize what we have.
59 source_bitmap = bitmap;
60 }
61 // Since the target size is so small, we use our best resizer. Never pass
62 // windows a different size because it will badly hammer it to 16x16.
51 SkBitmap sk_icon = skia::ImageOperations::Resize( 63 SkBitmap sk_icon = skia::ImageOperations::Resize(
52 *bitmap, 64 *source_bitmap,
53 skia::ImageOperations::RESIZE_LANCZOS3, 65 skia::ImageOperations::RESIZE_LANCZOS3,
54 16, 16); 66 16, 16);
55 icon = IconUtil::CreateHICONFromSkBitmap(sk_icon); 67 icon = IconUtil::CreateHICONFromSkBitmap(sk_icon);
56 if (!icon) 68 if (!icon)
57 return; 69 return;
58 } 70 }
59 taskbar->SetOverlayIcon(window, icon, L""); 71 taskbar->SetOverlayIcon(window, icon, L"");
60 if (icon) 72 if (icon)
61 DestroyIcon(icon); 73 DestroyIcon(icon);
62 #endif 74 #endif
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Bubble::Show() takes ownership of the view. 155 // Bubble::Show() takes ownership of the view.
144 bubble_ = Bubble::Show(browser_view->GetWidget(), bounds, 156 bubble_ = Bubble::Show(browser_view->GetWidget(), bounds,
145 views::BubbleBorder::TOP_LEFT, bubble_view, bubble_view); 157 views::BubbleBorder::TOP_LEFT, bubble_view, bubble_view);
146 bubble_->AddObserver(this); 158 bubble_->AddObserver(this);
147 } 159 }
148 160
149 void AvatarMenuButton::OnBubbleClosing() { 161 void AvatarMenuButton::OnBubbleClosing() {
150 bubble_->RemoveObserver(this); 162 bubble_->RemoveObserver(this);
151 bubble_ = NULL; 163 bubble_ = NULL;
152 } 164 }
OLDNEW
« 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