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

Side by Side Diff: third_party/WebKit/Source/platform/text/LocaleWin.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "platform/text/LocaleWin.h" 31 #include "platform/text/LocaleWin.h"
32 32
33 #include <limits>
34 #include "platform/DateComponents.h" 33 #include "platform/DateComponents.h"
35 #include "platform/Language.h" 34 #include "platform/Language.h"
36 #include "platform/LayoutTestSupport.h" 35 #include "platform/LayoutTestSupport.h"
37 #include "platform/text/DateTimeFormat.h" 36 #include "platform/text/DateTimeFormat.h"
38 #include "wtf/CurrentTime.h" 37 #include "wtf/CurrentTime.h"
39 #include "wtf/DateMath.h" 38 #include "wtf/DateMath.h"
40 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
41 #include "wtf/OwnPtr.h" 40 #include "wtf/PtrUtil.h"
42 #include "wtf/PassOwnPtr.h"
43 #include "wtf/text/StringBuffer.h" 41 #include "wtf/text/StringBuffer.h"
44 #include "wtf/text/StringBuilder.h" 42 #include "wtf/text/StringBuilder.h"
45 #include "wtf/text/StringHash.h" 43 #include "wtf/text/StringHash.h"
44 #include <limits>
45 #include <memory>
46 46
47 namespace blink { 47 namespace blink {
48 48
49 static String extractLanguageCode(const String& locale) 49 static String extractLanguageCode(const String& locale)
50 { 50 {
51 size_t dashPosition = locale.find('-'); 51 size_t dashPosition = locale.find('-');
52 if (dashPosition == kNotFound) 52 if (dashPosition == kNotFound)
53 return locale; 53 return locale;
54 return locale.left(dashPosition); 54 return locale.left(dashPosition);
55 } 55 }
(...skipping 13 matching lines...) Expand all
69 WCHAR lowercaseLanguageCode[languageCodeBufferSize]; 69 WCHAR lowercaseLanguageCode[languageCodeBufferSize];
70 ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME | (defaultsForLo cale ? LOCALE_NOUSEROVERRIDE : 0), lowercaseLanguageCode, languageCodeBufferSize ); 70 ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME | (defaultsForLo cale ? LOCALE_NOUSEROVERRIDE : 0), lowercaseLanguageCode, languageCodeBufferSize );
71 String userDefaultLanguageCode = String(lowercaseLanguageCode); 71 String userDefaultLanguageCode = String(lowercaseLanguageCode);
72 72
73 LCID lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageC ode, locale); 73 LCID lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageC ode, locale);
74 if (!lcid) 74 if (!lcid)
75 lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCo de, defaultLanguage()); 75 lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCo de, defaultLanguage());
76 return lcid; 76 return lcid;
77 } 77 }
78 78
79 PassOwnPtr<Locale> Locale::create(const String& locale) 79 std::unique_ptr<Locale> Locale::create(const String& locale)
80 { 80 {
81 // Whether the default settings for the locale should be used, ignoring user overrides. 81 // Whether the default settings for the locale should be used, ignoring user overrides.
82 bool defaultsForLocale = LayoutTestSupport::isRunningLayoutTest(); 82 bool defaultsForLocale = LayoutTestSupport::isRunningLayoutTest();
83 return LocaleWin::create(LCIDFromLocale(locale, defaultsForLocale), defaults ForLocale); 83 return LocaleWin::create(LCIDFromLocale(locale, defaultsForLocale), defaults ForLocale);
84 } 84 }
85 85
86 inline LocaleWin::LocaleWin(LCID lcid, bool defaultsForLocale) 86 inline LocaleWin::LocaleWin(LCID lcid, bool defaultsForLocale)
87 : m_lcid(lcid) 87 : m_lcid(lcid)
88 , m_didInitializeNumberData(false) 88 , m_didInitializeNumberData(false)
89 , m_defaultsForLocale(defaultsForLocale) 89 , m_defaultsForLocale(defaultsForLocale)
90 { 90 {
91 DWORD value = 0; 91 DWORD value = 0;
92 getLocaleInfo(LOCALE_IFIRSTDAYOFWEEK | (defaultsForLocale ? LOCALE_NOUSEROVE RRIDE : 0), value); 92 getLocaleInfo(LOCALE_IFIRSTDAYOFWEEK | (defaultsForLocale ? LOCALE_NOUSEROVE RRIDE : 0), value);
93 // 0:Monday, ..., 6:Sunday. 93 // 0:Monday, ..., 6:Sunday.
94 // We need 1 for Monday, 0 for Sunday. 94 // We need 1 for Monday, 0 for Sunday.
95 m_firstDayOfWeek = (value + 1) % 7; 95 m_firstDayOfWeek = (value + 1) % 7;
96 } 96 }
97 97
98 PassOwnPtr<LocaleWin> LocaleWin::create(LCID lcid, bool defaultsForLocale) 98 std::unique_ptr<LocaleWin> LocaleWin::create(LCID lcid, bool defaultsForLocale)
99 { 99 {
100 return adoptPtr(new LocaleWin(lcid, defaultsForLocale)); 100 return wrapUnique(new LocaleWin(lcid, defaultsForLocale));
101 } 101 }
102 102
103 LocaleWin::~LocaleWin() 103 LocaleWin::~LocaleWin()
104 { 104 {
105 } 105 }
106 106
107 String LocaleWin::getLocaleInfoString(LCTYPE type) 107 String LocaleWin::getLocaleInfoString(LCTYPE type)
108 { 108 {
109 int bufferSizeWithNUL = ::GetLocaleInfo(m_lcid, type | (m_defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), 0, 0); 109 int bufferSizeWithNUL = ::GetLocaleInfo(m_lcid, type | (m_defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), 0, 0);
110 if (bufferSizeWithNUL <= 0) 110 if (bufferSizeWithNUL <= 0)
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 case NegativeFormatSignPrefix: // Fall through. 506 case NegativeFormatSignPrefix: // Fall through.
507 default: 507 default:
508 negativePrefix = negativeSign; 508 negativePrefix = negativeSign;
509 break; 509 break;
510 } 510 }
511 m_didInitializeNumberData = true; 511 m_didInitializeNumberData = true;
512 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix); 512 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix);
513 } 513 }
514 514
515 } 515 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/LocaleWin.h ('k') | third_party/WebKit/Source/platform/text/LocaleWinTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698