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

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

Issue 1406403007: Eliminate HICON leaks caused by creating icons from bitmap image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 HICON big_icon = nullptr; 578 HICON big_icon = nullptr;
579 579
580 // Check if hosted BrowserView has a window icon to use. 580 // Check if hosted BrowserView has a window icon to use.
581 if (browser_view()->ShouldShowWindowIcon()) { 581 if (browser_view()->ShouldShowWindowIcon()) {
582 gfx::ImageSkia icon = browser_view()->GetWindowIcon(); 582 gfx::ImageSkia icon = browser_view()->GetWindowIcon();
583 if (!icon.isNull()) { 583 if (!icon.isNull()) {
584 small_icon = CreateHICONFromSkBitmapSizedTo( 584 small_icon = CreateHICONFromSkBitmapSizedTo(
585 icon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); 585 icon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
586 big_icon = CreateHICONFromSkBitmapSizedTo( 586 big_icon = CreateHICONFromSkBitmapSizedTo(
587 icon, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); 587 icon, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
588
589 // Take responsibility for eventually destroying the created icons.
590 small_window_icon_.Set(small_icon);
sky 2015/11/02 16:41:38 Won't this be problematic with the code on 618-623
591 big_window_icon_.Set(big_icon);
588 } 592 }
589 } 593 }
590 594
591 // Fallback to class icon. 595 // Fallback to class icon.
592 if (!small_icon) { 596 if (!small_icon) {
593 small_icon = reinterpret_cast<HICON>( 597 small_icon = reinterpret_cast<HICON>(
594 GetClassLongPtr(views::HWNDForWidget(frame()), GCLP_HICONSM)); 598 GetClassLongPtr(views::HWNDForWidget(frame()), GCLP_HICONSM));
595 } 599 }
596 if (!big_icon) { 600 if (!big_icon) {
597 big_icon = reinterpret_cast<HICON>( 601 big_icon = reinterpret_cast<HICON>(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 static bool initialized = false; 635 static bool initialized = false;
632 if (!initialized) { 636 if (!initialized) {
633 for (int i = 0; i < kThrobberIconCount; ++i) { 637 for (int i = 0; i < kThrobberIconCount; ++i) {
634 throbber_icons_[i] = 638 throbber_icons_[i] =
635 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); 639 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
636 DCHECK(throbber_icons_[i]); 640 DCHECK(throbber_icons_[i]);
637 } 641 }
638 initialized = true; 642 initialized = true;
639 } 643 }
640 } 644 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/glass_browser_frame_view.h ('k') | ui/views/win/hwnd_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698