blob: 94ef31a6eaebc8b72cfaf61510e4a0d7185a37b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/resource_bundle.h"
#import <Foundation/Foundation.h>
#include "base/file_path.h"
#include "base/logging.h"
#include "base/mac_util.h"
#include "skia/ext/skia_utils_mac.h"
namespace {
FilePath GetResourcesPakFilePath(NSString* name) {
NSString *resource_path = [mac_util::MainAppBundle() pathForResource:name
ofType:@"pak"];
if (!resource_path)
return FilePath();
return FilePath([resource_path fileSystemRepresentation]);
}
} // namespace
// static
FilePath ResourceBundle::GetResourcesFilePath() {
return GetResourcesPakFilePath(@"chrome");
}
// static
FilePath ResourceBundle::GetLocaleFilePath(const std::wstring& pref_locale) {
DLOG_IF(WARNING, !pref_locale.empty())
<< "ignoring requested locale in favor of NSBundle's selection";
return GetResourcesPakFilePath(@"locale");
}
NSImage* ResourceBundle::GetNSImageNamed(int resource_id) {
// Currently this doesn't make a cache holding these as NSImages because
// GetBitmapNamed has a cache, and we don't want to double cache.
SkBitmap* bitmap = GetBitmapNamed(resource_id);
if (!bitmap)
return nil;
NSImage* nsimage = gfx::SkBitmapToNSImage(*bitmap);
return nsimage;
}
|