| 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 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "app/gfx/font.h" | 9 #include "app/gfx/font.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (!module->Get(resource_id, &bytes)) | 79 if (!module->Get(resource_id, &bytes)) |
| 80 return NULL; | 80 return NULL; |
| 81 | 81 |
| 82 return new RefCountedStaticMemory( | 82 return new RefCountedStaticMemory( |
| 83 reinterpret_cast<const unsigned char*>(bytes.data()), bytes.length()); | 83 reinterpret_cast<const unsigned char*>(bytes.data()), bytes.length()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { | 86 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { |
| 87 DCHECK(resources_data_); | 87 DCHECK(resources_data_); |
| 88 base::StringPiece data; | 88 base::StringPiece data; |
| 89 if (!resources_data_->Get(resource_id, &data)) | 89 |
| 90 return base::StringPiece(); | 90 if (!resources_data_->Get(resource_id, &data)) { |
| 91 if (!locale_resources_data_->Get(resource_id, &data)) { |
| 92 return base::StringPiece(); |
| 93 } |
| 94 } |
| 95 |
| 91 return data; | 96 return data; |
| 92 } | 97 } |
| 93 | 98 |
| 94 string16 ResourceBundle::GetLocalizedString(int message_id) { | 99 string16 ResourceBundle::GetLocalizedString(int message_id) { |
| 95 // If for some reason we were unable to load a resource dll, return an empty | 100 // If for some reason we were unable to load a resource dll, return an empty |
| 96 // string (better than crashing). | 101 // string (better than crashing). |
| 97 if (!locale_resources_data_) { | 102 if (!locale_resources_data_) { |
| 98 LOG(WARNING) << "locale resources are not loaded"; | 103 LOG(WARNING) << "locale resources are not loaded"; |
| 99 return string16(); | 104 return string16(); |
| 100 } | 105 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 119 NSImage* ResourceBundle::GetNSImageNamed(int resource_id) { | 124 NSImage* ResourceBundle::GetNSImageNamed(int resource_id) { |
| 120 // Currently this doesn't make a cache holding these as NSImages because | 125 // Currently this doesn't make a cache holding these as NSImages because |
| 121 // GetBitmapNamed has a cache, and we don't want to double cache. | 126 // GetBitmapNamed has a cache, and we don't want to double cache. |
| 122 SkBitmap* bitmap = GetBitmapNamed(resource_id); | 127 SkBitmap* bitmap = GetBitmapNamed(resource_id); |
| 123 if (!bitmap) | 128 if (!bitmap) |
| 124 return nil; | 129 return nil; |
| 125 | 130 |
| 126 NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap); | 131 NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap); |
| 127 return nsimage; | 132 return nsimage; |
| 128 } | 133 } |
| OLD | NEW |