Chromium Code Reviews| 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 "chrome/common/resource_bundle.h" | 5 #include "chrome/common/resource_bundle.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/data_pack.h" | 10 #include "base/data_pack.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 void ResourceBundle::LoadResources(const std::wstring& pref_locale) { | 32 void ResourceBundle::LoadResources(const std::wstring& pref_locale) { |
| 33 FilePath resources_data_path; | 33 FilePath resources_data_path; |
| 34 PathService::Get(base::DIR_EXE, &resources_data_path); | 34 PathService::Get(base::DIR_EXE, &resources_data_path); |
| 35 resources_data_path = resources_data_path.Append( | 35 resources_data_path = resources_data_path.Append( |
| 36 FILE_PATH_LITERAL("chrome.pak")); | 36 FILE_PATH_LITERAL("chrome.pak")); |
| 37 DCHECK(resources_data_ == NULL) << "resource data already loaded!"; | 37 DCHECK(resources_data_ == NULL) << "resource data already loaded!"; |
| 38 resources_data_ = new base::DataPack; | 38 resources_data_ = new base::DataPack; |
| 39 bool success = resources_data_->Load(resources_data_path); | 39 bool success = resources_data_->Load(resources_data_path); |
| 40 DCHECK(success) << "failed to load chrome.pak"; | 40 DCHECK(success) << "failed to load chrome.pak"; |
| 41 | 41 |
| 42 FilePath locale_path; | |
| 43 PathService::Get(chrome::DIR_LOCALES, &locale_path); | |
| 44 // TODO(tc): Handle other locales properly. | |
| 45 // http://code.google.com/p/chromium/issues/detail?id=8125 | |
| 46 locale_path = locale_path.Append(FILE_PATH_LITERAL("en-US.pak")); | |
| 47 DCHECK(locale_resources_data_ == NULL) << "locale data already loaded!"; | 42 DCHECK(locale_resources_data_ == NULL) << "locale data already loaded!"; |
| 43 const FilePath& locale_path = GetLocaleFilePath(pref_locale); | |
| 44 if (locale_path.value().empty()) { | |
| 45 // It's possible that there are no locale dlls found, in which case we just | |
| 46 // return. | |
| 47 NOTREACHED(); | |
| 48 return; | |
|
Evan Martin
2009/03/06 20:39:53
Shouldn't we die horribly here?
| |
| 49 } | |
| 50 | |
| 48 locale_resources_data_ = new base::DataPack; | 51 locale_resources_data_ = new base::DataPack; |
| 49 success = locale_resources_data_->Load(locale_path); | 52 success = locale_resources_data_->Load(locale_path); |
| 50 DCHECK(success) << "failed to load locale pak file"; | 53 DCHECK(success) << "failed to load locale pak file"; |
| 51 } | 54 } |
| 52 | 55 |
| 53 FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) { | 56 FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) { |
| 54 FilePath locale_path; | 57 FilePath locale_path; |
| 55 PathService::Get(chrome::DIR_LOCALES, &locale_path); | 58 PathService::Get(chrome::DIR_LOCALES, &locale_path); |
| 56 | 59 |
| 57 const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale); | 60 const std::wstring app_locale = l10n_util::GetApplicationLocale(pref_locale); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); | 136 GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
| 134 DCHECK(pixbuf) << "failed to load " << resource_id << " " << data.size(); | 137 DCHECK(pixbuf) << "failed to load " << resource_id << " " << data.size(); |
| 135 | 138 |
| 136 // The pixbuf is owned by the loader, so add a ref so when we delete the | 139 // The pixbuf is owned by the loader, so add a ref so when we delete the |
| 137 // loader, the pixbuf still exists. | 140 // loader, the pixbuf still exists. |
| 138 g_object_ref(pixbuf); | 141 g_object_ref(pixbuf); |
| 139 g_object_unref(loader); | 142 g_object_unref(loader); |
| 140 | 143 |
| 141 return pixbuf; | 144 return pixbuf; |
| 142 } | 145 } |
| OLD | NEW |