| 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/app_paths.h" |
| 10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 FreeImages(); | 60 FreeImages(); |
| 61 // Free GdkPixbufs. | 61 // Free GdkPixbufs. |
| 62 for (GdkPixbufMap::iterator i = gdk_pixbufs_.begin(); | 62 for (GdkPixbufMap::iterator i = gdk_pixbufs_.begin(); |
| 63 i != gdk_pixbufs_.end(); i++) { | 63 i != gdk_pixbufs_.end(); i++) { |
| 64 g_object_unref(i->second); | 64 g_object_unref(i->second); |
| 65 } | 65 } |
| 66 gdk_pixbufs_.clear(); | 66 gdk_pixbufs_.clear(); |
| 67 | 67 |
| 68 delete locale_resources_data_; | 68 delete locale_resources_data_; |
| 69 locale_resources_data_ = NULL; | 69 locale_resources_data_ = NULL; |
| 70 delete theme_data_; | |
| 71 theme_data_ = NULL; | |
| 72 delete resources_data_; | 70 delete resources_data_; |
| 73 resources_data_ = NULL; | 71 resources_data_ = NULL; |
| 72 theme_data_ = NULL; |
| 74 } | 73 } |
| 75 | 74 |
| 76 void ResourceBundle::LoadResources(const std::wstring& pref_locale) { | 75 void ResourceBundle::LoadResources(const std::wstring& pref_locale) { |
| 77 FilePath resources_data_path; | 76 FilePath resources_data_path; |
| 78 PathService::Get(base::DIR_EXE, &resources_data_path); | 77 PathService::Get(base::DIR_EXE, &resources_data_path); |
| 79 resources_data_path = resources_data_path.Append( | 78 resources_data_path = resources_data_path.Append( |
| 80 FILE_PATH_LITERAL("chrome.pak")); | 79 FILE_PATH_LITERAL("chrome.pak")); |
| 81 DCHECK(resources_data_ == NULL) << "resource data already loaded!"; | 80 DCHECK(resources_data_ == NULL) << "resource data already loaded!"; |
| 82 resources_data_ = new base::DataPack; | 81 resources_data_ = new base::DataPack; |
| 83 bool success = resources_data_->Load(resources_data_path); | 82 bool success = resources_data_->Load(resources_data_path); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 PathService::Get(app::DIR_LOCALES, &locale_path); | 101 PathService::Get(app::DIR_LOCALES, &locale_path); |
| 103 | 102 |
| 104 const std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); | 103 const std::string app_locale = l10n_util::GetApplicationLocale(pref_locale); |
| 105 if (app_locale.empty()) | 104 if (app_locale.empty()) |
| 106 return FilePath(); | 105 return FilePath(); |
| 107 | 106 |
| 108 return locale_path.AppendASCII(app_locale + ".pak"); | 107 return locale_path.AppendASCII(app_locale + ".pak"); |
| 109 } | 108 } |
| 110 | 109 |
| 111 void ResourceBundle::LoadThemeResources() { | 110 void ResourceBundle::LoadThemeResources() { |
| 112 FilePath theme_data_path; | 111 // The data has been merged with chrome.pak so just set the pointer to be |
| 113 PathService::Get(app::DIR_THEMES, &theme_data_path); | 112 // the same file. |
| 114 theme_data_path = theme_data_path.Append(FILE_PATH_LITERAL("default.pak")); | 113 DCHECK(resources_data_); |
| 115 theme_data_ = new base::DataPack; | 114 theme_data_ = resources_data_; |
| 116 bool success = theme_data_->Load(theme_data_path); | |
| 117 DCHECK(success) << "failed to load theme data"; | |
| 118 } | 115 } |
| 119 | 116 |
| 120 // static | 117 // static |
| 121 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes( | 118 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes( |
| 122 DataHandle module, int resource_id) { | 119 DataHandle module, int resource_id) { |
| 123 DCHECK(module); | 120 DCHECK(module); |
| 124 return module->GetStaticMemory(resource_id); | 121 return module->GetStaticMemory(resource_id); |
| 125 } | 122 } |
| 126 | 123 |
| 127 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { | 124 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 208 } |
| 212 } | 209 } |
| 213 | 210 |
| 214 GdkPixbuf* ResourceBundle::GetPixbufNamed(int resource_id) { | 211 GdkPixbuf* ResourceBundle::GetPixbufNamed(int resource_id) { |
| 215 return GetPixbufImpl(resource_id, false); | 212 return GetPixbufImpl(resource_id, false); |
| 216 } | 213 } |
| 217 | 214 |
| 218 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) { | 215 GdkPixbuf* ResourceBundle::GetRTLEnabledPixbufNamed(int resource_id) { |
| 219 return GetPixbufImpl(resource_id, true); | 216 return GetPixbufImpl(resource_id, true); |
| 220 } | 217 } |
| OLD | NEW |