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

Unified Diff: third_party/libaddressinput/chromium/localization.cc

Issue 298863012: Use upstream libaddressinput in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698