| 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.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "ui/base/resource/resource_handle.h" |
| 11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "ui/base/gtk/scoped_gobject.h" | 14 #include "ui/base/gtk/scoped_gobject.h" |
| 14 #include "ui/base/ui_base_paths.h" | 15 #include "ui/base/ui_base_paths.h" |
| 15 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
| 16 | 17 |
| 17 #include <gtk/gtk.h> | 18 #include <gtk/gtk.h> |
| 18 | 19 |
| 19 namespace ui { | 20 namespace ui { |
| 20 | 21 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 FilePath GetResourcesPakFilePath(const std::string& pak_name) { | 55 FilePath GetResourcesPakFilePath(const std::string& pak_name) { |
| 55 FilePath path; | 56 FilePath path; |
| 56 if (PathService::Get(base::DIR_MODULE, &path)) | 57 if (PathService::Get(base::DIR_MODULE, &path)) |
| 57 return path.AppendASCII(pak_name.c_str()); | 58 return path.AppendASCII(pak_name.c_str()); |
| 58 return FilePath(); | 59 return FilePath(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 } // namespace | 62 } // namespace |
| 62 | 63 |
| 63 void ResourceBundle::LoadCommonResources() { | 64 void ResourceBundle::LoadCommonResources() { |
| 64 AddDataPack(GetResourcesPakFilePath("chrome.pak")); | 65 AddDataPack(GetResourcesPakFilePath("chrome.pak"), |
| 65 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak")); | 66 ResourceHandle::kScaleFactor100x); |
| 66 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak")); | 67 AddDataPack(GetResourcesPakFilePath("theme_resources_standard.pak"), |
| 68 ResourceHandle::kScaleFactor100x); |
| 69 AddDataPack(GetResourcesPakFilePath("ui_resources_standard.pak"), |
| 70 ResourceHandle::kScaleFactor100x); |
| 67 } | 71 } |
| 68 | 72 |
| 69 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { | 73 gfx::Image& ResourceBundle::GetNativeImageNamed(int resource_id, ImageRTL rtl) { |
| 70 // Use the negative |resource_id| for the key for BIDI-aware images. | 74 // Use the negative |resource_id| for the key for BIDI-aware images. |
| 71 int key = rtl == RTL_ENABLED ? -resource_id : resource_id; | 75 int key = rtl == RTL_ENABLED ? -resource_id : resource_id; |
| 72 | 76 |
| 73 // Check to see if the image is already in the cache. | 77 // Check to see if the image is already in the cache. |
| 74 { | 78 { |
| 75 base::AutoLock lock_scope(*images_and_fonts_lock_); | 79 base::AutoLock lock_scope(*images_and_fonts_lock_); |
| 76 ImageMap::const_iterator found = images_.find(key); | 80 ImageMap::const_iterator found = images_.find(key); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 96 images_[key] = image; | 100 images_[key] = image; |
| 97 return *image; | 101 return *image; |
| 98 } | 102 } |
| 99 | 103 |
| 100 LOG(WARNING) << "Unable to pixbuf with id " << resource_id; | 104 LOG(WARNING) << "Unable to pixbuf with id " << resource_id; |
| 101 NOTREACHED(); // Want to assert in debug mode. | 105 NOTREACHED(); // Want to assert in debug mode. |
| 102 return *GetEmptyImage(); | 106 return *GetEmptyImage(); |
| 103 } | 107 } |
| 104 | 108 |
| 105 } // namespace ui | 109 } // namespace ui |
| OLD | NEW |