| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 locale_resources_data_ = LoadResourceDataPack(@"locale"); | 64 locale_resources_data_ = LoadResourceDataPack(@"locale"); |
| 65 DCHECK(locale_resources_data_) << "failed to load locale.pak"; | 65 DCHECK(locale_resources_data_) << "failed to load locale.pak"; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ResourceBundle::LoadThemeResources() { | 68 void ResourceBundle::LoadThemeResources() { |
| 69 DCHECK(theme_data_ == NULL) << "theme data already loaded!"; | 69 DCHECK(theme_data_ == NULL) << "theme data already loaded!"; |
| 70 theme_data_ = LoadResourceDataPack(@"theme"); | 70 theme_data_ = LoadResourceDataPack(@"theme"); |
| 71 DCHECK(theme_data_) << "failed to load theme.pak"; | 71 DCHECK(theme_data_) << "failed to load theme.pak"; |
| 72 } | 72 } |
| 73 | 73 |
| 74 /* static */ | 74 // static |
| 75 bool ResourceBundle::LoadResourceBytes(DataHandle module, int resource_id, | 75 RefCountedStaticMemory* ResourceBundle::LoadResourceBytes( |
| 76 std::vector<unsigned char>* bytes) { | 76 DataHandle module, int resource_id) { |
| 77 DCHECK(module); | 77 DCHECK(module); |
| 78 base::StringPiece data; | 78 base::StringPiece bytes; |
| 79 if (!module->Get(resource_id, &data)) | 79 if (!module->Get(resource_id, &bytes)) |
| 80 return false; | 80 return NULL; |
| 81 | 81 |
| 82 bytes->resize(data.length()); | 82 return new RefCountedStaticMemory( |
| 83 memcpy(&(bytes->front()), data.data(), data.length()); | 83 reinterpret_cast<const unsigned char*>(bytes.data()), bytes.length()); |
| 84 | |
| 85 return true; | |
| 86 } | 84 } |
| 87 | 85 |
| 88 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { | 86 base::StringPiece ResourceBundle::GetRawDataResource(int resource_id) { |
| 89 DCHECK(resources_data_); | 87 DCHECK(resources_data_); |
| 90 base::StringPiece data; | 88 base::StringPiece data; |
| 91 if (!resources_data_->Get(resource_id, &data)) | 89 if (!resources_data_->Get(resource_id, &data)) |
| 92 return base::StringPiece(); | 90 return base::StringPiece(); |
| 93 return data; | 91 return data; |
| 94 } | 92 } |
| 95 | 93 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 121 NSImage* ResourceBundle::GetNSImageNamed(int resource_id) { | 119 NSImage* ResourceBundle::GetNSImageNamed(int resource_id) { |
| 122 // Currently this doesn't make a cache holding these as NSImages because | 120 // Currently this doesn't make a cache holding these as NSImages because |
| 123 // GetBitmapNamed has a cache, and we don't want to double cache. | 121 // GetBitmapNamed has a cache, and we don't want to double cache. |
| 124 SkBitmap* bitmap = GetBitmapNamed(resource_id); | 122 SkBitmap* bitmap = GetBitmapNamed(resource_id); |
| 125 if (!bitmap) | 123 if (!bitmap) |
| 126 return nil; | 124 return nil; |
| 127 | 125 |
| 128 NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap); | 126 NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap); |
| 129 return nsimage; | 127 return nsimage; |
| 130 } | 128 } |
| OLD | NEW |