Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 if (command_line->HasSwitch(switches::kLocalePak)) { | 156 if (command_line->HasSwitch(switches::kLocalePak)) { |
| 157 locale_file_path = | 157 locale_file_path = |
| 158 command_line->GetSwitchValuePath(switches::kLocalePak); | 158 command_line->GetSwitchValuePath(switches::kLocalePak); |
| 159 } else { | 159 } else { |
| 160 locale_file_path = GetLocaleFilePath(app_locale); | 160 locale_file_path = GetLocaleFilePath(app_locale); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 | 163 |
| 164 if (locale_file_path.empty()) { | 164 if (locale_file_path.empty()) { |
| 165 // It's possible that there is no locale.pak. | 165 // It's possible that there is no locale.pak. |
| 166 DLOG(WARNING) << "locale_file_path.empty()"; | |
| 166 return std::string(); | 167 return std::string(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 scoped_ptr<DataPack> data_pack( | 170 scoped_ptr<DataPack> data_pack( |
| 170 new DataPack(SCALE_FACTOR_100P)); | 171 new DataPack(SCALE_FACTOR_100P)); |
| 171 if (!data_pack->Load(locale_file_path)) { | 172 if (!data_pack->Load(locale_file_path)) { |
| 172 UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError", | 173 UMA_HISTOGRAM_ENUMERATION("ResourceBundle.LoadLocaleResourcesError", |
| 173 logging::GetLastSystemErrorCode(), 16000); | 174 logging::GetLastSystemErrorCode(), 16000); |
| 174 NOTREACHED() << "failed to load locale.pak"; | 175 NOTREACHED() << "failed to load locale.pak"; |
| 175 return std::string(); | 176 return std::string(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 } | 297 } |
| 297 | 298 |
| 298 base::StringPiece ResourceBundle::GetRawDataResource( | 299 base::StringPiece ResourceBundle::GetRawDataResource( |
| 299 int resource_id, | 300 int resource_id, |
| 300 ScaleFactor scale_factor) const { | 301 ScaleFactor scale_factor) const { |
| 301 base::StringPiece data; | 302 base::StringPiece data; |
| 302 if (delegate_ && | 303 if (delegate_ && |
| 303 delegate_->GetRawDataResource(resource_id, scale_factor, &data)) | 304 delegate_->GetRawDataResource(resource_id, scale_factor, &data)) |
| 304 return data; | 305 return data; |
| 305 | 306 |
| 307 // TODO(tony) Firm up locking for or constraints of calling | |
|
tony
2012/06/12 18:33:06
Nit: add a : after the close paren.
| |
| 308 // ReloadLocaleResources() and how to CHECK for misuse. | |
| 306 DCHECK(locale_resources_data_.get()); | 309 DCHECK(locale_resources_data_.get()); |
| 307 if (locale_resources_data_->GetStringPiece(resource_id, &data)) | 310 if (locale_resources_data_->GetStringPiece(resource_id, &data)) |
| 308 return data; | 311 return data; |
| 309 | 312 |
| 310 if (scale_factor != ui::SCALE_FACTOR_100P) { | 313 if (scale_factor != ui::SCALE_FACTOR_100P) { |
| 311 for (size_t i = 0; i < data_packs_.size(); i++) { | 314 for (size_t i = 0; i < data_packs_.size(); i++) { |
| 312 if (data_packs_[i]->GetScaleFactor() == scale_factor && | 315 if (data_packs_[i]->GetScaleFactor() == scale_factor && |
| 313 data_packs_[i]->GetStringPiece(resource_id, &data)) | 316 data_packs_[i]->GetStringPiece(resource_id, &data)) |
| 314 return data; | 317 return data; |
| 315 } | 318 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 SkBitmap bitmap; | 496 SkBitmap bitmap; |
| 494 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); | 497 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 32, 32); |
| 495 bitmap.allocPixels(); | 498 bitmap.allocPixels(); |
| 496 bitmap.eraseARGB(255, 255, 0, 0); | 499 bitmap.eraseARGB(255, 255, 0, 0); |
| 497 empty_image_ = gfx::Image(bitmap); | 500 empty_image_ = gfx::Image(bitmap); |
| 498 } | 501 } |
| 499 return empty_image_; | 502 return empty_image_; |
| 500 } | 503 } |
| 501 | 504 |
| 502 } // namespace ui | 505 } // namespace ui |
| OLD | NEW |