| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/content/browser/wallet/wallet_signin_helper.h" | 5 #include "components/autofill/content/browser/wallet/wallet_signin_helper.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void GetGoogleCookiesCallback( | 38 void GetGoogleCookiesCallback( |
| 39 const base::Callback<void(const std::string&)>& callback, | 39 const base::Callback<void(const std::string&)>& callback, |
| 40 const net::CookieList& cookies) { | 40 const net::CookieList& cookies) { |
| 41 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 41 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 42 | 42 |
| 43 // Cookies for parent domains will also be returned; we only want cookies with | 43 // Cookies for parent domains will also be returned; we only want cookies with |
| 44 // exact host matches. TODO(estade): really? | 44 // exact host matches. TODO(estade): really? |
| 45 std::string host = wallet::GetPassiveAuthUrl(0).host(); | 45 std::string host = wallet::GetPassiveAuthUrl(0).host(); |
| 46 std::string wallet_cookie; | 46 std::string wallet_cookie; |
| 47 for (size_t i = 0; i < cookies.size(); ++i) { | 47 for (size_t i = 0; i < cookies.size(); ++i) { |
| 48 if (LowerCaseEqualsASCII(cookies[i].Name(), kWalletCookieName) && | 48 if (base::LowerCaseEqualsASCII(cookies[i].Name(), kWalletCookieName) && |
| 49 LowerCaseEqualsASCII(cookies[i].Domain(), host.c_str())) { | 49 base::LowerCaseEqualsASCII(cookies[i].Domain(), host.c_str())) { |
| 50 wallet_cookie = cookies[i].Value(); | 50 wallet_cookie = cookies[i].Value(); |
| 51 break; | 51 break; |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 content::BrowserThread::PostTask(content::BrowserThread::UI, | 54 content::BrowserThread::PostTask(content::BrowserThread::UI, |
| 55 FROM_HERE, | 55 FROM_HERE, |
| 56 base::Bind(callback, wallet_cookie)); | 56 base::Bind(callback, wallet_cookie)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Gets Google Wallet cookies. Must be called on the IO thread. | 59 // Gets Google Wallet cookies. Must be called on the IO thread. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 | 149 |
| 150 std::string data; | 150 std::string data; |
| 151 if (!fetcher->GetResponseAsString(&data)) { | 151 if (!fetcher->GetResponseAsString(&data)) { |
| 152 DVLOG(1) << "failed to GetResponseAsString"; | 152 DVLOG(1) << "failed to GetResponseAsString"; |
| 153 OnOtherError(); | 153 OnOtherError(); |
| 154 return; | 154 return; |
| 155 } | 155 } |
| 156 | 156 |
| 157 if (!LowerCaseEqualsASCII(data, "yes")) { | 157 if (!base::LowerCaseEqualsASCII(data, "yes")) { |
| 158 OnServiceError( | 158 OnServiceError( |
| 159 GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP)); | 159 GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP)); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 | 162 |
| 163 delegate_->OnPassiveSigninSuccess(); | 163 delegate_->OnPassiveSigninSuccess(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void WalletSigninHelper::ReturnWalletCookieValue( | 166 void WalletSigninHelper::ReturnWalletCookieValue( |
| 167 const std::string& cookie_value) { | 167 const std::string& cookie_value) { |
| 168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 169 | 169 |
| 170 delegate_->OnDidFetchWalletCookieValue(cookie_value); | 170 delegate_->OnDidFetchWalletCookieValue(cookie_value); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace wallet | 173 } // namespace wallet |
| 174 } // namespace autofill | 174 } // namespace autofill |
| OLD | NEW |