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

Side by Side Diff: base/ios/ios_util.mm

Issue 1568363002: [iOS] Allow overriding icuctl.dat file location. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Less string copies Created 4 years, 11 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
« no previous file with comments | « base/ios/ios_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/ios/ios_util.h" 5 #include "base/ios/ios_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/sys_info.h" 11 #include "base/sys_info.h"
12 12
13 namespace { 13 namespace {
14
14 // Return a 3 elements array containing the major, minor and bug fix version of 15 // Return a 3 elements array containing the major, minor and bug fix version of
15 // the OS. 16 // the OS.
16 const int32_t* OSVersionAsArray() { 17 const int32_t* OSVersionAsArray() {
17 int32_t* digits = new int32_t[3]; 18 int32_t* digits = new int32_t[3];
18 base::SysInfo::OperatingSystemVersionNumbers( 19 base::SysInfo::OperatingSystemVersionNumbers(
19 &digits[0], &digits[1], &digits[2]); 20 &digits[0], &digits[1], &digits[2]);
20 return digits; 21 return digits;
21 } 22 }
23
24 std::string* g_icudtl_path_override = nullptr;
25
22 } // namespace 26 } // namespace
23 27
24 namespace base { 28 namespace base {
25 namespace ios { 29 namespace ios {
26 30
27 // When dropping iOS7 support, also address issues listed in crbug.com/502968. 31 // When dropping iOS7 support, also address issues listed in crbug.com/502968.
28 bool IsRunningOnIOS8OrLater() { 32 bool IsRunningOnIOS8OrLater() {
29 return IsRunningOnOrLater(8, 0, 0); 33 return IsRunningOnOrLater(8, 0, 0);
30 } 34 }
31 35
32 bool IsRunningOnIOS9OrLater() { 36 bool IsRunningOnIOS9OrLater() {
33 return IsRunningOnOrLater(9, 0, 0); 37 return IsRunningOnOrLater(9, 0, 0);
34 } 38 }
35 39
36 bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) { 40 bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) {
37 static const int32_t* current_version = OSVersionAsArray(); 41 static const int32_t* current_version = OSVersionAsArray();
38 int32_t version[] = {major, minor, bug_fix}; 42 int32_t version[] = {major, minor, bug_fix};
39 for (size_t i = 0; i < arraysize(version); i++) { 43 for (size_t i = 0; i < arraysize(version); i++) {
40 if (current_version[i] != version[i]) 44 if (current_version[i] != version[i])
41 return current_version[i] > version[i]; 45 return current_version[i] > version[i];
42 } 46 }
43 return true; 47 return true;
44 } 48 }
45 49
46 bool IsInForcedRTL() { 50 bool IsInForcedRTL() {
47 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; 51 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
48 return [defaults boolForKey:@"NSForceRightToLeftWritingDirection"]; 52 return [defaults boolForKey:@"NSForceRightToLeftWritingDirection"];
49 } 53 }
50 54
55 void OverridePathOfEmbeddedICU(const char* path) {
56 DCHECK(!g_icudtl_path_override);
57 g_icudtl_path_override = new std::string(path);
58 }
59
60 FilePath FilePathOfEmbeddedICU() {
61 if (g_icudtl_path_override) {
62 return FilePath(*g_icudtl_path_override);
63 }
64 return FilePath();
65 }
66
51 } // namespace ios 67 } // namespace ios
52 } // namespace base 68 } // namespace base
OLDNEW
« no previous file with comments | « base/ios/ios_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698