OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/data_pack.h" | 8 #include "base/data_pack.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 locale_resources_data_ = NULL; | 43 locale_resources_data_ = NULL; |
44 } | 44 } |
45 | 45 |
46 // static | 46 // static |
47 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes( | 47 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes( |
48 DataHandle module, int resource_id) { | 48 DataHandle module, int resource_id) { |
49 DCHECK(module); | 49 DCHECK(module); |
50 return module->GetStaticMemory(resource_id); | 50 return module->GetStaticMemory(resource_id); |
51 } | 51 } |
52 | 52 |
53 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { | 53 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) const { |
54 DCHECK(resources_data_); | 54 DCHECK(resources_data_); |
55 base::StringPiece data; | 55 base::StringPiece data; |
56 if (!resources_data_->GetStringPiece(resource_id, &data)) { | 56 if (!resources_data_->GetStringPiece(resource_id, &data)) { |
57 if (!locale_resources_data_->GetStringPiece(resource_id, &data)) { | 57 if (!locale_resources_data_->GetStringPiece(resource_id, &data)) { |
58 for (size_t i = 0; i < data_packs_.size(); ++i) { | 58 for (size_t i = 0; i < data_packs_.size(); ++i) { |
59 if (data_packs_[i]->GetStringPiece(resource_id, &data)) | 59 if (data_packs_[i]->GetStringPiece(resource_id, &data)) |
60 return data; | 60 return data; |
61 } | 61 } |
62 | 62 |
63 return base::StringPiece(); | 63 return base::StringPiece(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 FilePath locale_file_path = GetLocaleFilePath(app_locale); | 107 FilePath locale_file_path = GetLocaleFilePath(app_locale); |
108 if (locale_file_path.empty()) { | 108 if (locale_file_path.empty()) { |
109 // It's possible that there is no locale.pak. | 109 // It's possible that there is no locale.pak. |
110 NOTREACHED(); | 110 NOTREACHED(); |
111 return std::string(); | 111 return std::string(); |
112 } | 112 } |
113 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); | 113 locale_resources_data_ = LoadResourcesDataPak(locale_file_path); |
114 CHECK(locale_resources_data_) << "failed to load locale.pak"; | 114 CHECK(locale_resources_data_) << "failed to load locale.pak"; |
115 return app_locale; | 115 return app_locale; |
116 } | 116 } |
OLD | NEW |