Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: app/resource_bundle_mac.mm

Issue 338028: ResourceBundle::GetRawDataResource should fall back to localized resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « app/resource_bundle_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « app/resource_bundle_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698