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

Side by Side Diff: ui/base/resource/resource_bundle_win.cc

Issue 10082020: Metro/HiDPI: Use metro resource pak in metro mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 8 years, 8 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
« chrome/chrome_resources.gyp ('K') | « tools/gritsettings/resource_ids ('k') | 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) 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 "ui/base/resource/resource_bundle_win.h" 5 #include "ui/base/resource/resource_bundle_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/base/resource/resource_data_dll_win.h" 10 #include "ui/base/resource/resource_data_dll_win.h"
(...skipping 11 matching lines...) Expand all
22 return GetModuleHandle(NULL); 22 return GetModuleHandle(NULL);
23 } 23 }
24 24
25 FilePath GetResourcesPakFilePath(const std::string& pak_name) { 25 FilePath GetResourcesPakFilePath(const std::string& pak_name) {
26 FilePath path; 26 FilePath path;
27 if (PathService::Get(base::DIR_MODULE, &path)) 27 if (PathService::Get(base::DIR_MODULE, &path))
28 return path.AppendASCII(pak_name.c_str()); 28 return path.AppendASCII(pak_name.c_str());
29 return FilePath(); 29 return FilePath();
30 } 30 }
31 31
32 bool IsInMetroMode() {
33 const char* kMetroModeEnvVar = "CHROME_METRO_DLL";
sky 2012/04/13 22:56:15 Can you use base/win/metro.h?
sail 2012/04/18 15:46:40 Done.
34 char buffer[2];
35 if (!::GetEnvironmentVariableA(kMetroModeEnvVar, buffer, arraysize(buffer)))
36 return false;
37 return buffer == std::string("1");
38 }
39
32 } // end anonymous namespace 40 } // end anonymous namespace
33 41
34 void ResourceBundle::LoadCommonResources() { 42 void ResourceBundle::LoadCommonResources() {
35 // As a convenience, add the current resource module as a data packs. 43 // As a convenience, add the current resource module as a data packs.
36 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); 44 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL()));
37 45
38 bool use_hidpi_pak = false; 46 bool use_hidpi_pak = false;
39 #if defined(ENABLE_HIDPI) 47 #if defined(ENABLE_HIDPI)
40 // If we're running in HiDPI mode then use the 2x resource for DPI greater 48 // If we're running in HiDPI mode then use the 2x resource for DPI greater
41 // than 1.5. Otherwise use the 1x resource. 49 // than 1.5. Otherwise use the 1x resource.
42 use_hidpi_pak = ui::GetDPIScale() > 1.5; 50 use_hidpi_pak = ui::GetDPIScale() > 1.5;
43 #endif 51 #endif
44 52
45 if (!use_hidpi_pak) { 53 bool use_metro_pak = false;
54 #if defined(ENABLE_METRO)
55 use_metro_pak = IsInMetroMode();
56 #endif
57
58 if (use_metro_pak) {
59 AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak"));
60 } else if (use_hidpi_pak) {
61 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"));
62 } else {
46 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); 63 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
64 }
65
66 if (use_hidpi_pak) {
67 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"));
68 } else {
47 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); 69 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
48 } else {
49 AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"));
50 AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"));
51 } 70 }
52 } 71 }
53 72
54 void ResourceBundle::LoadTestResources(const FilePath& path) { 73 void ResourceBundle::LoadTestResources(const FilePath& path) {
55 // On Windows, the test resources are normally compiled into the binary 74 // On Windows, the test resources are normally compiled into the binary
56 // itself. 75 // itself.
57 } 76 }
58 77
59 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { 78 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
60 // Flipped image is not used on Windows. 79 // Flipped image is not used on Windows.
61 DCHECK_EQ(rtl, RTL_DISABLED); 80 DCHECK_EQ(rtl, RTL_DISABLED);
62 81
63 // Windows only uses SkBitmap for gfx::Image, so this is the same as 82 // Windows only uses SkBitmap for gfx::Image, so this is the same as
64 // GetImageNamed. 83 // GetImageNamed.
65 return GetImageNamed(resource_id); 84 return GetImageNamed(resource_id);
66 } 85 }
67 86
68 void SetResourcesDataDLL(HINSTANCE handle) { 87 void SetResourcesDataDLL(HINSTANCE handle) {
69 resources_data_dll = handle; 88 resources_data_dll = handle;
70 } 89 }
71 90
72 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { 91 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) {
73 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); 92 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id));
74 } 93 }
75 94
76 } // namespace ui; 95 } // namespace ui;
OLDNEW
« chrome/chrome_resources.gyp ('K') | « tools/gritsettings/resource_ids ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698