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 #include "base/i18n/icu_util.h" | 5 #include "base/i18n/icu_util.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/memory_mapped_file.h" | 15 #include "base/files/memory_mapped_file.h" |
16 #if defined(OS_IOS) | |
17 #include "base/ios/ios_util.h" | |
rohitrao (ping after 24h)
2016/01/08 17:47:05
This should go between the OS_ANDROID and OS_MAC b
| |
18 #endif | |
16 #include "base/logging.h" | 19 #include "base/logging.h" |
17 #include "base/path_service.h" | 20 #include "base/path_service.h" |
18 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
19 #include "base/strings/sys_string_conversions.h" | 22 #include "base/strings/sys_string_conversions.h" |
20 #include "build/build_config.h" | 23 #include "build/build_config.h" |
21 #include "third_party/icu/source/common/unicode/putil.h" | 24 #include "third_party/icu/source/common/unicode/putil.h" |
22 #include "third_party/icu/source/common/unicode/udata.h" | 25 #include "third_party/icu/source/common/unicode/udata.h" |
23 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 26 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
24 #include "third_party/icu/source/i18n/unicode/timezone.h" | 27 #include "third_party/icu/source/i18n/unicode/timezone.h" |
25 #endif | 28 #endif |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 wchar_t tmp_buffer2[_MAX_PATH] = {0}; | 120 wchar_t tmp_buffer2[_MAX_PATH] = {0}; |
118 wcscpy_s(tmp_buffer2, data_path.value().c_str()); | 121 wcscpy_s(tmp_buffer2, data_path.value().c_str()); |
119 debug::Alias(tmp_buffer2); | 122 debug::Alias(tmp_buffer2); |
120 #endif | 123 #endif |
121 | 124 |
122 #else | 125 #else |
123 // Assume it is in the framework bundle's Resources directory. | 126 // Assume it is in the framework bundle's Resources directory. |
124 ScopedCFTypeRef<CFStringRef> data_file_name( | 127 ScopedCFTypeRef<CFStringRef> data_file_name( |
125 SysUTF8ToCFStringRef(kIcuDataFileName)); | 128 SysUTF8ToCFStringRef(kIcuDataFileName)); |
126 FilePath data_path = mac::PathForFrameworkBundleResource(data_file_name); | 129 FilePath data_path = mac::PathForFrameworkBundleResource(data_file_name); |
130 #if defined(OS_IOS) | |
131 FilePath override_data_path = base::ios::FilePathOfEmbeddedICU(); | |
132 if (!override_data_path.empty()) { | |
133 data_path = override_data_path; | |
134 } | |
135 #endif // !defined(OS_IOS) | |
127 if (data_path.empty()) { | 136 if (data_path.empty()) { |
128 LOG(ERROR) << kIcuDataFileName << " not found in bundle"; | 137 LOG(ERROR) << kIcuDataFileName << " not found in bundle"; |
129 return; | 138 return; |
130 } | 139 } |
131 #endif // !defined(OS_MACOSX) | 140 #endif // !defined(OS_MACOSX) |
132 File file(data_path, File::FLAG_OPEN | File::FLAG_READ); | 141 File file(data_path, File::FLAG_OPEN | File::FLAG_READ); |
133 if (file.IsValid()) { | 142 if (file.IsValid()) { |
134 g_icudtl_pf = file.TakePlatformFile(); | 143 g_icudtl_pf = file.TakePlatformFile(); |
135 g_icudtl_region = MemoryMappedFile::Region::kWholeFile; | 144 g_icudtl_region = MemoryMappedFile::Region::kWholeFile; |
136 } | 145 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 #endif // !defined(OS_NACL) | 274 #endif // !defined(OS_NACL) |
266 | 275 |
267 void AllowMultipleInitializeCallsForTesting() { | 276 void AllowMultipleInitializeCallsForTesting() { |
268 #if !defined(NDEBUG) && !defined(OS_NACL) | 277 #if !defined(NDEBUG) && !defined(OS_NACL) |
269 g_check_called_once = false; | 278 g_check_called_once = false; |
270 #endif | 279 #endif |
271 } | 280 } |
272 | 281 |
273 } // namespace i18n | 282 } // namespace i18n |
274 } // namespace base | 283 } // namespace base |
OLD | NEW |