From 8973c3a2aa49807495c55cb8ff6e2e7b31621eaf Mon Sep 17 00:00:00 2001 From: "sail@chromium.org" Date: Wed, 25 Apr 2012 02:24:18 +0000 Subject: Metro/HiDPI: Use metro resource pak in metro mode This CL does the following: - add a new enable_metro build flag - if the build flag is set then add a new metro icon resource pak to chrome - at run time if Chrome is running in metro mode AND ENABLE_METRO is set then use the metro icon resource pak BUG=114311 TEST= Review URL: http://codereview.chromium.org/10082020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133843 0039d316-1c4b-4281-b951-d872f2087c98 --- build/common.gypi | 9 +++++++++ chrome/app/theme/theme_resources_metro_1x.grd | 4 ++-- chrome/chrome_resources.gyp | 17 +++++++++++++++++ chrome/installer/mini_installer/chrome.release | 3 +++ chrome/tools/build/win/FILES.cfg | 5 +++++ chrome/tools/build/win/create_installer_archive.py | 13 +++++++++---- chrome/tools/build/win/release.rules | 2 +- tools/gritsettings/resource_ids | 3 +++ ui/base/resource/resource_bundle_win.cc | 20 ++++++++++++++++---- ui/base/win/metro.cc | 20 ++++++++++++++++++++ ui/base/win/metro.h | 18 ++++++++++++++++++ ui/ui.gyp | 2 ++ 12 files changed, 105 insertions(+), 11 deletions(-) create mode 100644 ui/base/win/metro.cc create mode 100644 ui/base/win/metro.h diff --git a/build/common.gypi b/build/common.gypi index db5bf66..5889045 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -43,6 +43,9 @@ # Enable HiDPI support. 'enable_hidpi%': 0, + + # Enable Metro support. + 'enable_metro%': 0, }, # Copy conditionally-set variables out one scope. 'chromeos%': '<(chromeos)', @@ -53,6 +56,7 @@ 'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'enable_viewport%': '<(enable_viewport)', 'enable_hidpi%': '<(enable_hidpi)', + 'enable_metro%': '<(enable_metro)', # Compute the architecture that we're building on. 'conditions': [ @@ -105,6 +109,7 @@ 'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'enable_viewport%': '<(enable_viewport)', 'enable_hidpi%': '<(enable_hidpi)', + 'enable_metro%': '<(enable_metro)', # We used to provide a variable for changing how libraries were built. # This variable remains until we can clean up all the users. @@ -503,6 +508,7 @@ 'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'enable_viewport%': '<(enable_viewport)', 'enable_hidpi%': '<(enable_hidpi)', + 'enable_metro%': '<(enable_metro)', 'use_xi2_mt%':'<(use_xi2_mt)', 'file_manager_extension%': '<(file_manager_extension)', 'webui_task_manager%': '<(webui_task_manager)', @@ -1301,6 +1307,9 @@ ['enable_hidpi==1', { 'defines': ['ENABLE_HIDPI=1'], }], + ['enable_metro==1', { + 'defines': ['ENABLE_METRO=1'], + }], ['fastbuild!=0', { 'conditions': [ diff --git a/chrome/app/theme/theme_resources_metro_1x.grd b/chrome/app/theme/theme_resources_metro_1x.grd index 610b9ae..a7eed02 100644 --- a/chrome/app/theme/theme_resources_metro_1x.grd +++ b/chrome/app/theme/theme_resources_metro_1x.grd @@ -1,10 +1,10 @@ - + - + diff --git a/chrome/chrome_resources.gyp b/chrome/chrome_resources.gyp index 18f88fb..31de62b 100644 --- a/chrome/chrome_resources.gyp +++ b/chrome/chrome_resources.gyp @@ -217,6 +217,13 @@ }, 'includes': [ '../build/grit_action.gypi' ], }, + { + 'action_name': 'theme_resources_metro_1x', + 'variables': { + 'grit_grd_file': 'app/theme/theme_resources_metro_1x.grd', + }, + 'includes': [ '../build/grit_action.gypi' ], + }, ], 'includes': [ '../build/grit_target.gypi' ], }, @@ -260,6 +267,16 @@ }, ], }], + ['enable_metro == 1', { + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)', + 'files': [ + '<(grit_out_dir)/theme_resources_metro_1x.pak', + ], + }, + ], + }], ], }, { diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release index b99fab4..1b63134 100644 --- a/chrome/installer/mini_installer/chrome.release +++ b/chrome/installer/mini_installer/chrome.release @@ -36,6 +36,9 @@ default_apps\external_extensions.json: %(VersionDir)s\default_apps\ theme_resources_2x.pak: %(VersionDir)s\ ui_resources_2x.pak: %(VersionDir)s\ +[METRO] +theme_resources_metro_1x.pak: %(VersionDir)s\ + [GOOGLE_CHROME] splash-620x300.png: %(ChromeDir)s\ Logo.png: %(ChromeDir)s\ diff --git a/chrome/tools/build/win/FILES.cfg b/chrome/tools/build/win/FILES.cfg index 7fc10bd..5a9aac6 100644 --- a/chrome/tools/build/win/FILES.cfg +++ b/chrome/tools/build/win/FILES.cfg @@ -352,6 +352,11 @@ FILES = [ 'buildtype': ['dev', 'official'], }, { + 'filename': 'theme_resources_metro_1x.pak', + 'arch': ['32bit', '64bit'], + 'buildtype': ['dev', 'official'], + }, + { 'filename': 'ui_resources_standard.pak', '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 2e85d9b..cab244c 100755 --- a/chrome/tools/build/win/create_installer_archive.py +++ b/chrome/tools/build/win/create_installer_archive.py @@ -1,5 +1,5 @@ #!/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 # found in the LICENSE file. @@ -90,7 +90,7 @@ def CompressUsingLZMA(build_dir, compressed_file, input_file): def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir, - enable_hidpi): + enable_hidpi, enable_metro): """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. @@ -103,6 +103,8 @@ def CopyAllFilesToStagingDir(config, distribution, staging_dir, build_dir, staging_dir, build_dir) if enable_hidpi == '1': CopySectionFilesToStagingDir(config, 'HIDPI', staging_dir, build_dir) + if enable_metro == '1': + CopySectionFilesToStagingDir(config, 'METRO', staging_dir, build_dir) def CopySectionFilesToStagingDir(config, section, staging_dir, build_dir): @@ -328,12 +330,12 @@ def main(options): if options.build_dir != options.output_dir: CopyAllFilesToStagingDir(config, options.distribution, staging_dir, options.output_dir, - options.enable_hidpi) + options.enable_hidpi, options.enable_metro) # Now copy the remainder of the files from the build dir. CopyAllFilesToStagingDir(config, options.distribution, staging_dir, options.build_dir, - options.enable_hidpi) + options.enable_hidpi, options.enable_metro) version_numbers = current_version.split('.') current_build_number = version_numbers[2] + '.' + version_numbers[3] @@ -387,6 +389,9 @@ def _ParseOptions(): help='Name used to prefix names of generated archives.') parser.add_option('--enable_hidpi', default='0', help='Whether to include HiDPI resource files.') + parser.add_option('--enable_metro', default='0', + help='Whether to include resource files from the "METRO" section of the ' + 'input file.') 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 cd3212b..0f98ef2 100644 --- a/chrome/tools/build/win/release.rules +++ b/chrome/tools/build/win/release.rules @@ -7,7 +7,7 @@ 1.5; #endif - if (!use_hidpi_pak) { - AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); - AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); - } else { + bool use_metro_pak = false; +#if defined(ENABLE_METRO) + use_metro_pak = ui::IsInMetroMode(); +#endif + + if (use_metro_pak) { + AddDataPack(GetResourcesPakFilePath("theme_resources_metro_1x.pak")); + } else if (use_hidpi_pak) { AddDataPack(GetResourcesPakFilePath("theme_resources_2x.pak")); + } else { + AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); + } + + if (use_hidpi_pak) { AddDataPack(GetResourcesPakFilePath("ui_resources_2x.pak")); + } else { + AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); } } diff --git a/ui/base/win/metro.cc b/ui/base/win/metro.cc new file mode 100644 index 0000000..1426278 --- /dev/null +++ b/ui/base/win/metro.cc @@ -0,0 +1,20 @@ +// 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. + +#include "ui/base/win/metro.h" + +#include +#include + +namespace ui { + +bool IsInMetroMode() { + const char* kMetroModeEnvVar = "CHROME_METRO_DLL"; + char buffer[2]; + if (!::GetEnvironmentVariableA(kMetroModeEnvVar, buffer, arraysize(buffer))) + return false; + return buffer == std::string("1"); +} + +} // namespace ui diff --git a/ui/base/win/metro.h b/ui/base/win/metro.h new file mode 100644 index 0000000..6f7ff87 --- /dev/null +++ b/ui/base/win/metro.h @@ -0,0 +1,18 @@ +// 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. + +#ifndef UI_BASE_WIN_METRO_H_ +#define UI_BASE_WIN_METRO_H_ +#pragma once + +#include "base/basictypes.h" +#include "ui/base/ui_export.h" + +namespace ui { + +UI_EXPORT bool IsInMetroMode(); + +} // namespace ui + +#endif // UI_BASE_WIN_METRO_H_ diff --git a/ui/ui.gyp b/ui/ui.gyp index e8089a1..f998b79 100644 --- a/ui/ui.gyp +++ b/ui/ui.gyp @@ -259,6 +259,8 @@ 'base/win/ime_input.h', 'base/win/message_box_win.cc', 'base/win/message_box_win.h', + 'base/win/metro.cc', + 'base/win/metro.h', 'base/win/mouse_wheel_util.cc', 'base/win/mouse_wheel_util.h', 'base/win/scoped_ole_initializer.cc', -- cgit v1.1