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

Unified Diff: chrome/browser/chromeos/login/auth/user_context.cc

Issue 290513003: Move UserContext to its own file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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/auth/user_context.cc
diff --git a/chrome/browser/chromeos/login/auth/user_context.cc b/chrome/browser/chromeos/login/auth/user_context.cc
new file mode 100644
index 0000000000000000000000000000000000000000..545ed5b87abc1fc0028d2f785565c355976d742a
--- /dev/null
+++ b/chrome/browser/chromeos/login/auth/user_context.cc
@@ -0,0 +1,122 @@
+// Copyright 2014 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/auth/user_context.h"
+
+#include "chrome/browser/chromeos/login/helper.h"
+#include "chrome/browser/chromeos/login/users/user_manager.h"
+
+namespace chromeos {
+
+UserContext::UserContext() : does_need_password_hashing_(true),
+ is_using_oauth_(true),
+ auth_flow_(AUTH_FLOW_OFFLINE) {
+}
+
+UserContext::UserContext(const UserContext& other)
+ : user_id_(other.user_id_),
+ password_(other.password_),
+ does_need_password_hashing_(other.does_need_password_hashing_),
+ key_label_(other.key_label_),
+ auth_code_(other.auth_code_),
+ user_id_hash_(other.user_id_hash_),
+ is_using_oauth_(other.is_using_oauth_),
+ auth_flow_(other.auth_flow_) {
+}
+
+UserContext::UserContext(const std::string& user_id)
+ : user_id_(login::CanonicalizeUserID(user_id)),
+ does_need_password_hashing_(true),
+ is_using_oauth_(true),
+ auth_flow_(AUTH_FLOW_OFFLINE) {
+}
+
+UserContext::~UserContext() {
+}
+
+bool UserContext::operator==(const UserContext& context) const {
+ return context.user_id_ == user_id_ &&
+ context.password_ == password_ &&
+ context.does_need_password_hashing_ == does_need_password_hashing_ &&
+ context.key_label_ == key_label_ &&
+ context.auth_code_ == auth_code_ &&
+ context.user_id_hash_ == user_id_hash_ &&
+ context.is_using_oauth_ == is_using_oauth_ &&
+ context.auth_flow_ == auth_flow_;
+}
+
+const std::string& UserContext::GetUserID() const {
+ return user_id_;
+}
+
+const std::string& UserContext::GetPassword() const {
+ return password_;
+}
+
+bool UserContext::DoesNeedPasswordHashing() const {
+ return does_need_password_hashing_;
+}
+
+const std::string& UserContext::GetKeyLabel() const {
+ return key_label_;
+}
+
+const std::string& UserContext::GetAuthCode() const {
+ return auth_code_;
+}
+
+const std::string& UserContext::GetUserIDHash() const {
+ return user_id_hash_;
+}
+
+bool UserContext::IsUsingOAuth() const {
+ return is_using_oauth_;
+}
+
+UserContext::AuthFlow UserContext::GetAuthFlow() const {
+ return auth_flow_;
+}
+
+bool UserContext::HasCredentials() const {
+ return (!user_id_.empty() && !password_.empty()) || !auth_code_.empty();
+}
+
+void UserContext::SetUserID(const std::string& user_id) {
+ user_id_ = login::CanonicalizeUserID(user_id);
+}
+
+void UserContext::SetPassword(const std::string& password) {
+ password_ = password;
+}
+
+void UserContext::SetDoesNeedPasswordHashing(bool does_need_password_hashing) {
+ does_need_password_hashing_ = does_need_password_hashing;
+}
+
+void UserContext::SetKeyLabel(const std::string& key_label) {
+ key_label_ = key_label;
+}
+
+void UserContext::SetAuthCode(const std::string& auth_code) {
+ auth_code_ = auth_code;
+}
+
+void UserContext::SetUserIDHash(const std::string& user_id_hash) {
+ user_id_hash_ = user_id_hash;
+}
+
+void UserContext::SetIsUsingOAuth(bool is_using_oauth) {
+ is_using_oauth_ = is_using_oauth;
+}
+
+void UserContext::SetAuthFlow(AuthFlow auth_flow) {
+ auth_flow_ = auth_flow;
+}
+
+void UserContext::ClearSecrets() {
+ password_.clear();
+ auth_code_.clear();
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/auth/user_context.h ('k') | chrome/browser/chromeos/login/existing_user_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698