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(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 41 DCHECK(content::BrowserThread::CurrentlyOn(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 (base::LowerCaseEqualsASCII(cookies[i].Name(), kWalletCookieName) && | 48 if (LowerCaseEqualsASCII(cookies[i].Name(), kWalletCookieName) && |
49 base::LowerCaseEqualsASCII(cookies[i].Domain(), host.c_str())) { | 49 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
151 std::string data; | 151 std::string data; |
152 if (!fetcher->GetResponseAsString(&data)) { | 152 if (!fetcher->GetResponseAsString(&data)) { |
153 DVLOG(1) << "failed to GetResponseAsString"; | 153 DVLOG(1) << "failed to GetResponseAsString"; |
154 OnOtherError(); | 154 OnOtherError(); |
155 return; | 155 return; |
156 } | 156 } |
157 | 157 |
158 if (!base::LowerCaseEqualsASCII(data, "yes")) { | 158 if (!LowerCaseEqualsASCII(data, "yes")) { |
159 OnServiceError( | 159 OnServiceError( |
160 GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP)); | 160 GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP)); |
161 return; | 161 return; |
162 } | 162 } |
163 | 163 |
164 delegate_->OnPassiveSigninSuccess(); | 164 delegate_->OnPassiveSigninSuccess(); |
165 } | 165 } |
166 | 166 |
167 void WalletSigninHelper::ReturnWalletCookieValue( | 167 void WalletSigninHelper::ReturnWalletCookieValue( |
168 const std::string& cookie_value) { | 168 const std::string& cookie_value) { |
169 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 169 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
170 | 170 |
171 delegate_->OnDidFetchWalletCookieValue(cookie_value); | 171 delegate_->OnDidFetchWalletCookieValue(cookie_value); |
172 } | 172 } |
173 | 173 |
174 } // namespace wallet | 174 } // namespace wallet |
175 } // namespace autofill | 175 } // namespace autofill |
OLD | NEW |