| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Helper tool that is built and run during a build to pull strings from | 5 // Helper tool that is built and run during a build to pull strings from |
| 6 // the GRD files and generate the InfoPlist.strings files needed for | 6 // the GRD files and generate the InfoPlist.strings files needed for |
| 7 // Mac OS X app bundles. | 7 // Mac OS X app bundles. |
| 8 | 8 |
| 9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
| 10 | 10 |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 | 13 |
| 14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 15 #include "base/file_util.h" |
| 15 #include "base/mac/scoped_nsautorelease_pool.h" | 16 #include "base/mac/scoped_nsautorelease_pool.h" |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/string_piece.h" | 18 #include "base/string_piece.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
| 20 #include "ui/base/resource/data_pack.h" | 21 #include "ui/base/resource/data_pack.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 NSString* ApplicationVersionString(const char* version_file_path) { | 25 NSString* ApplicationVersionString(const char* version_file_path) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 53 | 54 |
| 54 ui::DataPack* LoadResourceDataPack(const char* dir_path, | 55 ui::DataPack* LoadResourceDataPack(const char* dir_path, |
| 55 const char* branding_strings_name, | 56 const char* branding_strings_name, |
| 56 const char* locale_name) { | 57 const char* locale_name) { |
| 57 ui::DataPack* resource_pack = NULL; | 58 ui::DataPack* resource_pack = NULL; |
| 58 | 59 |
| 59 NSString* resource_path = [NSString stringWithFormat:@"%s/%s_%s.pak", | 60 NSString* resource_path = [NSString stringWithFormat:@"%s/%s_%s.pak", |
| 60 dir_path, branding_strings_name, locale_name]; | 61 dir_path, branding_strings_name, locale_name]; |
| 61 if (resource_path) { | 62 if (resource_path) { |
| 62 FilePath resources_pak_path([resource_path fileSystemRepresentation]); | 63 FilePath resources_pak_path([resource_path fileSystemRepresentation]); |
| 64 file_util::AbsolutePath(&resources_pak_path); |
| 63 resource_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); | 65 resource_pack = new ui::DataPack(ui::SCALE_FACTOR_100P); |
| 64 bool success = resource_pack->LoadFromPath(resources_pak_path); | 66 bool success = resource_pack->LoadFromPath(resources_pak_path); |
| 65 if (!success) { | 67 if (!success) { |
| 66 delete resource_pack; | 68 delete resource_pack; |
| 67 resource_pack = NULL; | 69 resource_pack = NULL; |
| 68 } | 70 } |
| 69 } | 71 } |
| 70 | 72 |
| 71 return resource_pack; | 73 return resource_pack; |
| 72 } | 74 } |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; | 310 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; |
| 309 if (![strings_file_contents_utf8 writeToFile:output_path | 311 if (![strings_file_contents_utf8 writeToFile:output_path |
| 310 atomically:YES]) { | 312 atomically:YES]) { |
| 311 fprintf(stderr, "ERROR: Failed to write out '%s'\n", | 313 fprintf(stderr, "ERROR: Failed to write out '%s'\n", |
| 312 [output_path UTF8String]); | 314 [output_path UTF8String]); |
| 313 exit(1); | 315 exit(1); |
| 314 } | 316 } |
| 315 } | 317 } |
| 316 return 0; | 318 return 0; |
| 317 } | 319 } |
| OLD | NEW |