Index: third_party/libaddressinput/chromium/cpp/src/rule.cc |
diff --git a/third_party/libaddressinput/chromium/cpp/src/rule.cc b/third_party/libaddressinput/chromium/cpp/src/rule.cc |
index 1566f646d15366e093d3a438551f172406edf109..5551ed44d19b127d74caa264f52016556703e703 100644 |
--- a/third_party/libaddressinput/chromium/cpp/src/rule.cc |
+++ b/third_party/libaddressinput/chromium/cpp/src/rule.cc |
@@ -24,6 +24,7 @@ |
#include "grit.h" |
#include "messages.h" |
+#include "region_data_constants.h" |
#include "util/json.h" |
#include "util/string_split.h" |
@@ -32,6 +33,9 @@ namespace addressinput { |
namespace { |
+// Allocated once and leaked on shutdown. |
+static Rule* default_rule = NULL; |
+ |
bool ParseToken(char c, AddressField* field) { |
assert(field != NULL); |
switch (c) { |
@@ -171,6 +175,16 @@ Rule::Rule() |
Rule::~Rule() {} |
+// static |
+const Rule& Rule::GetDefault() { |
+ if (default_rule == NULL) { |
+ default_rule = new Rule; |
+ default_rule->ParseSerializedRule( |
+ RegionDataConstants::GetDefaultRegionData()); |
+ } |
+ return *default_rule; |
+} |
+ |
void Rule::CopyFrom(const Rule& rule) { |
format_ = rule.format_; |
required_ = rule.required_; |