summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 02:12:11 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 02:12:11 +0000
commit2e317bffec137548f6240fff37b70b5f4b372740 (patch)
tree3db7b06819fcd1e729530a801dccaa74653a2644 /ui
parent83d9dc34879eb006cb7f3ba53f0e6ec5e24772a9 (diff)
downloadchromium_src-2e317bffec137548f6240fff37b70b5f4b372740.zip
chromium_src-2e317bffec137548f6240fff37b70b5f4b372740.tar.gz
chromium_src-2e317bffec137548f6240fff37b70b5f4b372740.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. Review URL: http://codereview.chromium.org/10024050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-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.cc12
-rw-r--r--ui/base/ui_base_paths.h5
-rw-r--r--ui/test/test_suite.cc7
7 files changed, 70 insertions, 26 deletions
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 b295b50..79355d6 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"));
+ }
}
void ResourceBundle::LoadTestResources(const FilePath& path) {
diff --git a/ui/base/ui_base_paths.cc b/ui/base/ui_base_paths.cc
index 14897f0..b216c7e 100644
--- a/ui/base/ui_base_paths.cc
+++ b/ui/base/ui_base_paths.cc
@@ -1,4 +1,4 @@
-// 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.
@@ -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..6d58d49 100644
--- a/ui/base/ui_base_paths.h
+++ b/ui/base/ui_base_paths.h
@@ -1,4 +1,4 @@
-// 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.
@@ -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() {