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

Side by Side Diff: components/autofill/core/common/autofill_l10n_util.cc

Issue 1859453002: components/autofill: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 4 years, 8 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/autofill/core/common/autofill_l10n_util.h" 5 #include "components/autofill/core/common/autofill_l10n_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/i18n/string_compare.h" 10 #include "base/i18n/string_compare.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
13 14
14 namespace autofill { 15 namespace autofill {
15 namespace l10n { 16 namespace l10n {
16 17
17 scoped_ptr<icu::Collator> GetCollatorForLocale(const icu::Locale& locale) { 18 std::unique_ptr<icu::Collator> GetCollatorForLocale(const icu::Locale& locale) {
18 UErrorCode ignored = U_ZERO_ERROR; 19 UErrorCode ignored = U_ZERO_ERROR;
19 scoped_ptr<icu::Collator> collator( 20 std::unique_ptr<icu::Collator> collator(
20 icu::Collator::createInstance(locale, ignored)); 21 icu::Collator::createInstance(locale, ignored));
21 if (!collator) { 22 if (!collator) {
22 // On some systems, the default locale is invalid to the eyes of the ICU 23 // On some systems, the default locale is invalid to the eyes of the ICU
23 // library. This could be due to a device-specific issue (has been seen in 24 // library. This could be due to a device-specific issue (has been seen in
24 // the wild on Android and iOS devices). In the failure case, |collator| 25 // the wild on Android and iOS devices). In the failure case, |collator|
25 // will be null. See http://crbug.com/558625. 26 // will be null. See http://crbug.com/558625.
26 icu::UnicodeString name; 27 icu::UnicodeString name;
27 std::string locale_name; 28 std::string locale_name;
28 locale.getDisplayName(name).toUTF8String(locale_name); 29 locale.getDisplayName(name).toUTF8String(locale_name);
29 LOG(ERROR) << "Failed to initialize the ICU Collator with locale " 30 LOG(ERROR) << "Failed to initialize the ICU Collator with locale "
30 << locale_name; 31 << locale_name;
31 32
32 // Attempt to load the English locale. 33 // Attempt to load the English locale.
33 collator = make_scoped_ptr( 34 collator = base::WrapUnique(
34 icu::Collator::createInstance(icu::Locale::getEnglish(), ignored)); 35 icu::Collator::createInstance(icu::Locale::getEnglish(), ignored));
35 if (!collator) { 36 if (!collator) {
36 LOG(ERROR) << "Failed to initialize the ICU Collator with the English " 37 LOG(ERROR) << "Failed to initialize the ICU Collator with the English "
37 << "locale."; 38 << "locale.";
38 } 39 }
39 } 40 }
40 41
41 UMA_HISTOGRAM_BOOLEAN("Autofill.IcuCollatorCreationSuccess", !!collator); 42 UMA_HISTOGRAM_BOOLEAN("Autofill.IcuCollatorCreationSuccess", !!collator);
42 return collator; 43 return collator;
43 } 44 }
(...skipping 14 matching lines...) Expand all
58 const base::string16& rhs) const { 59 const base::string16& rhs) const {
59 if (collator_) { 60 if (collator_) {
60 return base::i18n::CompareString16WithCollator(*collator_, lhs, rhs) == 61 return base::i18n::CompareString16WithCollator(*collator_, lhs, rhs) ==
61 UCOL_EQUAL; 62 UCOL_EQUAL;
62 } 63 }
63 return lhs == rhs; 64 return lhs == rhs;
64 } 65 }
65 66
66 } // namespace l10n 67 } // namespace l10n
67 } // namespace autofill 68 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/common/autofill_l10n_util.h ('k') | components/autofill/core/common/autofill_regexes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698