Index: components/autofill/core/common/autofill_l10n_util.cc |
diff --git a/components/autofill/core/common/autofill_l10n_util.cc b/components/autofill/core/common/autofill_l10n_util.cc |
index 6f063a85f4f7821d0e962b3d26680b26d075d151..8c82a12185089d8aeba594ca37a9b8f456815b13 100644 |
--- a/components/autofill/core/common/autofill_l10n_util.cc |
+++ b/components/autofill/core/common/autofill_l10n_util.cc |
@@ -6,6 +6,7 @@ |
#include "base/i18n/string_compare.h" |
#include "base/logging.h" |
+#include "base/metrics/histogram_macros.h" |
namespace autofill { |
namespace l10n { |
@@ -13,8 +14,15 @@ namespace l10n { |
CaseInsensitiveCompare::CaseInsensitiveCompare() { |
UErrorCode error = U_ZERO_ERROR; |
collator_.reset(icu::Collator::createInstance(error)); |
- DCHECK(U_SUCCESS(error)); |
- collator_->setStrength(icu::Collator::PRIMARY); |
+ // On some systems, the default locale is invalid to the eyes of the ICU |
+ // library. This could be due to a device-specific issue (has been seen in the |
+ // wild on Android devices). |
Ilya Sherman
2015/11/19 21:04:06
Please add a crbug reference to this comment.
Mathieu
2015/11/19 21:53:02
Done.
|
+ bool success = U_SUCCESS(error); |
+ DCHECK(success); |
Ilya Sherman
2015/11/19 21:04:06
nit: It's not appropriate to DCHECK a statement th
Mathieu
2015/11/19 21:53:01
My idea there was that a developer with a faulty d
Ilya Sherman
2015/11/19 22:31:20
If you think it's useful for random developers to
Mathieu
2015/11/20 16:19:38
It hits me that I can't test the failure codepath
|
+ if (success) |
+ collator_->setStrength(icu::Collator::PRIMARY); |
+ |
+ UMA_HISTOGRAM_BOOLEAN("Autofill.IcuCollatorCreationSuccess", success); |
Mathieu
2015/11/19 20:50:51
I thought it was simpler to have the macro here, l
Ilya Sherman
2015/11/19 21:04:06
I think it's been helpful in the past to funnel al
Mathieu
2015/11/19 21:53:02
Done. Created an explicit constructor for testing,
Mathieu
2015/11/20 16:19:38
It turns out that there is no dependency path betw
|
} |
CaseInsensitiveCompare::~CaseInsensitiveCompare() { |
@@ -22,8 +30,11 @@ CaseInsensitiveCompare::~CaseInsensitiveCompare() { |
bool CaseInsensitiveCompare::StringsEqual(const base::string16& lhs, |
const base::string16& rhs) const { |
- return base::i18n::CompareString16WithCollator(*collator_, lhs, rhs) == |
- UCOL_EQUAL; |
+ if (collator_.get()) { |
Ilya Sherman
2015/11/19 21:04:06
Hmm, when might the collator be unset? The code o
Mathieu
2015/11/19 21:53:01
On line 16, the constructor can return NULL on err
Ilya Sherman
2015/11/19 22:31:19
I see -- I'd misunderstood what the failure case w
Mathieu
2015/11/20 16:19:38
Acknowledged.
|
+ return base::i18n::CompareString16WithCollator(*collator_, lhs, rhs) == |
+ UCOL_EQUAL; |
+ } |
+ return lhs == rhs; |
} |
} // namespace l10n |