OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/resource_bundle.h" | 5 #include "app/resource_bundle.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
| 9 #include "app/app_paths.h" |
9 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
10 #include "app/gfx/gtk_util.h" | 11 #include "app/gfx/gtk_util.h" |
11 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
12 #include "base/base_paths.h" | 13 #include "base/base_paths.h" |
13 #include "base/data_pack.h" | 14 #include "base/data_pack.h" |
14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
15 #include "base/file_util.h" | 16 #include "base/file_util.h" |
16 #include "base/gfx/gtk_util.h" | 17 #include "base/gfx/gtk_util.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
19 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
20 #include "base/string_util.h" | 21 #include "base/string_util.h" |
21 #include "chrome/common/chrome_paths.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "SkBitmap.h" | |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned | 26 // Convert the raw image data into a GdkPixbuf. The GdkPixbuf that is returned |
27 // has a ref count of 1 so the caller must call g_object_unref to free the | 27 // has a ref count of 1 so the caller must call g_object_unref to free the |
28 // memory. | 28 // memory. |
29 GdkPixbuf* LoadPixbuf(std::vector<unsigned char>& data) { | 29 GdkPixbuf* LoadPixbuf(std::vector<unsigned char>& data) { |
30 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); | 30 ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); |
31 bool ok = gdk_pixbuf_loader_write(loader.get(), | 31 bool ok = gdk_pixbuf_loader_write(loader.get(), |
32 static_cast<guint8*>(data.data()), data.size(), NULL); | 32 static_cast<guint8*>(data.data()), data.size(), NULL); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 locale_resources_data_ = new base::DataPack; | 90 locale_resources_data_ = new base::DataPack; |
91 success = locale_resources_data_->Load(locale_path); | 91 success = locale_resources_data_->Load(locale_path); |
92 DCHECK(success) << "failed to load locale pak file"; | 92 DCHECK(success) << "failed to load locale pak file"; |
93 } | 93 } |
94 | 94 |
95 FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) { | 95 FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) { |
96 FilePath locale_path; | 96 FilePath locale_path; |
97 PathService::Get(chrome::DIR_LOCALES, &locale_path); | 97 PathService::Get(app::DIR_LOCALES, &locale_path); |
98 | 98 |
99 const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale); | 99 const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale); |
100 if (app_locale.empty()) | 100 if (app_locale.empty()) |
101 return FilePath(); | 101 return FilePath(); |
102 | 102 |
103 return locale_path.Append(WideToASCII(app_locale + L".pak")); | 103 return locale_path.Append(WideToASCII(app_locale + L".pak")); |
104 } | 104 } |
105 | 105 |
106 void ResourceBundle::LoadThemeResources() { | 106 void ResourceBundle::LoadThemeResources() { |
107 FilePath theme_data_path; | 107 FilePath theme_data_path; |
108 PathService::Get(chrome::DIR_THEMES, &theme_data_path); | 108 PathService::Get(app::DIR_THEMES, &theme_data_path); |
109 theme_data_path = theme_data_path.Append(FILE_PATH_LITERAL("default.pak")); | 109 theme_data_path = theme_data_path.Append(FILE_PATH_LITERAL("default.pak")); |
110 theme_data_ = new base::DataPack; | 110 theme_data_ = new base::DataPack; |
111 bool success = theme_data_->Load(theme_data_path); | 111 bool success = theme_data_->Load(theme_data_path); |
112 DCHECK(success) << "failed to load theme data"; | 112 DCHECK(success) << "failed to load theme data"; |
113 } | 113 } |
114 | 114 |
115 /* static */ | 115 /* static */ |
116 bool ResourceBundle::LoadResourceBytes(DataHandle module, int resource_id, | 116 bool ResourceBundle::LoadResourceBytes(DataHandle module, int resource_id, |
117 std::vector<unsigned char>* bytes) { | 117 std::vector<unsigned char>* bytes) { |
118 DCHECK(module); | 118 DCHECK(module); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // This bitmap will be leaked, but this code should never be hit. | 200 // This bitmap will be leaked, but this code should never be hit. |
201 scoped_ptr<SkBitmap> skia_bitmap(new SkBitmap()); | 201 scoped_ptr<SkBitmap> skia_bitmap(new SkBitmap()); |
202 skia_bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 202 skia_bitmap->setConfig(SkBitmap::kARGB_8888_Config, 32, 32); |
203 skia_bitmap->allocPixels(); | 203 skia_bitmap->allocPixels(); |
204 skia_bitmap->eraseARGB(255, 255, 0, 0); | 204 skia_bitmap->eraseARGB(255, 255, 0, 0); |
205 empty_bitmap = gfx::GdkPixbufFromSkBitmap(skia_bitmap.get()); | 205 empty_bitmap = gfx::GdkPixbufFromSkBitmap(skia_bitmap.get()); |
206 } | 206 } |
207 return empty_bitmap; | 207 return empty_bitmap; |
208 } | 208 } |
209 } | 209 } |
OLD | NEW |