| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/base/resource/resource_bundle.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "ui/base/layout.h" | |
| 11 #include "ui/base/resource/resource_handle.h" | |
| 12 #include "ui/base/ui_base_paths.h" | |
| 13 #include "ui/base/ui_base_switches.h" | |
| 14 #include "ui/gfx/display.h" | |
| 15 #include "ui/gfx/image/image.h" | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 base::FilePath GetResourcesPakFilePath(const std::string& pak_name) { | |
| 20 base::FilePath path; | |
| 21 if (PathService::Get(base::DIR_MODULE, &path)) | |
| 22 return path.AppendASCII(pak_name.c_str()); | |
| 23 | |
| 24 // Return just the name of the pack file. | |
| 25 return base::FilePath(pak_name.c_str()); | |
| 26 } | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 namespace ui { | |
| 31 | |
| 32 void ResourceBundle::LoadCommonResources() { | |
| 33 // Always load the 1x data pack first as the 2x data pack contains both 1x and | |
| 34 // 2x images. The 1x data pack only has 1x images, thus passes in an accurate | |
| 35 // scale factor to gfx::ImageSkia::AddRepresentation. | |
| 36 | |
| 37 AddDataPackFromPath(GetResourcesPakFilePath("chrome.pak"), | |
| 38 SCALE_FACTOR_NONE); | |
| 39 AddDataPackFromPath(GetResourcesPakFilePath( | |
| 40 "chrome_100_percent.pak"), SCALE_FACTOR_100P); | |
| 41 | |
| 42 if (ui::IsScaleFactorSupported(SCALE_FACTOR_200P)) { | |
| 43 AddOptionalDataPackFromPath(GetResourcesPakFilePath( | |
| 44 "chrome_200_percent.pak"), SCALE_FACTOR_200P); | |
| 45 } | |
| 46 } | |
| 47 | |
| 48 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | |
| 49 // Flipped image is not used on ChromeOS. | |
| 50 DCHECK_EQ(rtl, RTL_DISABLED); | |
| 51 return GetImageNamed(resource_id); | |
| 52 } | |
| 53 | |
| 54 } // namespace ui | |
| OLD | NEW |