Commit 2e317bff authored by sail@chromium.org's avatar sail@chromium.org

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.

Review URL: http://codereview.chromium.org/10024050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132517 0039d316-1c4b-4281-b951-d872f2087c98
parent 83d9dc34
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
# Disable viewport meta tag by default. # Disable viewport meta tag by default.
'enable_viewport%': 0, 'enable_viewport%': 0,
# Enable HiDPI support.
'enable_hidpi%': 0,
}, },
# Copy conditionally-set variables out one scope. # Copy conditionally-set variables out one scope.
'chromeos%': '<(chromeos)', 'chromeos%': '<(chromeos)',
...@@ -49,6 +52,7 @@ ...@@ -49,6 +52,7 @@
'use_openssl%': '<(use_openssl)', 'use_openssl%': '<(use_openssl)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)', 'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',
# Compute the architecture that we're building on. # Compute the architecture that we're building on.
'conditions': [ 'conditions': [
...@@ -82,6 +86,11 @@ ...@@ -82,6 +86,11 @@
}, { }, {
'toolkit_views%': 0, 'toolkit_views%': 0,
}], }],
# Enable HiDPI on Mac OS.
['OS=="mac"', {
'enable_hidpi%': 1,
}],
], ],
}, },
...@@ -95,6 +104,7 @@ ...@@ -95,6 +104,7 @@
'use_openssl%': '<(use_openssl)', 'use_openssl%': '<(use_openssl)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)', 'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',
# We used to provide a variable for changing how libraries were built. # We used to provide a variable for changing how libraries were built.
# This variable remains until we can clean up all the users. # This variable remains until we can clean up all the users.
...@@ -490,6 +500,7 @@ ...@@ -490,6 +500,7 @@
'chromeos%': '<(chromeos)', 'chromeos%': '<(chromeos)',
'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'use_virtual_keyboard%': '<(use_virtual_keyboard)',
'enable_viewport%': '<(enable_viewport)', 'enable_viewport%': '<(enable_viewport)',
'enable_hidpi%': '<(enable_hidpi)',
'use_xi2_mt%':'<(use_xi2_mt)', 'use_xi2_mt%':'<(use_xi2_mt)',
'file_manager_extension%': '<(file_manager_extension)', 'file_manager_extension%': '<(file_manager_extension)',
'webui_task_manager%': '<(webui_task_manager)', 'webui_task_manager%': '<(webui_task_manager)',
...@@ -1285,6 +1296,9 @@ ...@@ -1285,6 +1296,9 @@
['notifications==1', { ['notifications==1', {
'defines': ['ENABLE_NOTIFICATIONS'], 'defines': ['ENABLE_NOTIFICATIONS'],
}], }],
['enable_hidpi==1', {
'defines': ['ENABLE_HIDPI=1'],
}],
['fastbuild!=0', { ['fastbuild!=0', {
'conditions': [ 'conditions': [
......
...@@ -100,7 +100,6 @@ ...@@ -100,7 +100,6 @@
'<(SHARED_INTERMEDIATE_DIR)/chrome/extensions_api_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/chrome/extensions_api_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/chrome/renderer_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/chrome/theme_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)/content/content_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.rc',
'<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc',
...@@ -304,8 +303,10 @@ ...@@ -304,8 +303,10 @@
'app/theme/star.pdf', 'app/theme/star.pdf',
'app/theme/star_lit.pdf', 'app/theme/star_lit.pdf',
'browser/mac/install.sh', 'browser/mac/install.sh',
'<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak', '<(SHARED_INTERMEDIATE_DIR)/repack/chrome.pak',
'<(SHARED_INTERMEDIATE_DIR)/repack/resources.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))', '<!@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 # Note: pseudo_locales are generated via the packed_resources
# dependency but not copied to the final target. See # dependency but not copied to the final target. See
...@@ -354,11 +355,6 @@ ...@@ -354,11 +355,6 @@
], ],
'repack_path': '../tools/grit/grit/format/repack.py', 'repack_path': '../tools/grit/grit/format/repack.py',
}, },
'actions': [
{
'includes': ['chrome_repack_theme_resources_2x.gypi']
},
],
'postbuilds': [ 'postbuilds': [
{ {
# This step causes an error to be raised if the .order file # This step causes an error to be raised if the .order file
...@@ -537,6 +533,12 @@ ...@@ -537,6 +533,12 @@
'../pdf/pdf.gyp:pdf', '../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 ], # conditions
}], # OS=="mac" }], # OS=="mac"
], # conditions ], # conditions
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
'<(grit_out_dir)/common_resources.pak', '<(grit_out_dir)/common_resources.pak',
'<(grit_out_dir)/renderer_resources.pak', '<(grit_out_dir)/renderer_resources.pak',
'<(grit_out_dir)/theme_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)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_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_chromium_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak',
], ],
......
# 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,
}
...@@ -219,6 +219,39 @@ ...@@ -219,6 +219,39 @@
}, },
], ],
'includes': [ '../build/grit_target.gypi' ], 'includes': [ '../build/grit_target.gypi' ],
'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', 'target_name': 'packed_extra_resources',
......
...@@ -13,6 +13,8 @@ nacl_irt_x86_32.nexe: %(VersionDir)s\ ...@@ -13,6 +13,8 @@ nacl_irt_x86_32.nexe: %(VersionDir)s\
nacl_irt_x86_64.nexe: %(VersionDir)s\ nacl_irt_x86_64.nexe: %(VersionDir)s\
icudt.dll: %(VersionDir)s\ icudt.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\ resources.pak: %(VersionDir)s\
theme_resources_standard.pak: %(VersionDir)s\
ui_resources_standard.pak: %(VersionDir)s\
locales\*.pak: %(VersionDir)s\Locales locales\*.pak: %(VersionDir)s\Locales
locales\*.dll: %(VersionDir)s\Locales locales\*.dll: %(VersionDir)s\Locales
npchrome_frame.dll: %(VersionDir)s\ npchrome_frame.dll: %(VersionDir)s\
...@@ -30,6 +32,10 @@ xinput1_3.dll: %(VersionDir)s\ ...@@ -30,6 +32,10 @@ xinput1_3.dll: %(VersionDir)s\
default_apps\*.crx: %(VersionDir)s\default_apps\ default_apps\*.crx: %(VersionDir)s\default_apps\
default_apps\external_extensions.json: %(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] [GOOGLE_CHROME]
gcswf32.dll: %(VersionDir)s\ gcswf32.dll: %(VersionDir)s\
plugin.vch: %(VersionDir)s\ plugin.vch: %(VersionDir)s\
......
...@@ -84,6 +84,16 @@ FILES = [ ...@@ -84,6 +84,16 @@ FILES = [
'arch': ['32bit', '64bit'], 'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'], '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', 'filename': 'session',
'arch': ['32bit', '64bit'], 'arch': ['32bit', '64bit'],
......
...@@ -86,6 +86,16 @@ FILES = [ ...@@ -86,6 +86,16 @@ FILES = [
'arch': ['32bit', '64bit'], 'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'], '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', 'filename': 'session',
'arch': ['32bit', '64bit'], 'arch': ['32bit', '64bit'],
......
...@@ -346,6 +346,26 @@ FILES = [ ...@@ -346,6 +346,26 @@ FILES = [
'arch': ['32bit', '64bit'], 'arch': ['32bit', '64bit'],
'buildtype': ['dev', 'official'], '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', 'filename': 'wow_helper.exe',
'arch': ['32bit', '64bit'], 'arch': ['32bit', '64bit'],
......
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -89,7 +89,8 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file): ...@@ -89,7 +89,8 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file):
RunSystemCommand(cmd) 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 the files required for installer archive.
Copies all common files required for various distributions of Chromium and Copies all common files required for various distributions of Chromium and
also files for the specific Chromium build specified by distribution. also files for the specific Chromium build specified by distribution.
...@@ -100,6 +101,8 @@ def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir): ...@@ -100,6 +101,8 @@ def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir):
distribution = distribution[1:] distribution = distribution[1:]
CopySectionFilesToStagingDir(config, distribution.upper(), CopySectionFilesToStagingDir(config, distribution.upper(),
staging_dir, build_dir) staging_dir, build_dir)
if enable_hidpi == '1':
CopySectionFilesToStagingDir(config, 'HIDPI', staging_dir, build_dir)
def CopySectionFilesToStagingDir(config, section, staging_dir, build_dir): def CopySectionFilesToStagingDir(config, section, staging_dir, build_dir):
...@@ -324,11 +327,13 @@ def main(options): ...@@ -324,11 +327,13 @@ def main(options):
# building the optimized mini_installer. # building the optimized mini_installer.
if options.build_dir != options.output_dir: if options.build_dir != options.output_dir:
CopyAllFilesToStagingDir(config, options.distribution, 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. # Now copy the remainder of the files from the build dir.
CopyAllFilesToStagingDir(config, options.distribution, CopyAllFilesToStagingDir(config, options.distribution,
staging_dir, options.build_dir) staging_dir, options.build_dir,
options.enable_hidpi)
version_numbers = current_version.split('.') version_numbers = current_version.split('.')
current_build_number = version_numbers[2] + '.' + version_numbers[3] current_build_number = version_numbers[2] + '.' + version_numbers[3]
...@@ -380,6 +385,8 @@ def _ParseOptions(): ...@@ -380,6 +385,8 @@ def _ParseOptions():
'{BSDIFF|COURGETTE}.') '{BSDIFF|COURGETTE}.')
parser.add_option('-n', '--output_name', default='chrome', parser.add_option('-n', '--output_name', default='chrome',
help='Name used to prefix names of generated archives.') 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() options, args = parser.parse_args()
if not options.build_dir: if not options.build_dir:
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<CustomBuildRule <CustomBuildRule
Name="Create Installer Archive" Name="Create Installer Archive"
DisplayName="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;" 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" 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" FileExtensions="*.release"
......
...@@ -12,14 +12,23 @@ ...@@ -12,14 +12,23 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/stringprintf.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 { namespace ui {
void ResourceBundle::LoadCommonResources() { void ResourceBundle::LoadCommonResources() {
FilePath data_path; AddDataPack(GetResourcesPakFilePath("chrome.pak"));
PathService::Get(base::DIR_ANDROID_APP_DATA, &data_path); AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
DCHECK(!data_path.empty()); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
data_path = data_path.AppendASCII("paks").AppendASCII("chrome.pak");
AddDataPack(data_path);
} }
gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) {
......
...@@ -7,12 +7,23 @@ ...@@ -7,12 +7,23 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "ui/base/ui_base_paths.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 { namespace ui {
void ResourceBundle::LoadCommonResources() { void ResourceBundle::LoadCommonResources() {
FilePath path; AddDataPack(GetResourcesPakFilePath("chrome.pak"));
PathService::Get(ui::FILE_RESOURCES_PAK, &path); AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"));
AddDataPack(path); AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"));
} }
} // namespace ui } // namespace ui
...@@ -44,8 +44,18 @@ FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) { ...@@ -44,8 +44,18 @@ FilePath GetResourcesPakFilePath(NSString* name, NSString* mac_locale) {
void ResourceBundle::LoadCommonResources() { void ResourceBundle::LoadCommonResources() {
AddDataPack(GetResourcesPakFilePath(@"chrome", nil)); 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_2x", nil));
AddDataPack(GetResourcesPakFilePath(@"theme_resources_standard_2x", nil));
AddDataPack(GetResourcesPakFilePath(@"ui_resources_standard_2x", nil));
}
#endif
} }
// static // static
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
#include "ui/base/resource/resource_bundle_win.h" #include "ui/base/resource/resource_bundle_win.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/path_service.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_data_dll_win.h" #include "ui/base/resource/resource_data_dll_win.h"
#include "ui/base/win/dpi.h"
namespace ui { namespace ui {
...@@ -20,11 +22,33 @@ HINSTANCE GetCurrentResourceDLL() { ...@@ -20,11 +22,33 @@ HINSTANCE GetCurrentResourceDLL() {
return GetModuleHandle(NULL); 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 } // end anonymous namespace
void ResourceBundle::LoadCommonResources() { void ResourceBundle::LoadCommonResources() {
// As a convenience, add the current resource module as a data packs. // As a convenience, add the current resource module as a data packs.
data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); 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"));
}
} }
void ResourceBundle::LoadTestResources(const FilePath& path) { void ResourceBundle::LoadTestResources(const FilePath& path) {
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -32,16 +32,6 @@ bool PathProvider(int key, FilePath* result) { ...@@ -32,16 +32,6 @@ bool PathProvider(int key, FilePath* result) {
#endif #endif
create_dir = true; create_dir = true;
break; 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 // The following are only valid in the development environment, and
// will fail if executed from an installed executable (because the // will fail if executed from an installed executable (because the
// generated path won't exist). // generated path won't exist).
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -18,9 +18,6 @@ enum { ...@@ -18,9 +18,6 @@ enum {
DIR_LOCALES, // Directory where locale resources are stored. 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 // Valid only in development environment; TODO(darin): move these
DIR_TEST_DATA, // Directory where unit test data resides. DIR_TEST_DATA, // Directory where unit test data resides.
......
...@@ -46,13 +46,16 @@ void UITestSuite::Initialize() { ...@@ -46,13 +46,16 @@ void UITestSuite::Initialize() {
PathService::Get(base::DIR_MODULE, &pak_dir); PathService::Get(base::DIR_MODULE, &pak_dir);
pak_dir = pak_dir.AppendASCII("ui_unittests_strings"); pak_dir = pak_dir.AppendASCII("ui_unittests_strings");
PathService::Override(ui::DIR_LOCALES, pak_dir); PathService::Override(ui::DIR_LOCALES, pak_dir);
PathService::Override(ui::FILE_RESOURCES_PAK,
pak_dir.AppendASCII("ui_resources.pak"));
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
// Force unittests to run using en-US so if we test against string // Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language. // output, it'll pass regardless of the system language.
ui::ResourceBundle::InitSharedInstanceWithLocale("en-US"); 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() { void UITestSuite::Shutdown() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment