| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "chrome/browser/content_settings/cookie_settings.h" | 13 #include "chrome/browser/content_settings/cookie_settings.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/signin/token_service.h" | 16 #include "chrome/browser/signin/token_service.h" |
| 17 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 20 #include "chrome/common/net/gaia/gaia_constants.h" | 21 #include "chrome/common/net/gaia/gaia_constants.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "net/base/cookie_monster.h" | 24 #include "net/base/cookie_monster.h" |
| 24 | 25 |
| 25 const char kGetInfoEmailKey[] = "email"; | 26 const char kGetInfoEmailKey[] = "email"; |
| 26 const char kGetInfoServicesKey[] = "allServices"; | 27 const char kGetInfoServicesKey[] = "allServices"; |
| 27 const char kGooglePlusServiceKey[] = "googleme"; | 28 const char kGooglePlusServiceKey[] = "googleme"; |
| 28 | 29 |
| 29 const char kGoogleAccountsUrl[] = "https://accounts.google.com"; | 30 const char kGoogleAccountsUrl[] = "https://accounts.google.com"; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 GaiaConstants::kChromeSource, | 146 GaiaConstants::kChromeSource, |
| 146 profile_->GetRequestContext())); | 147 profile_->GetRequestContext())); |
| 147 client_login_->StartClientLogin(possibly_invalid_username_, | 148 client_login_->StartClientLogin(possibly_invalid_username_, |
| 148 access_code, | 149 access_code, |
| 149 "", | 150 "", |
| 150 std::string(), | 151 std::string(), |
| 151 std::string(), | 152 std::string(), |
| 152 GaiaAuthFetcher::HostedAccountsNotAllowed); | 153 GaiaAuthFetcher::HostedAccountsNotAllowed); |
| 153 } | 154 } |
| 154 | 155 |
| 155 void SigninManager::StartSignInWithCredentials(const std::string& username, | 156 void SigninManager::StartSignInWithCredentials(const std::string& session_index, |
| 157 const std::string& username, |
| 156 const std::string& password) { | 158 const std::string& password) { |
| 157 DCHECK(authenticated_username_.empty()); | 159 DCHECK(authenticated_username_.empty()); |
| 158 PrepareForSignin(); | 160 PrepareForSignin(); |
| 159 possibly_invalid_username_.assign(username); | 161 possibly_invalid_username_.assign(username); |
| 160 password_.assign(password); | 162 password_.assign(password); |
| 161 | 163 |
| 162 client_login_.reset(new GaiaAuthFetcher(this, | 164 client_login_.reset(new GaiaAuthFetcher(this, |
| 163 GaiaConstants::kChromeSource, | 165 GaiaConstants::kChromeSource, |
| 164 profile_->GetRequestContext())); | 166 profile_->GetRequestContext())); |
| 165 | 167 |
| 166 // This function starts with the current state of the web session's cookie | 168 // This function starts with the current state of the web session's cookie |
| 167 // jar and mints a new ClientLogin-style SID/LSID pair. This involves going | 169 // jar and mints a new ClientLogin-style SID/LSID pair. This involves going |
| 168 // throug the follow process or requests to GAIA and LSO: | 170 // throug the follow process or requests to GAIA and LSO: |
| 169 // | 171 // |
| 170 // - call /o/oauth2/programmatic_auth with the returned token to get oauth2 | 172 // - call /o/oauth2/programmatic_auth with the returned token to get oauth2 |
| 171 // access and refresh tokens | 173 // access and refresh tokens |
| 172 // - call /accounts/OAuthLogin with the oauth2 access token and get an uber | 174 // - call /accounts/OAuthLogin with the oauth2 access token and get an uber |
| 173 // auth token | 175 // auth token |
| 174 // - call /TokenAuth with the uber auth token to get a SID/LSID pair for use | 176 // - call /TokenAuth with the uber auth token to get a SID/LSID pair for use |
| 175 // by the token service | 177 // by the token service |
| 176 // | 178 // |
| 177 // The resulting SID/LSID can then be used just as if | 179 // The resulting SID/LSID can then be used just as if |
| 178 // client_login_->StartClientLogin() had completed successfully. | 180 // client_login_->StartClientLogin() had completed successfully. |
| 179 client_login_->StartOAuthLoginTokenFetch(""); | 181 client_login_->StartOAuthLoginTokenFetchWithCookies(session_index); |
| 180 } | 182 } |
| 181 | 183 |
| 182 void SigninManager::ClearTransientSigninData() { | 184 void SigninManager::ClearTransientSigninData() { |
| 183 DCHECK(IsInitialized()); | 185 DCHECK(IsInitialized()); |
| 184 | 186 |
| 185 CleanupNotificationRegistration(); | 187 CleanupNotificationRegistration(); |
| 186 client_login_.reset(); | 188 client_login_.reset(); |
| 187 last_result_ = ClientLoginResult(); | 189 last_result_ = ClientLoginResult(); |
| 188 possibly_invalid_username_.clear(); | 190 possibly_invalid_username_.clear(); |
| 189 password_.clear(); | 191 password_.clear(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 profile_->GetRequestContext())); | 383 profile_->GetRequestContext())); |
| 382 } | 384 } |
| 383 | 385 |
| 384 client_login_->StartMergeSession(tok_details->token()); | 386 client_login_->StartMergeSession(tok_details->token()); |
| 385 | 387 |
| 386 // We only want to do this once per sign-in. | 388 // We only want to do this once per sign-in. |
| 387 CleanupNotificationRegistration(); | 389 CleanupNotificationRegistration(); |
| 388 } | 390 } |
| 389 #endif | 391 #endif |
| 390 } | 392 } |
| OLD | NEW |