| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/resource/resource_bundle_win.h" | 5 #include "ui/base/resource/resource_bundle_win.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "skia/ext/image_operations.h" | 10 #include "skia/ext/image_operations.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 HINSTANCE resources_data_dll; | 23 HINSTANCE resources_data_dll; |
| 24 | 24 |
| 25 HINSTANCE GetCurrentResourceDLL() { | 25 HINSTANCE GetCurrentResourceDLL() { |
| 26 if (resources_data_dll) | 26 if (resources_data_dll) |
| 27 return resources_data_dll; | 27 return resources_data_dll; |
| 28 return GetModuleHandle(NULL); | 28 return GetModuleHandle(NULL); |
| 29 } | 29 } |
| 30 | 30 |
| 31 base::FilePath GetResourcesPakFilePath(const std::string& pak_name) { | |
| 32 base::FilePath path; | |
| 33 if (PathService::Get(base::DIR_MODULE, &path)) | |
| 34 return path.AppendASCII(pak_name.c_str()); | |
| 35 | |
| 36 // Return just the name of the pack file. | |
| 37 return base::FilePath(base::ASCIIToUTF16(pak_name)); | |
| 38 } | |
| 39 | |
| 40 } // namespace | 31 } // namespace |
| 41 | 32 |
| 42 void ResourceBundle::LoadCommonResources() { | |
| 43 // As a convenience, add the current resource module as a data packs. | |
| 44 data_packs_.push_back(new ResourceDataDLL(GetCurrentResourceDLL())); | |
| 45 | |
| 46 if (IsScaleFactorSupported(SCALE_FACTOR_100P)) { | |
| 47 AddDataPackFromPath( | |
| 48 GetResourcesPakFilePath("chrome_100_percent.pak"), | |
| 49 SCALE_FACTOR_100P); | |
| 50 } | |
| 51 if (IsScaleFactorSupported(SCALE_FACTOR_200P)) { | |
| 52 DCHECK(gfx::IsHighDPIEnabled()); | |
| 53 AddDataPackFromPath( | |
| 54 GetResourcesPakFilePath("chrome_200_percent.pak"), | |
| 55 SCALE_FACTOR_200P); | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 33 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
| 60 // Flipped image is not used on Windows. | 34 // Flipped image is not used on Windows. |
| 61 DCHECK_EQ(rtl, RTL_DISABLED); | 35 DCHECK_EQ(rtl, RTL_DISABLED); |
| 62 | 36 |
| 63 // Windows only uses SkBitmap for gfx::Image, so this is the same as | 37 // Windows only uses SkBitmap for gfx::Image, so this is the same as |
| 64 // GetImageNamed. | 38 // GetImageNamed. |
| 65 return GetImageNamed(resource_id); | 39 return GetImageNamed(resource_id); |
| 66 } | 40 } |
| 67 | 41 |
| 68 void SetResourcesDataDLL(HINSTANCE handle) { | 42 void SetResourcesDataDLL(HINSTANCE handle) { |
| 69 resources_data_dll = handle; | 43 resources_data_dll = handle; |
| 70 } | 44 } |
| 71 | 45 |
| 72 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { | 46 HICON LoadThemeIconFromResourcesDataDLL(int icon_id) { |
| 73 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); | 47 return ::LoadIcon(GetCurrentResourceDLL(), MAKEINTRESOURCE(icon_id)); |
| 74 } | 48 } |
| 75 | 49 |
| 76 } // namespace ui; | 50 } // namespace ui; |
| OLD | NEW |