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_service_url.h" | 5 #include "components/autofill/content/browser/wallet/wallet_service_url.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 GURL GetSaveToWalletUrl(size_t user_index) { | 134 GURL GetSaveToWalletUrl(size_t user_index) { |
135 return GetBaseEncryptedFrontendUrl(user_index) | 135 return GetBaseEncryptedFrontendUrl(user_index) |
136 .Resolve("saveToWallet?s7e=card_number%3Bcvn"); | 136 .Resolve("saveToWallet?s7e=card_number%3Bcvn"); |
137 } | 137 } |
138 | 138 |
139 GURL GetPassiveAuthUrl(size_t user_index) { | 139 GURL GetPassiveAuthUrl(size_t user_index) { |
140 return GetBaseWalletUrl(user_index) | 140 return GetBaseWalletUrl(user_index) |
141 .Resolve("passiveauth?isChromePayments=true"); | 141 .Resolve("passiveauth?isChromePayments=true"); |
142 } | 142 } |
143 | 143 |
144 GURL GetSignInUrl() { | 144 GURL GetAddAccountUrl() { |
145 GURL url(GaiaUrls::GetInstance()->add_account_url()); | 145 GURL url(GaiaUrls::GetInstance()->add_account_url()); |
146 url = net::AppendQueryParameter(url, "nui", "1"); | 146 url = net::AppendQueryParameter(url, "nui", "1"); |
147 // Prevents promos from showing (see http://crbug.com/235227). | 147 // Prevents promos from showing (see http://crbug.com/235227). |
148 url = net::AppendQueryParameter(url, "sarp", "1"); | 148 url = net::AppendQueryParameter(url, "sarp", "1"); |
149 url = net::AppendQueryParameter(url, | 149 url = net::AppendQueryParameter(url, |
150 "continue", | 150 "continue", |
151 GetSignInContinueUrl().spec()); | 151 GetSignInContinueUrl().spec()); |
152 return url; | 152 return url; |
153 } | 153 } |
154 | 154 |
| 155 GURL GetSignInUrl(size_t user_index) { |
| 156 GURL url(GaiaUrls::GetInstance()->service_login_url()); |
| 157 url = net::AppendQueryParameter( |
| 158 url, "authuser", base::SizeTToString(user_index)); |
| 159 // Prevents promos from showing (see http://crbug.com/235227). |
| 160 url = net::AppendQueryParameter(url, "sarp", "1"); |
| 161 url = |
| 162 net::AppendQueryParameter(url, "continue", GetSignInContinueUrl().spec()); |
| 163 return url; |
| 164 } |
| 165 |
155 // The continue url portion of the sign-in URL. This URL is used as a milestone | 166 // The continue url portion of the sign-in URL. This URL is used as a milestone |
156 // to determine that the sign-in process is finished. It has to be a Google | 167 // to determine that the sign-in process is finished. It has to be a Google |
157 // domain, use https://, and do almost nothing, but otherwise it's not too | 168 // domain, use https://, and do almost nothing, but otherwise it's not too |
158 // important what the URL actually is: it's not important that this URL has the | 169 // important what the URL actually is: it's not important that this URL has the |
159 // ability to generate a gdToken. | 170 // ability to generate a gdToken. |
160 GURL GetSignInContinueUrl() { | 171 GURL GetSignInContinueUrl() { |
161 return GetPassiveAuthUrl(0); | 172 return GetPassiveAuthUrl(0); |
162 } | 173 } |
163 | 174 |
164 bool IsSignInContinueUrl(const GURL& url, size_t* user_index) { | 175 bool IsSignInContinueUrl(const GURL& url, size_t* user_index) { |
(...skipping 15 matching lines...) Expand all Loading... |
180 base::StringToSizeT(query_str.substr(value.begin, value.len), user_index); | 191 base::StringToSizeT(query_str.substr(value.begin, value.len), user_index); |
181 break; | 192 break; |
182 } | 193 } |
183 } | 194 } |
184 | 195 |
185 return true; | 196 return true; |
186 } | 197 } |
187 | 198 |
188 bool IsSignInRelatedUrl(const GURL& url) { | 199 bool IsSignInRelatedUrl(const GURL& url) { |
189 size_t unused; | 200 size_t unused; |
190 return url.GetOrigin() == GetSignInUrl().GetOrigin() || | 201 return url.GetOrigin() == GetAddAccountUrl().GetOrigin() || |
191 StartsWith(base::UTF8ToUTF16(url.GetOrigin().host()), | 202 StartsWith(base::UTF8ToUTF16(url.GetOrigin().host()), |
192 base::ASCIIToUTF16("accounts."), | 203 base::ASCIIToUTF16("accounts."), |
193 false) || | 204 false) || |
194 IsSignInContinueUrl(url, &unused); | 205 IsSignInContinueUrl(url, &unused); |
195 } | 206 } |
196 | 207 |
197 bool IsUsingProd() { | 208 bool IsUsingProd() { |
198 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); | 209 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); |
199 } | 210 } |
200 | 211 |
201 } // namespace wallet | 212 } // namespace wallet |
202 } // namespace autofill | 213 } // namespace autofill |
OLD | NEW |