summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 02:43:24 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-24 02:43:24 +0000
commit1efbaaa1a43dda420ddb5f96ba765748de0ba5fe (patch)
tree46ad73caa63a44d1aa144554725df4b2e341e559
parentd6c0a490893a73cfe28757ba5004c438e9275d96 (diff)
downloadchromium_src-1efbaaa1a43dda420ddb5f96ba765748de0ba5fe.zip
chromium_src-1efbaaa1a43dda420ddb5f96ba765748de0ba5fe.tar.gz
chromium_src-1efbaaa1a43dda420ddb5f96ba765748de0ba5fe.tar.bz2
Metro/HiDPI: Move 1x icons into separate pak file
Currently all 1x art files are repacked into chrome.pak files. This is a problem on Windows where we want to choose which pak file to load based on metro and DPI scale. As a first step this CL does the following: - add a new enable_hidpi build flag. This allows us to test HiDPI mode on Windows Chrome. - stop packing theme_resources_standard.pak and ui_resources_standard.pak into chrome.pak - update the Mac and Windows installer code to package the extra pak files. Note, I'll be updating the Linux installer script in a separate CL. I'm still looking into the ChromeOS situation. BUG=114311 TEST=Ran on Windows, and Mac and Linux. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=132517 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=132760 Review URL: https://chromiumcodereview.appspot.com/10024050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133613 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--build/common.gypi14
-rw-r--r--chrome/chrome_dll.gypi18
-rw-r--r--chrome/chrome_repack_chrome.gypi2
-rw-r--r--chrome/chrome_repack_theme_resources_2x.gypi21
-rw-r--r--chrome/chrome_resources.gyp46
-rw-r--r--chrome/installer/mini_installer/chrome.release6
-rw-r--r--chrome/tools/build/chromeos/FILES.cfg10
-rw-r--r--chrome/tools/build/linux/FILES.cfg10
-rw-r--r--chrome/tools/build/win/FILES.cfg20
-rwxr-xr-xchrome/tools/build/win/create_installer_archive.py13
-rw-r--r--chrome/tools/build/win/release.rules2
-rw-r--r--ui/base/resource/resource_bundle_android.cc19
-rw-r--r--ui/base/resource/resource_bundle_linux.cc17
-rw-r--r--ui/base/resource/resource_bundle_mac.mm12
-rw-r--r--ui/base/resource/resource_bundle_win.cc24
-rw-r--r--ui/base/ui_base_paths.cc10
-rw-r--r--ui/base/ui_base_paths.h3
-rw-r--r--ui/test/test_suite.cc7
18 files changed, 192 insertions, 62 deletions
diff --git a/build/common.gypi b/build/common.gypi
index 429438e..db5bf66 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -40,6 +40,9 @@
# Disable viewport meta tag by default.
'enable_viewport%': 0,
+
+ # Enable HiDPI support.
+ 'enable_hidpi%': 0,
},
# Copy conditionally-set variables out one scope.
'chromeos%': '<(chromeos)',
@@ -49,6 +52,7 @@
'use_openssl%': '<(use_openssl)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)',
+ 'enable_hidpi%': '<(enable_hidpi)',
# Compute the architecture that we're building on.
'conditions': [
@@ -82,6 +86,11 @@
}, {
'toolkit_views%': 0,
}],
+
+ # Enable HiDPI on Mac OS.
+ ['OS=="mac"', {
+ 'enable_hidpi%': 1,
+ }],
],
},
@@ -95,6 +104,7 @@
'use_openssl%': '<(use_openssl)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)',
+ 'enable_hidpi%': '<(enable_hidpi)',
# We used to provide a variable for changing how libraries were built.
# This variable remains until we can clean up all the users.
@@ -492,6 +502,7 @@
'chromeos%': '<(chromeos)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)',
+ 'enable_hidpi%': '<(enable_hidpi)',
'use_xi2_mt%':'<(use_xi2_mt)',
'file_manager_extension%': '<(file_manager_extension)',
'webui_task_manager%': '<(webui_task_manager)',
@@ -1287,6 +1298,9 @@
['notifications==1', {
'defines': ['ENABLE_NOTIFICATIONS'],
}],
+ ['enable_hidpi==1', {
+ 'defines': ['ENABLE_HIDPI=1'],
+ }],
['fastbuild!=0', {
'conditions': [
diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi
index 2744184..c926dc4 100644
--- a/chrome/chrome_dll.gypi
+++ b/chrome/chrome_dll.gypi
@@ -100,7 +100,6 @@
'<(SHARED_INTERMEDIATE_DIR)/chrome/extensions_api_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/theme_resources.rc',
- '<(SHARED_INTERMEDIATE_DIR)/chrome/theme_resources_standard.rc',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
@@ -304,8 +303,10 @@
'app/theme/star.pdf',
'app/theme/star_lit.pdf',
'browser/mac/install.sh',
- '<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak',
- '<(SHARED_INTERMEDIATE_DIR)/repack/resources.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/repack/resources.pak',
+ '<(grit_out_dir)/theme_resources_standard.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak',
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(SHARED_INTERMEDIATE_DIR) <(locales))',
# Note: pseudo_locales are generated via the packed_resources
# dependency but not copied to the final target. See
@@ -354,11 +355,6 @@
],
'repack_path': '../tools/grit/grit/format/repack.py',
},
- 'actions': [
- {
- 'includes': ['chrome_repack_theme_resources_2x.gypi']
- },
- ],
'postbuilds': [
{
# This step causes an error to be raised if the .order file
@@ -537,6 +533,12 @@
'../pdf/pdf.gyp:pdf',
],
}],
+ ['enable_hidpi==1', {
+ 'mac_bundle_resources': [
+ '<(grit_out_dir)/theme_resources_2x.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_2x/ui_resources_2x.pak',
+ ],
+ }],
], # conditions
}], # OS=="mac"
], # conditions
diff --git a/chrome/chrome_repack_chrome.gypi b/chrome/chrome_repack_chrome.gypi
index 2911000..342a60e 100644
--- a/chrome/chrome_repack_chrome.gypi
+++ b/chrome/chrome_repack_chrome.gypi
@@ -9,11 +9,9 @@
'<(grit_out_dir)/common_resources.pak',
'<(grit_out_dir)/renderer_resources.pak',
'<(grit_out_dir)/theme_resources.pak',
- '<(grit_out_dir)/theme_resources_standard.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.pak',
- '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak',
],
diff --git a/chrome/chrome_repack_theme_resources_2x.gypi b/chrome/chrome_repack_theme_resources_2x.gypi
deleted file mode 100644
index 9453118..0000000
--- a/chrome/chrome_repack_theme_resources_2x.gypi
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'action_name': 'repack_theme_resources_2x',
- 'variables': {
- 'pak_inputs': [
- '<(grit_out_dir)/theme_resources_2x.pak',
- ],
- },
- 'inputs': [
- '<(repack_path)',
- '<@(pak_inputs)',
- ],
- 'outputs': [
- '<(INTERMEDIATE_DIR)/repack/theme_resources_2x.pak',
- ],
- 'action': ['python', '<(repack_path)', '<@(_outputs)',
- '<@(pak_inputs)'],
- 'process_outputs_as_mac_bundle_resources': 1,
-}
diff --git a/chrome/chrome_resources.gyp b/chrome/chrome_resources.gyp
index 9834578..18f88fb 100644
--- a/chrome/chrome_resources.gyp
+++ b/chrome/chrome_resources.gyp
@@ -193,7 +193,7 @@
'includes': [ '../build/grit_target.gypi' ],
},
{
- 'target_name': 'theme_resources',
+ 'target_name': 'theme_resources_gen',
'type': 'none',
'actions': [
{
@@ -221,6 +221,48 @@
'includes': [ '../build/grit_target.gypi' ],
},
{
+ 'target_name': 'theme_resources',
+ 'type': 'none',
+ 'dependencies': [
+ 'theme_resources_gen',
+ '<(DEPTH)/ui/ui.gyp:ui_resources_2x',
+ '<(DEPTH)/ui/ui.gyp:ui_resources_standard',
+ ],
+ 'conditions': [
+ ['OS != "mac"', {
+ # Copy pak files to the product directory. These files will be picked
+ # up by the following installer scripts:
+ # - Windows: chrome/installer/mini_installer/chrome.release
+ # - Linux: chrome/installer/linux/internal/common/installer.include
+ # Ensure that the above scripts are updated when adding or removing
+ # pak files.
+ # Coping files to the product directory is not needed on the Mac
+ # since the framework build phase will copy them into the framework
+ # bundle directly.
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [
+ '<(grit_out_dir)/theme_resources_standard.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_standard/ui_resources_standard.pak',
+ ],
+ },
+ ],
+ }],
+ ['OS != "mac" and enable_hidpi == 1', {
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [
+ '<(grit_out_dir)/theme_resources_2x.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources_2x/ui_resources_2x.pak',
+ ],
+ },
+ ],
+ }],
+ ],
+ },
+ {
'target_name': 'packed_extra_resources',
'type': 'none',
'variables': {
@@ -269,8 +311,6 @@
'<(DEPTH)/ui/base/strings/ui_strings.gyp:ui_strings',
'<(DEPTH)/ui/ui.gyp:gfx_resources',
'<(DEPTH)/ui/ui.gyp:ui_resources',
- '<(DEPTH)/ui/ui.gyp:ui_resources_2x',
- '<(DEPTH)/ui/ui.gyp:ui_resources_standard',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_resources',
'<(DEPTH)/webkit/support/webkit_support.gyp:webkit_strings',
],
diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release
index 49de5ab..b99fab4 100644
--- a/chrome/installer/mini_installer/chrome.release
+++ b/chrome/installer/mini_installer/chrome.release
@@ -13,6 +13,8 @@ nacl_irt_x86_32.nexe: %(VersionDir)s\
nacl_irt_x86_64.nexe: %(VersionDir)s\
icudt.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\
+theme_resources_standard.pak: %(VersionDir)s\
+ui_resources_standard.pak: %(VersionDir)s\
locales\*.pak: %(VersionDir)s\Locales
locales\*.dll: %(VersionDir)s\Locales
npchrome_frame.dll: %(VersionDir)s\
@@ -30,6 +32,10 @@ xinput1_3.dll: %(VersionDir)s\
default_apps\*.crx: %(VersionDir)s\default_apps\
default_apps\external_extensions.json: %(VersionDir)s\default_apps\
+[HIDPI]
+theme_resources_2x.pak: %(VersionDir)s\
+ui_resources_2x.pak: %(VersionDir)s\
+
[GOOGLE_CHROME]
splash-620x300.png: %(ChromeDir)s\
Logo.png: %(ChromeDir)s\
diff --git a/chrome/tools/build/chromeos/FILES.cfg b/chrome/tools/build/chromeos/FILES.cfg
index cdf2700..958f6b2 100644
--- a/chrome/tools/build/chromeos/FILES.cfg
+++ b/chrome/tools/build/chromeos/FILES.cfg
@@ -85,6 +85,16 @@ FILES = [
'buildtype': ['dev', 'official'],
},
{
+ 'filename': 'theme_resources_standard.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
+ 'filename': 'ui_resources_standard.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
'filename': 'session',
'arch': ['32bit', '64bit'],
'buildtype': ['dev'],
diff --git a/chrome/tools/build/linux/FILES.cfg b/chrome/tools/build/linux/FILES.cfg
index 88520a8..5953a0a 100644
--- a/chrome/tools/build/linux/FILES.cfg
+++ b/chrome/tools/build/linux/FILES.cfg
@@ -87,6 +87,16 @@ FILES = [
'buildtype': ['dev', 'official'],
},
{
+ 'filename': 'theme_resources_standard.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
+ 'filename': 'ui_resources_standard.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
'filename': 'session',
'arch': ['32bit', '64bit'],
'buildtype': ['dev'],
diff --git a/chrome/tools/build/win/FILES.cfg b/chrome/tools/build/win/FILES.cfg
index 2c21743..60fe243 100644
--- a/chrome/tools/build/win/FILES.cfg
+++ b/chrome/tools/build/win/FILES.cfg
@@ -347,6 +347,26 @@ FILES = [
'buildtype': ['dev', 'official'],
},
{
+ 'filename': 'theme_resources_standard.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
+ 'filename': 'theme_resources_2x.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
+ 'filename': 'ui_resources_standard.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
+ 'filename': 'ui_resources_2x.pak',
+ 'arch': ['32bit', '64bit'],
+ 'buildtype': ['dev', 'official'],
+ },
+ {
'filename': 'wow_helper.exe',
'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'],
diff --git a/chrome/tools/build/win/create_installer_archive.py b/chrome/tools/build/win/create_installer_archive.py
index a7adbba..2e85d9b 100755
--- a/chrome/tools/build/win/create_installer_archive.py
+++ b/chrome/tools/build/win/create_installer_archive.py
@@ -89,7 +89,8 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file):
RunSystemCommand(cmd)
-def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir):
+def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir,
+ enable_hidpi):
"""Copies the files required for installer archive.
Copies all common files required for various distributions of Chromium and
also files for the specific Chromium build specified by distribution.
@@ -100,6 +101,8 @@ def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir):
distribution = distribution[1:]
CopySectionFilesToStagingDir(config, distribution.upper(),
staging_dir, build_dir)
+ if enable_hidpi == '1':
+ CopySectionFilesToStagingDir(config, 'HIDPI', staging_dir, build_dir)
def CopySectionFilesToStagingDir(config, section, staging_dir, build_dir):
@@ -324,11 +327,13 @@ def main(options):
# building the optimized mini_installer.
if options.build_dir != options.output_dir:
CopyAllFilesToStagingDir(config, options.distribution,
- staging_dir, options.output_dir)
+ staging_dir, options.output_dir,
+ options.enable_hidpi)
# Now copy the remainder of the files from the build dir.
CopyAllFilesToStagingDir(config, options.distribution,
- staging_dir, options.build_dir)
+ staging_dir, options.build_dir,
+ options.enable_hidpi)
version_numbers = current_version.split('.')
current_build_number = version_numbers[2] + '.' + version_numbers[3]
@@ -380,6 +385,8 @@ def _ParseOptions():
'{BSDIFF|COURGETTE}.')
parser.add_option('-n', '--output_name', default='chrome',
help='Name used to prefix names of generated archives.')
+ parser.add_option('--enable_hidpi', default='0',
+ help='Whether to include HiDPI resource files.')
options, args = parser.parse_args()
if not options.build_dir:
diff --git a/chrome/tools/build/win/release.rules b/chrome/tools/build/win/release.rules
index 21cdf14..cd3212b 100644
--- a/chrome/tools/build/win/release.rules
+++ b/chrome/tools/build/win/release.rules
@@ -7,7 +7,7 @@
<CustomBuildRule
Name="Create Installer Archive"
DisplayName="Create Installer Archive"
- CommandLine="$(SolutionDir)..\third_party\python_24\python.exe $(SolutionDir)tools\build\win\create_installer_archive.py --output_dir=&quot;$(OutDir)&quot; --input_file=&quot;$(InputPath)&quot; --distribution=$(CHROMIUM_BUILD) [LastChromeInstaller] [SkipRebuildArchive] [SetupExeFormat] [DiffAlgorithm]"
+ CommandLine="$(SolutionDir)..\third_party\python_24\python.exe $(SolutionDir)tools\build\win\create_installer_archive.py --output_dir=&quot;$(OutDir)&quot; --input_file=&quot;$(InputPath)&quot; --distribution=$(CHROMIUM_BUILD) --enable_hidpi=$(ENABLE_HIDPI) [LastChromeInstaller] [SkipRebuildArchive] [SetupExeFormat] [DiffAlgorithm]"
Outputs="$(OutDir)/$(InputName).7z;$(OutDir)/$(InputName).packed.7z;$(OutDir)/setup.ex_;$(OutDir)/packed_files.txt;"
AdditionalDependencies="$(SolutionDir)\tools\build\win\create_installer_archive.py;$(OutDir)\chrome.exe;$(OutDir)\crash_reporter.exe;$(OutDir)\chrome.dll;$(OutDir)\locales\en-US.dll;$(OutDir)\icudt38.dll"
FileExtensions="*.release"
diff --git a/ui/base/resource/resource_bundle_android.cc b/ui/base/resource/resource_bundle_android.cc
index 2959d5b..62a53c6 100644
--- a/ui/base/resource/resource_bundle_android.cc
+++ b/ui/base/resource/resource_bundle_android.cc
@@ -12,14 +12,23 @@
#include "base/path_service.h"
#include "base/stringprintf.h"
+namespace {
+
+FilePath GetResourcesPakFilePath(const std::string& pak_name) {
+ FilePath path;
+ PathService::Get(base::DIR_ANDROID_APP_DATA, &path);
+ DCHECK(!path.empty());
+ return path.AppendASCII("paks").AppendASCII(pak_name.c_str());
+}
+
+} // namespace
+
namespace ui {
void ResourceBundle::LoadCommonResources() {
- FilePath data_path;
- PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path);
- DCHECK(!data_path.empty());
- data_path = data_path.AppendASCII("paks").AppendASCII("chrome.pak");
- AddDataPack(data_path);
+ AddDataPack(GetResourcesPakFilePath("chrome.pak"));
+ AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
+ AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
}
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
diff --git a/ui/base/resource/resource_bundle_linux.cc b/ui/base/resource/resource_bundle_linux.cc
index ec6678d..5c8d598 100644
--- a/ui/base/resource/resource_bundle_linux.cc
+++ b/ui/base/resource/resource_bundle_linux.cc
@@ -7,12 +7,23 @@
#include "base/path_service.h"
#include "ui/base/ui_base_paths.h"
+namespace {
+
+FilePath GetResourcesPakFilePath(const std::string& pak_name) {
+ FilePath path;
+ if (PathService::Get(base::DIR_MODULE, &path))
+ return path.AppendASCII(pak_name.c_str());
+ return FilePath();
+}
+
+} // namespace
+
namespace ui {
void ResourceBundle::LoadCommonResources() {
- FilePath path;
- PathService::Get(ui::FILE_RESOURCES_PAK, &path);
- AddDataPack(path);
+ AddDataPack(GetResourcesPakFilePath("chrome.pak"));
+ AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
+ AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
}
} // namespace ui
diff --git a/ui/base/resource/resource_bundle_mac.mm b/ui/base/resource/resource_bundle_mac.mm
index 5ace3de..6e4002d 100644
--- a/ui/base/resource/resource_bundle_mac.mm
+++ b/ui/base/resource/resource_bundle_mac.mm
@@ -44,8 +44,18 @@ FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) {
void ResourceBundle::LoadCommonResources() {
AddDataPack(GetResourcesPakFilePath(@"chrome", nil));
- if (base::mac::IsOSLionOrLater())
+ AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard", nil));
+ AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard", nil));
+
+ // On Windows and ChromeOS we load either the 1x resource or the 2x resource.
+ // On Mac we load both and let the UI framework decide which one to use.
+#if defined(ENABLE_HIDPI)
+ if (base::mac::IsOSLionOrLater()) {
AddDataPack(GetResourcesPakFilePath(@"theme_resources_2x", nil));
+ AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard_2x", nil));
+ AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard_2x", nil));
+ }
+#endif
}
// static
diff --git a/ui/base/resource/resource_bundle_win.cc b/ui/base/resource/resource_bundle_win.cc
index 72330ff..7425755 100644
--- a/ui/base/resource/resource_bundle_win.cc
+++ b/ui/base/resource/resource_bundle_win.cc
@@ -5,8 +5,10 @@
#include "ui/base/resource/resource_bundle_win.h"
#include "base/logging.h"
+#include "base/path_service.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_data_dll_win.h"
+#include "ui/base/win/dpi.h"
namespace ui {
@@ -20,11 +22,33 @@ HINSTANCE GetCurrentResourceDLL() {
return GetModuleHandle(NULL);
}
+FilePath GetResourcesPakFilePath(const std::string& pak_name) {
+ FilePath path;
+ if (PathService::Get(base::DIR_MODULE, &path))
+ return path.AppendASCII(pak_name.c_str());
+ return FilePath();
+}
+
} // end anonymous namespace
void ResourceBundle::LoadCommonResources() {
// As a convenience, add the current resource module as a data packs.
data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL()));
+
+ bool use_hidpi_pak = false;
+#if defined(ENABLE_HIDPI)
+ // If we're running in HiDPI mode then use the 2x resource for DPI greater
+ // than 1.5. Otherwise use the 1x resource.
+ use_hidpi_pak = ui::GetDPIScale() > 1.5;
+#endif
+
+ if (!use_hidpi_pak) {
+ AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
+ AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
+ } else {
+ AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak"));
+ AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak"));
+ }
}
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
diff --git a/ui/base/ui_base_paths.cc b/ui/base/ui_base_paths.cc
index 14897f0..fc07a78 100644
--- a/ui/base/ui_base_paths.cc
+++ b/ui/base/ui_base_paths.cc
@@ -32,16 +32,6 @@ bool PathProvider(int key, FilePath* result) {
#endif
create_dir = true;
break;
- case ui::FILE_RESOURCES_PAK:
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
- if (!PathService::Get(base::DIR_EXE, &cur))
- return false;
- // TODO(tony): We shouldn't be referencing chrome here.
- cur = cur.AppendASCII("chrome.pak");
-#else
- NOTREACHED();
-#endif
- break;
// The following are only valid in the development environment, and
// will fail if executed from an installed executable (because the
// generated path won't exist).
diff --git a/ui/base/ui_base_paths.h b/ui/base/ui_base_paths.h
index 2884ae9..7ca95bc 100644
--- a/ui/base/ui_base_paths.h
+++ b/ui/base/ui_base_paths.h
@@ -18,9 +18,6 @@ enum {
DIR_LOCALES, // Directory where locale resources are stored.
- FILE_RESOURCES_PAK, // Path to the data .pak file which holds binary
- // resources.
-
// Valid only in development environment; TODO(darin): move these
DIR_TEST_DATA, // Directory where unit test data resides.
diff --git a/ui/test/test_suite.cc b/ui/test/test_suite.cc
index bd4e325..024543e 100644
--- a/ui/test/test_suite.cc
+++ b/ui/test/test_suite.cc
@@ -46,13 +46,16 @@ void UITestSuite::Initialize() {
PathService::Get(base::DIR_MODULE, &pak_dir);
pak_dir = pak_dir.AppendASCII("ui_unittests_strings");
PathService::Override(ui::DIR_LOCALES, pak_dir);
- PathService::Override(ui::FILE_RESOURCES_PAK,
- pak_dir.AppendASCII("ui_resources.pak"));
#endif // defined(OS_MACOSX)
// Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US");
+
+#if !defined(OS_MACOSX) && defined(OS_POSIX)
+ ui::ResourceBundle::GetSharedInstance().AddDataPack(
+ pak_dir.AppendASCII("ui_resources.pak"));
+#endif
}
void UITestSuite::Shutdown() {