| 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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 } | 928 } |
| 929 | 929 |
| 930 PrefService* pref_service = user_profile->GetPrefs(); | 930 PrefService* pref_service = user_profile->GetPrefs(); |
| 931 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token); | 931 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token); |
| 932 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret); | 932 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret); |
| 933 if (!encoded_token.length() || !encoded_secret.length()) | 933 if (!encoded_token.length() || !encoded_secret.length()) |
| 934 return false; | 934 return false; |
| 935 | 935 |
| 936 std::string decoded_token = authenticator_->DecryptToken(encoded_token); | 936 std::string decoded_token = authenticator_->DecryptToken(encoded_token); |
| 937 std::string decoded_secret = authenticator_->DecryptToken(encoded_secret); | 937 std::string decoded_secret = authenticator_->DecryptToken(encoded_secret); |
| 938 if (!decoded_token.length() || !decoded_secret.length()) | 938 if (!decoded_token.length() || !decoded_secret.length()) { |
| 939 return false; | 939 // TODO(zelidrag): Remove legacy encryption support in R16. |
| 940 // Check if tokens were encoded with the legacy encryption instead. |
| 941 decoded_token = authenticator_->DecryptLegacyToken(encoded_token); |
| 942 decoded_secret = authenticator_->DecryptLegacyToken(encoded_secret); |
| 943 if (!decoded_token.length() || !decoded_secret.length()) |
| 944 return false; |
| 945 |
| 946 pref_service->SetString(prefs::kOAuth1Token, |
| 947 authenticator_->EncryptToken(decoded_token)); |
| 948 pref_service->SetString(prefs::kOAuth1Secret, |
| 949 authenticator_->EncryptToken(decoded_secret)); |
| 950 } |
| 940 | 951 |
| 941 *token = decoded_token; | 952 *token = decoded_token; |
| 942 *secret = decoded_secret; | 953 *secret = decoded_secret; |
| 943 return true; | 954 return true; |
| 944 } | 955 } |
| 945 | 956 |
| 946 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, | 957 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, |
| 947 const std::string& token, | 958 const std::string& token, |
| 948 const std::string& secret) { | 959 const std::string& secret) { |
| 949 // First store OAuth1 token + service for the current user profile... | 960 // First store OAuth1 token + service for the current user profile... |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 // Mark login host for deletion after browser starts. This | 1041 // Mark login host for deletion after browser starts. This |
| 1031 // guarantees that the message loop will be referenced by the | 1042 // guarantees that the message loop will be referenced by the |
| 1032 // browser before it is dereferenced by the login host. | 1043 // browser before it is dereferenced by the login host. |
| 1033 if (login_host) { | 1044 if (login_host) { |
| 1034 login_host->OnSessionStart(); | 1045 login_host->OnSessionStart(); |
| 1035 login_host = NULL; | 1046 login_host = NULL; |
| 1036 } | 1047 } |
| 1037 } | 1048 } |
| 1038 | 1049 |
| 1039 } // namespace chromeos | 1050 } // namespace chromeos |
| OLD | NEW |