OLD | NEW |
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/profile_menu_model.h" | 8 #include "chrome/browser/ui/profile_menu_model.h" |
9 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" | 9 #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" |
10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // The Windows 7 taskbar supports dynamic overlays and effects, we use this | 27 // The Windows 7 taskbar supports dynamic overlays and effects, we use this |
28 // to ovelay the avatar icon there. The overlay only applies if the taskbar | 28 // to ovelay the avatar icon there. The overlay only applies if the taskbar |
29 // is in "default large icon mode". This function is a best effort deal so | 29 // is in "default large icon mode". This function is a best effort deal so |
30 // we bail out silently at any error condition. | 30 // we bail out silently at any error condition. |
31 // See http://msdn.microsoft.com/en-us/library/dd391696(VS.85).aspx for | 31 // See http://msdn.microsoft.com/en-us/library/dd391696(VS.85).aspx for |
32 // more information. | 32 // more information. |
33 void DrawTaskBarDecoration(const Browser* browser, const SkBitmap* bitmap) { | 33 void DrawTaskBarDecoration(const Browser* browser, const SkBitmap* bitmap) { |
34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
35 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 35 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
36 return; | 36 return; |
| 37 // During destruction of the browser frame, we might not have a window |
| 38 // so the taksbar button will be removed by windows anyway. |
| 39 BrowserWindow* bw = browser->window(); |
| 40 if (!bw) |
| 41 return; |
| 42 gfx::NativeWindow window = bw->GetNativeHandle(); |
| 43 if (!window) |
| 44 return; |
37 | 45 |
38 base::win::ScopedComPtr<ITaskbarList3> taskbar; | 46 base::win::ScopedComPtr<ITaskbarList3> taskbar; |
39 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL, | 47 HRESULT result = taskbar.CreateInstance(CLSID_TaskbarList, NULL, |
40 CLSCTX_INPROC_SERVER); | 48 CLSCTX_INPROC_SERVER); |
41 if (FAILED(result) || FAILED(taskbar->HrInit())) | 49 if (FAILED(result) || FAILED(taskbar->HrInit())) |
42 return; | 50 return; |
43 gfx::NativeWindow window = browser->window()->GetNativeHandle(); | |
44 if (!window) | |
45 return; | |
46 HICON icon = NULL; | 51 HICON icon = NULL; |
47 if (bitmap) { | 52 if (bitmap) { |
48 // Since the target size is so small, we use our best resizer. | 53 // Since the target size is so small, we use our best resizer. |
49 SkBitmap sk_icon = skia::ImageOperations::Resize( | 54 SkBitmap sk_icon = skia::ImageOperations::Resize( |
50 *bitmap, | 55 *bitmap, |
51 skia::ImageOperations::RESIZE_LANCZOS3, | 56 skia::ImageOperations::RESIZE_LANCZOS3, |
52 16, 16); | 57 16, 16); |
53 icon = IconUtil::CreateHICONFromSkBitmap(sk_icon); | 58 icon = IconUtil::CreateHICONFromSkBitmap(sk_icon); |
54 if (!icon) | 59 if (!icon) |
55 return; | 60 return; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 views::View::ConvertPointToScreen(this, &origin); | 136 views::View::ConvertPointToScreen(this, &origin); |
132 gfx::Rect bounds(0, 0, width(), height()); | 137 gfx::Rect bounds(0, 0, width(), height()); |
133 bounds.set_origin(origin); | 138 bounds.set_origin(origin); |
134 | 139 |
135 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_); | 140 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_); |
136 // Bubble::Show() takes ownership of the view. | 141 // Bubble::Show() takes ownership of the view. |
137 Bubble::Show(browser_view->GetWidget(), bounds, | 142 Bubble::Show(browser_view->GetWidget(), bounds, |
138 views::BubbleBorder::TOP_LEFT, | 143 views::BubbleBorder::TOP_LEFT, |
139 bubble_view, bubble_view); | 144 bubble_view, bubble_view); |
140 } | 145 } |
OLD | NEW |