Index: third_party/libaddressinput/chromium/localization.cc |
diff --git a/third_party/libaddressinput/chromium/localization.cc b/third_party/libaddressinput/chromium/localization.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..767774933ad523f0e1c5240f487496ca5843f9ec |
--- /dev/null |
+++ b/third_party/libaddressinput/chromium/localization.cc |
@@ -0,0 +1,53 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
please use gerrit instead
2014/06/05 22:22:49
Remove this localization.cc file! (It's not used i
please use gerrit instead
2014/06/09 23:28:17
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h" |
+ |
+#include <cassert> |
+#include <cstddef> |
+#include <string> |
+ |
+#include "third_party/libaddressinput/src/cpp/src/grit.h" |
+ |
+namespace i18n { |
+namespace addressinput { |
+ |
+namespace { |
+ |
+static const char kDefaultLanguage[] = "en"; |
+ |
+// Only libaddressinput_unittests call this function, because they always use |
+// the default strings. |
+std::string NoDefaultStrings(int message_id) { |
+ static const char kInvalidString[] = "[INVALID_STRING]"; |
+ static const char kEmptyString[] = ""; |
+ return message_id != INVALID_MESSAGE_ID ? kInvalidString : kEmptyString; |
+} |
+ |
+} // namespace |
+ |
+Localization::Localization() : get_string_(&NoDefaultStrings), |
+ language_tag_(kDefaultLanguage) {} |
+ |
+Localization::~Localization() {} |
+ |
+std::string Localization::GetString(int message_id) const { |
+ return get_string_(message_id); |
+} |
+ |
+void Localization::SetLanguage(const std::string& language_tag) { |
+ // Only libaddressinput_unittests call this function. |
+ assert(language_tag == kDefaultLanguage); |
+ language_tag_ = language_tag; |
+} |
+ |
+void Localization::SetGetter(std::string (*getter)(int), |
+ const std::string& language_tag) { |
+ assert(getter != NULL); |
+ get_string_ = getter; |
+ language_tag_ = language_tag; |
+} |
+ |
+} // namespace addressinput |
+} // namespace i18n |