| 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 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | |
| 12 #include <stdio.h> | 11 #include <stdio.h> |
| 13 #include <unistd.h> | 12 #include <unistd.h> |
| 14 | 13 |
| 14 #include <memory> |
| 15 |
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 17 #include "base/mac/scoped_nsautorelease_pool.h" | 18 #include "base/mac/scoped_nsautorelease_pool.h" |
| 18 #include "base/memory/scoped_ptr.h" | |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_piece.h" | 20 #include "base/strings/string_piece.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
| 24 #include "chrome/grit/chromium_strings.h" | 24 #include "chrome/grit/chromium_strings.h" |
| 25 #include "ui/base/resource/data_pack.h" | 25 #include "ui/base/resource/data_pack.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 fprintf(stderr, "ERROR: failed to get a version string"); | 215 fprintf(stderr, "ERROR: failed to get a version string"); |
| 216 exit(1); | 216 exit(1); |
| 217 } | 217 } |
| 218 | 218 |
| 219 NSFileManager* fm = [NSFileManager defaultManager]; | 219 NSFileManager* fm = [NSFileManager defaultManager]; |
| 220 | 220 |
| 221 for (int loop = 0; loop < lang_list_count; ++loop) { | 221 for (int loop = 0; loop < lang_list_count; ++loop) { |
| 222 const char* cur_lang = lang_list[loop]; | 222 const char* cur_lang = lang_list[loop]; |
| 223 | 223 |
| 224 // Open the branded string pak file | 224 // Open the branded string pak file |
| 225 scoped_ptr<ui::DataPack> branded_data_pack( | 225 std::unique_ptr<ui::DataPack> branded_data_pack( |
| 226 LoadResourceDataPack(grit_output_dir, | 226 LoadResourceDataPack(grit_output_dir, branding_strings_name, cur_lang)); |
| 227 branding_strings_name, | |
| 228 cur_lang)); | |
| 229 if (branded_data_pack.get() == NULL) { | 227 if (branded_data_pack.get() == NULL) { |
| 230 fprintf(stderr, "ERROR: Failed to load branded pak for language: %s\n", | 228 fprintf(stderr, "ERROR: Failed to load branded pak for language: %s\n", |
| 231 cur_lang); | 229 cur_lang); |
| 232 exit(1); | 230 exit(1); |
| 233 } | 231 } |
| 234 | 232 |
| 235 uint32_t name_id = IDS_PRODUCT_NAME; | 233 uint32_t name_id = IDS_PRODUCT_NAME; |
| 236 const char* name_id_str = "IDS_PRODUCT_NAME"; | 234 const char* name_id_str = "IDS_PRODUCT_NAME"; |
| 237 uint32_t short_name_id = IDS_APP_MENU_PRODUCT_NAME; | 235 uint32_t short_name_id = IDS_APP_MENU_PRODUCT_NAME; |
| 238 const char* short_name_id_str = "IDS_APP_MENU_PRODUCT_NAME"; | 236 const char* short_name_id_str = "IDS_APP_MENU_PRODUCT_NAME"; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; | 326 [output_path stringByAppendingPathComponent:@"InfoPlist.strings"]; |
| 329 if (![strings_file_contents_utf8 writeToFile:output_path | 327 if (![strings_file_contents_utf8 writeToFile:output_path |
| 330 atomically:YES]) { | 328 atomically:YES]) { |
| 331 fprintf(stderr, "ERROR: Failed to write out '%s'\n", | 329 fprintf(stderr, "ERROR: Failed to write out '%s'\n", |
| 332 [output_path UTF8String]); | 330 [output_path UTF8String]); |
| 333 exit(1); | 331 exit(1); |
| 334 } | 332 } |
| 335 } | 333 } |
| 336 return 0; | 334 return 0; |
| 337 } | 335 } |
| OLD | NEW |