| 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/chromeos/login/profile_auth_data.h" | 5 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 void ProfileAuthDataTransferer::MaybeTransferCookiesAndChannelIDs() { | 280 void ProfileAuthDataTransferer::MaybeTransferCookiesAndChannelIDs() { |
| 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 282 if (waiting_for_auth_cookies_ || waiting_for_channel_ids_) | 282 if (waiting_for_auth_cookies_ || waiting_for_channel_ids_) |
| 283 return; | 283 return; |
| 284 | 284 |
| 285 net::CookieStore* to_store = | 285 net::CookieStore* to_store = |
| 286 to_context_->GetURLRequestContext()->cookie_store(); | 286 to_context_->GetURLRequestContext()->cookie_store(); |
| 287 net::CookieMonster* to_monster = to_store->GetCookieMonster(); | 287 net::CookieMonster* to_monster = to_store->GetCookieMonster(); |
| 288 if (first_login_) { | 288 if (first_login_) { |
| 289 to_monster->InitializeFrom(cookies_to_transfer_); | 289 to_monster->ImportCookies(cookies_to_transfer_); |
| 290 net::ChannelIDService* to_cert_service = | 290 net::ChannelIDService* to_cert_service = |
| 291 to_context_->GetURLRequestContext()->channel_id_service(); | 291 to_context_->GetURLRequestContext()->channel_id_service(); |
| 292 to_cert_service->GetChannelIDStore()->InitializeFrom( | 292 to_cert_service->GetChannelIDStore()->InitializeFrom( |
| 293 channel_ids_to_transfer_); | 293 channel_ids_to_transfer_); |
| 294 } else { | 294 } else { |
| 295 net::CookieList non_gaia_cookies; |
| 295 for (net::CookieList::const_iterator it = cookies_to_transfer_.begin(); | 296 for (net::CookieList::const_iterator it = cookies_to_transfer_.begin(); |
| 296 it != cookies_to_transfer_.end(); ++it) { | 297 it != cookies_to_transfer_.end(); ++it) { |
| 297 if (IsGAIACookie(*it)) | 298 if (!IsGAIACookie(*it)) |
| 298 continue; | 299 non_gaia_cookies.push_back(*it); |
| 299 // Although this method can be asynchronous, it will run synchronously in | |
| 300 // this case as the target cookie jar is guaranteed to be loaded and | |
| 301 // ready. | |
| 302 to_monster->SetCookieWithDetailsAsync( | |
| 303 GURL(it->Source()), | |
| 304 it->Name(), | |
| 305 it->Value(), | |
| 306 it->Domain(), | |
| 307 it->Path(), | |
| 308 it->ExpiryDate(), | |
| 309 it->IsSecure(), | |
| 310 it->IsHttpOnly(), | |
| 311 it->Priority(), | |
| 312 net::CookieStore::SetCookiesCallback()); | |
| 313 } | 300 } |
| 301 to_monster->ImportCookies(non_gaia_cookies); |
| 314 } | 302 } |
| 315 | 303 |
| 316 Finish(); | 304 Finish(); |
| 317 } | 305 } |
| 318 | 306 |
| 319 void ProfileAuthDataTransferer::Finish() { | 307 void ProfileAuthDataTransferer::Finish() { |
| 320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 321 if (!completion_callback_.is_null()) | 309 if (!completion_callback_.is_null()) |
| 322 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion_callback_); | 310 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion_callback_); |
| 323 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 311 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 322 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 335 (new ProfileAuthDataTransferer( | 323 (new ProfileAuthDataTransferer( |
| 336 from_context, | 324 from_context, |
| 337 to_context, | 325 to_context, |
| 338 transfer_auth_cookies_and_channel_ids_on_first_login, | 326 transfer_auth_cookies_and_channel_ids_on_first_login, |
| 339 transfer_saml_auth_cookies_on_subsequent_login, | 327 transfer_saml_auth_cookies_on_subsequent_login, |
| 340 completion_callback))->BeginTransfer(); | 328 completion_callback))->BeginTransfer(); |
| 341 } | 329 } |
| 342 | 330 |
| 343 } // namespace chromeos | 331 } // namespace chromeos |
| OLD | NEW |