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

Side by Side Diff: chrome/common/resource_bundle_mac.mm

Issue 28214: Add a macutil for the main app bundle and override... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months 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
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 "chrome/common/resource_bundle.h" 5 #include "chrome/common/resource_bundle.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/data_pack.h" 10 #include "base/data_pack.h"
(...skipping 18 matching lines...) Expand all
29 theme_data_ = NULL; 29 theme_data_ = NULL;
30 delete resources_data_; 30 delete resources_data_;
31 resources_data_ = NULL; 31 resources_data_ = NULL;
32 } 32 }
33 33
34 namespace { 34 namespace {
35 35
36 base::DataPack *LoadResourceDataPack(NSString *name) { 36 base::DataPack *LoadResourceDataPack(NSString *name) {
37 base::DataPack *resource_pack = NULL; 37 base::DataPack *resource_pack = NULL;
38 38
39 NSString *const pakExt = @"pak"; 39 NSString *resource_path = [mac_util::MainAppBundle() pathForResource:name
40 40 ofType:@"pak"];
41 // TODO(thomasvl): THIS SUCKS! We need to remove this gate. It's here
42 // because of the unittests, but we have no other way to find our resources.
43 if (!mac_util::AmIBundled()) {
44 FilePath path;
45 PathService::Get(base::DIR_EXE, &path);
46 path = path.AppendASCII("Chromium.app");
47 path = path.AppendASCII("Contents");
48 path = path.AppendASCII("Resources");
49 if ([name isEqual:@"locale"]) {
50 path = path.AppendASCII("en.lproj");
51 }
52 NSString *pakName = [name stringByAppendingPathExtension:pakExt];
53 path = path.Append([pakName fileSystemRepresentation]);
54 resource_pack = new base::DataPack;
55 bool success = resource_pack->Load(path);
56 DCHECK(success) << "failed to load chrome.pak";
57 if (!success) {
58 delete resource_pack;
59 resource_pack = NULL;
60 }
61 return resource_pack;
62 }
63
64 NSString *resource_path = [[NSBundle mainBundle] pathForResource:name
65 ofType:pakExt];
66 if (resource_path) { 41 if (resource_path) {
67 FilePath resources_pak_path([resource_path fileSystemRepresentation]); 42 FilePath resources_pak_path([resource_path fileSystemRepresentation]);
68 resource_pack = new base::DataPack; 43 resource_pack = new base::DataPack;
69 bool success = resource_pack->Load(resources_pak_path); 44 bool success = resource_pack->Load(resources_pak_path);
70 DCHECK(success) << "failed to load chrome.pak"; 45 DCHECK(success) << "failed to load chrome.pak";
71 if (!success) { 46 if (!success) {
72 delete resource_pack; 47 delete resource_pack;
73 resource_pack = NULL; 48 resource_pack = NULL;
74 } 49 }
75 } 50 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 NOTREACHED() << "unable to find resource: " << message_id; 112 NOTREACHED() << "unable to find resource: " << message_id;
138 return std::wstring(); 113 return std::wstring();
139 } 114 }
140 } 115 }
141 116
142 // Data pack encodes strings as UTF16. 117 // Data pack encodes strings as UTF16.
143 string16 msg(reinterpret_cast<const char16*>(data.data()), 118 string16 msg(reinterpret_cast<const char16*>(data.data()),
144 data.length() / 2); 119 data.length() / 2);
145 return UTF16ToWide(msg); 120 return UTF16ToWide(msg);
146 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698