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

Side by Side Diff: views/controls/menu/menu_config_win.cc

Issue 7978021: Fix memory leak on menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ScopedHFONT Created 9 years, 3 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 "views/controls/menu/menu_config.h" 5 #include "views/controls/menu/menu_config.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <uxtheme.h> 8 #include <uxtheme.h>
9 #include <Vssym32.h> 9 #include <Vssym32.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/win/scoped_gdi_object.h"
12 #include "base/win/win_util.h" 13 #include "base/win/win_util.h"
13 #include "ui/base/l10n/l10n_util_win.h" 14 #include "ui/base/l10n/l10n_util_win.h"
14 #include "ui/gfx/native_theme_win.h" 15 #include "ui/gfx/native_theme_win.h"
15 16
16 using gfx::NativeTheme; 17 using gfx::NativeTheme;
17 using gfx::NativeThemeWin; 18 using gfx::NativeThemeWin;
18 19
19 namespace views { 20 namespace views {
20 21
21 // static 22 // static
22 MenuConfig* MenuConfig::Create() { 23 MenuConfig* MenuConfig::Create() {
23 MenuConfig* config = new MenuConfig(); 24 MenuConfig* config = new MenuConfig();
24 25
25 config->text_color = NativeThemeWin::instance()->GetThemeColorWithDefault( 26 config->text_color = NativeThemeWin::instance()->GetThemeColorWithDefault(
26 NativeThemeWin::MENU, MENU_POPUPITEM, MPI_NORMAL, TMT_TEXTCOLOR, 27 NativeThemeWin::MENU, MENU_POPUPITEM, MPI_NORMAL, TMT_TEXTCOLOR,
27 COLOR_MENUTEXT); 28 COLOR_MENUTEXT);
28 29
29 NONCLIENTMETRICS metrics; 30 NONCLIENTMETRICS metrics;
30 base::win::GetNonClientMetrics(&metrics); 31 base::win::GetNonClientMetrics(&metrics);
31 l10n_util::AdjustUIFont(&(metrics.lfMenuFont)); 32 l10n_util::AdjustUIFont(&(metrics.lfMenuFont));
32 HFONT font = CreateFontIndirect(&metrics.lfMenuFont); 33 {
33 DLOG_ASSERT(font); 34 base::win::ScopedHFONT font(CreateFontIndirect(&metrics.lfMenuFont));
34 config->font = gfx::Font(font); 35 DLOG_ASSERT(font.Get());
35 36 config->font = gfx::Font(font);
37 }
36 NativeTheme::ExtraParams extra; 38 NativeTheme::ExtraParams extra;
37 extra.menu_check.is_radio = false; 39 extra.menu_check.is_radio = false;
38 extra.menu_check.is_selected = false; 40 extra.menu_check.is_selected = false;
39 gfx::Size check_size = NativeTheme::instance()->GetPartSize( 41 gfx::Size check_size = NativeTheme::instance()->GetPartSize(
40 NativeTheme::kMenuCheck, NativeTheme::kNormal, extra); 42 NativeTheme::kMenuCheck, NativeTheme::kNormal, extra);
41 if (!check_size.IsEmpty()) { 43 if (!check_size.IsEmpty()) {
42 config->check_width = check_size.width(); 44 config->check_width = check_size.width();
43 config->check_height = check_size.height(); 45 config->check_height = check_size.height();
44 } else { 46 } else {
45 config->check_width = GetSystemMetrics(SM_CXMENUCHECK); 47 config->check_width = GetSystemMetrics(SM_CXMENUCHECK);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 config->item_no_icon_top_margin = config->item_top_margin; 95 config->item_no_icon_top_margin = config->item_top_margin;
94 96
95 BOOL show_cues; 97 BOOL show_cues;
96 config->show_mnemonics = 98 config->show_mnemonics =
97 (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) && 99 (SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &show_cues, 0) &&
98 show_cues == TRUE); 100 show_cues == TRUE);
99 return config; 101 return config;
100 } 102 }
101 103
102 } // namespace views 104 } // namespace views
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