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

Unified Diff: chrome/browser/chromeos/login/authenticator.cc

Issue 3436031: [Chrome OS] Refactor Canonicalize() method into base class to prepare for new Authenticator subclass (Closed)
Patch Set: aaaaand fix one more header Created 10 years, 3 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: chrome/browser/chromeos/login/authenticator.cc
diff --git a/chrome/browser/chromeos/login/authenticator.cc b/chrome/browser/chromeos/login/authenticator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1ca3378aaa49aebefbf45cbd81a0d2410367d10b
--- /dev/null
+++ b/chrome/browser/chromeos/login/authenticator.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/authenticator.h"
+
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+#include "base/string_split.h"
+#include "base/string_util.h"
+
+namespace chromeos {
+class LoginStatusConsumer;
+
+Authenticator::Authenticator(LoginStatusConsumer* consumer)
+ : consumer_(consumer) {
+}
+
+Authenticator::~Authenticator() {}
+
+// static
+std::string Authenticator::Canonicalize(const std::string& email_address) {
+ std::vector<std::string> parts;
+ char at = '@';
+ SplitString(email_address, at, &parts);
+ DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @";
+ RemoveChars(parts[0], ".", &parts[0]);
+ if (parts[0].find('+') != std::string::npos)
+ parts[0].erase(parts[0].find('+'));
+ std::string new_email = StringToLowerASCII(JoinString(parts, at));
+ LOG(INFO) << "Canonicalized " << email_address << " to " << new_email;
+ return new_email;
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698