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

Side by Side Diff: chrome/browser/ui/views/frame/glass_browser_frame_view.cc

Issue 772533002: Fix icon on Windows XP taskbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some doc + git cl format Created 6 years 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
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.cc ('k') | ui/gfx/win/window_impl.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/frame/glass_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/signin/signin_header_helper.h" 13 #include "chrome/browser/signin/signin_header_helper.h"
14 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 15 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
18 #include "chrome/browser/ui/views/tabs/tab.h" 18 #include "chrome/browser/ui/views/tabs/tab.h"
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" 19 #include "chrome/browser/ui/views/tabs/tab_strip.h"
20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
21 #include "components/signin/core/common/profile_management_switches.h" 21 #include "components/signin/core/common/profile_management_switches.h"
22 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "skia/ext/image_operations.h"
24 #include "ui/base/resource/resource_bundle_win.h" 25 #include "ui/base/resource/resource_bundle_win.h"
25 #include "ui/base/theme_provider.h" 26 #include "ui/base/theme_provider.h"
26 #include "ui/gfx/canvas.h" 27 #include "ui/gfx/canvas.h"
27 #include "ui/gfx/icon_util.h" 28 #include "ui/gfx/icon_util.h"
28 #include "ui/gfx/image/image.h" 29 #include "ui/gfx/image/image.h"
29 #include "ui/gfx/win/dpi.h" 30 #include "ui/gfx/win/dpi.h"
30 #include "ui/resources/grit/ui_resources.h" 31 #include "ui/resources/grit/ui_resources.h"
31 #include "ui/views/controls/label.h" 32 #include "ui/views/controls/label.h"
32 #include "ui/views/layout/layout_constants.h" 33 #include "ui/views/layout/layout_constants.h"
33 #include "ui/views/win/hwnd_util.h" 34 #include "ui/views/win/hwnd_util.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // so we stop it when the gap between the two is down to 5 px. 66 // so we stop it when the gap between the two is down to 5 px.
66 const int kNewTabCaptionRestoredSpacing = 5; 67 const int kNewTabCaptionRestoredSpacing = 5;
67 // In maximized mode, where the New Tab button and the caption buttons are at 68 // In maximized mode, where the New Tab button and the caption buttons are at
68 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid 69 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid
69 // looking too cluttered. 70 // looking too cluttered.
70 const int kNewTabCaptionMaximizedSpacing = 16; 71 const int kNewTabCaptionMaximizedSpacing = 16;
71 // How far to indent the tabstrip from the left side of the screen when there 72 // How far to indent the tabstrip from the left side of the screen when there
72 // is no avatar icon. 73 // is no avatar icon.
73 const int kTabStripIndent = -6; 74 const int kTabStripIndent = -6;
74 75
76 // Converts the |image| to a Windows icon and returns the corresponding HICON
77 // handle. |image| is resized to desired |width| and |height| if needed.
78 HICON CreateHICONFromSkBitmapSizedTo(const gfx::ImageSkia& image,
79 int width,
80 int height) {
81 if (width == image.width() && height == image.height())
82 return IconUtil::CreateHICONFromSkBitmap(*image.bitmap());
83 return IconUtil::CreateHICONFromSkBitmap(skia::ImageOperations::Resize(
84 *image.bitmap(), skia::ImageOperations::RESIZE_BEST, width, height));
85 }
86
75 } // namespace 87 } // namespace
76 88
77 /////////////////////////////////////////////////////////////////////////////// 89 ///////////////////////////////////////////////////////////////////////////////
78 // GlassBrowserFrameView, public: 90 // GlassBrowserFrameView, public:
79 91
80 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, 92 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
81 BrowserView* browser_view) 93 BrowserView* browser_view)
82 : BrowserNonClientFrameView(frame, browser_view), 94 : BrowserNonClientFrameView(frame, browser_view),
83 throbber_running_(false), 95 throbber_running_(false),
84 throbber_frame_(0) { 96 throbber_frame_(0) {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, 544 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
533 static_cast<WPARAM>(ICON_SMALL), 545 static_cast<WPARAM>(ICON_SMALL),
534 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); 546 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
535 } 547 }
536 } 548 }
537 549
538 void GlassBrowserFrameView::StopThrobber() { 550 void GlassBrowserFrameView::StopThrobber() {
539 if (throbber_running_) { 551 if (throbber_running_) {
540 throbber_running_ = false; 552 throbber_running_ = false;
541 553
542 HICON frame_icon = nullptr; 554 HICON small_icon = nullptr;
555 HICON big_icon = nullptr;
543 556
544 // Check if hosted BrowserView has a window icon to use. 557 // Check if hosted BrowserView has a window icon to use.
545 if (browser_view()->ShouldShowWindowIcon()) { 558 if (browser_view()->ShouldShowWindowIcon()) {
546 gfx::ImageSkia icon = browser_view()->GetWindowIcon(); 559 gfx::ImageSkia icon = browser_view()->GetWindowIcon();
547 if (!icon.isNull()) 560 if (!icon.isNull()) {
548 frame_icon = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap()); 561 small_icon = CreateHICONFromSkBitmapSizedTo(
562 icon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
563 big_icon = CreateHICONFromSkBitmapSizedTo(
564 icon, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
565 }
549 } 566 }
550 567
551 // Fallback to class icon. 568 // Fallback to class icon.
552 if (!frame_icon) { 569 if (!small_icon) {
553 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr( 570 small_icon = reinterpret_cast<HICON>(
554 views::HWNDForWidget(frame()), GCLP_HICONSM)); 571 GetClassLongPtr(views::HWNDForWidget(frame()), GCLP_HICONSM));
572 }
573 if (!big_icon) {
574 big_icon = reinterpret_cast<HICON>(
575 GetClassLongPtr(views::HWNDForWidget(frame()), GCLP_HICON));
555 } 576 }
556 577
557 // This will reset the small icon which we set in the throbber code. 578 // This will reset the icon which we set in the throbber code.
558 // WM_SETICON with null icon restores the icon for title bar but not 579 // WM_SETICON with null icon restores the icon for title bar but not
559 // for taskbar. See http://crbug.com/29996 580 // for taskbar. See http://crbug.com/29996
560 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, 581 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
561 static_cast<WPARAM>(ICON_SMALL), 582 static_cast<WPARAM>(ICON_SMALL),
562 reinterpret_cast<LPARAM>(frame_icon)); 583 reinterpret_cast<LPARAM>(small_icon));
584 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
585 static_cast<WPARAM>(ICON_BIG),
586 reinterpret_cast<LPARAM>(big_icon));
563 } 587 }
564 } 588 }
565 589
566 void GlassBrowserFrameView::DisplayNextThrobberFrame() { 590 void GlassBrowserFrameView::DisplayNextThrobberFrame() {
567 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; 591 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
568 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, 592 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
569 static_cast<WPARAM>(ICON_SMALL), 593 static_cast<WPARAM>(ICON_SMALL),
570 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); 594 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
571 } 595 }
572 596
(...skipping 21 matching lines...) Expand all
594 static bool initialized = false; 618 static bool initialized = false;
595 if (!initialized) { 619 if (!initialized) {
596 for (int i = 0; i < kThrobberIconCount; ++i) { 620 for (int i = 0; i < kThrobberIconCount; ++i) {
597 throbber_icons_[i] = 621 throbber_icons_[i] =
598 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 622 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
599 DCHECK(throbber_icons_[i]); 623 DCHECK(throbber_icons_[i]);
600 } 624 }
601 initialized = true; 625 initialized = true;
602 } 626 }
603 } 627 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.cc ('k') | ui/gfx/win/window_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698