| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 | 1085 |
| 1086 PrefService* pref_service = user_profile->GetPrefs(); | 1086 PrefService* pref_service = user_profile->GetPrefs(); |
| 1087 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token); | 1087 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token); |
| 1088 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret); | 1088 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret); |
| 1089 if (!encoded_token.length() || !encoded_secret.length()) | 1089 if (!encoded_token.length() || !encoded_secret.length()) |
| 1090 return false; | 1090 return false; |
| 1091 | 1091 |
| 1092 DCHECK(authenticator_.get()); | 1092 DCHECK(authenticator_.get()); |
| 1093 std::string decoded_token = authenticator_->DecryptToken(encoded_token); | 1093 std::string decoded_token = authenticator_->DecryptToken(encoded_token); |
| 1094 std::string decoded_secret = authenticator_->DecryptToken(encoded_secret); | 1094 std::string decoded_secret = authenticator_->DecryptToken(encoded_secret); |
| 1095 if (!decoded_token.length() || !decoded_secret.length()) { | 1095 if (!decoded_token.length() || !decoded_secret.length()) |
| 1096 // TODO(zelidrag): Remove legacy encryption support in R16. | 1096 return false; |
| 1097 // Check if tokens were encoded with the legacy encryption instead. | |
| 1098 decoded_token = authenticator_->DecryptLegacyToken(encoded_token); | |
| 1099 decoded_secret = authenticator_->DecryptLegacyToken(encoded_secret); | |
| 1100 if (!decoded_token.length() || !decoded_secret.length()) | |
| 1101 return false; | |
| 1102 | |
| 1103 pref_service->SetString(prefs::kOAuth1Token, | |
| 1104 authenticator_->EncryptToken(decoded_token)); | |
| 1105 pref_service->SetString(prefs::kOAuth1Secret, | |
| 1106 authenticator_->EncryptToken(decoded_secret)); | |
| 1107 } | |
| 1108 | 1097 |
| 1109 *token = decoded_token; | 1098 *token = decoded_token; |
| 1110 *secret = decoded_secret; | 1099 *secret = decoded_secret; |
| 1111 return true; | 1100 return true; |
| 1112 } | 1101 } |
| 1113 | 1102 |
| 1114 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, | 1103 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, |
| 1115 const std::string& token, | 1104 const std::string& token, |
| 1116 const std::string& secret) { | 1105 const std::string& secret) { |
| 1117 // First store OAuth1 token + service for the current user profile... | 1106 // First store OAuth1 token + service for the current user profile... |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 // Mark login host for deletion after browser starts. This | 1209 // Mark login host for deletion after browser starts. This |
| 1221 // guarantees that the message loop will be referenced by the | 1210 // guarantees that the message loop will be referenced by the |
| 1222 // browser before it is dereferenced by the login host. | 1211 // browser before it is dereferenced by the login host. |
| 1223 if (login_host) { | 1212 if (login_host) { |
| 1224 login_host->OnSessionStart(); | 1213 login_host->OnSessionStart(); |
| 1225 login_host = NULL; | 1214 login_host = NULL; |
| 1226 } | 1215 } |
| 1227 } | 1216 } |
| 1228 | 1217 |
| 1229 } // namespace chromeos | 1218 } // namespace chromeos |
| OLD | NEW |