| 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 15d13443de680420e50729ae32a8ad90096dd443..a8aba1d8101c63c72ae133dbfaa8e1b0b02599cf 100644
|
| --- a/third_party/libaddressinput/chromium/cpp/src/rule.cc
|
| +++ b/third_party/libaddressinput/chromium/cpp/src/rule.cc
|
| @@ -24,6 +24,7 @@
|
| #include "address_field_util.h"
|
| #include "grit.h"
|
| #include "messages.h"
|
| +#include "region_data_constants.h"
|
| #include "util/json.h"
|
| #include "util/string_split.h"
|
|
|
| @@ -98,6 +99,15 @@ int GetMessageIdFromName(const std::string& name,
|
| return it != message_ids.end() ? it->second : INVALID_MESSAGE_ID;
|
| }
|
|
|
| +// Parses the default region data into the static Rule object and returns a
|
| +// constant reference to this object. Cannot return a copy of the object,
|
| +// because Rule objects are not copyable.
|
| +const Rule& InitDefaultRule() {
|
| + static Rule rule;
|
| + rule.ParseSerializedRule(RegionDataConstants::GetDefaultRegionData());
|
| + return rule;
|
| +}
|
| +
|
| } // namespace
|
|
|
| Rule::Rule()
|
| @@ -110,6 +120,16 @@ Rule::Rule()
|
|
|
| Rule::~Rule() {}
|
|
|
| +// static
|
| +const Rule& Rule::GetDefault() {
|
| + // Returns the constant reference to the Rule object from InitDefaultRule().
|
| + // The static object is in InitDefaultRule(), but this function maintains a
|
| + // constant static reference to it. The constant static reference avoids
|
| + // re-parsing the default region data.
|
| + static const Rule& kDefaultRule(InitDefaultRule());
|
| + return kDefaultRule;
|
| +}
|
| +
|
| void Rule::CopyFrom(const Rule& rule) {
|
| format_ = rule.format_;
|
| sub_keys_ = rule.sub_keys_;
|
|
|