Chromium Code Reviews

Side by Side Diff: app/resource_bundle_mac.mm

Issue 173363: Add a helper to resource bundle to get an NSImage back.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « app/resource_bundle.h ('k') | skia/skia.gyp » ('j') | 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"
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/data_pack.h" 12 #include "base/data_pack.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/mac_util.h" 16 #include "base/mac_util.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/string_piece.h" 18 #include "base/string_piece.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "skia/ext/skia_utils_mac.h"
20 21
21 ResourceBundle::~ResourceBundle() { 22 ResourceBundle::~ResourceBundle() {
22 FreeImages(); 23 FreeImages();
23 24
24 delete locale_resources_data_; 25 delete locale_resources_data_;
25 locale_resources_data_ = NULL; 26 locale_resources_data_ = NULL;
26 delete theme_data_; 27 delete theme_data_;
27 theme_data_ = NULL; 28 theme_data_ = NULL;
28 delete resources_data_; 29 delete resources_data_;
29 resources_data_ = NULL; 30 resources_data_ = NULL;
(...skipping 79 matching lines...)
109 NOTREACHED() << "unable to find resource: " << message_id; 110 NOTREACHED() << "unable to find resource: " << message_id;
110 return string16(); 111 return string16();
111 } 112 }
112 } 113 }
113 114
114 // Data pack encodes strings as UTF16. 115 // Data pack encodes strings as UTF16.
115 string16 msg(reinterpret_cast<const char16*>(data.data()), 116 string16 msg(reinterpret_cast<const char16*>(data.data()),
116 data.length() / 2); 117 data.length() / 2);
117 return msg; 118 return msg;
118 } 119 }
120
121 NSImage* ResourceBundle::GetNSImageNamed(int resource_id) {
122 // 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.
124 SkBitmap* bitmap = GetBitmapNamed(resource_id);
125 if (!bitmap)
126 return nil;
127
128 NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap);
129 return nsimage;
130 }
OLDNEW
« no previous file with comments | « app/resource_bundle.h ('k') | skia/skia.gyp » ('j') | no next file with comments »

Powered by Google App Engine