OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/autofill/wallet/wallet_service_url.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "base/command_line.h" | |
10 #include "components/autofill/common/autofill_switches.h" | |
11 #include "google_apis/gaia/gaia_urls.h" | |
12 #include "googleurl/src/gurl.h" | |
13 #include "net/base/url_util.h" | |
14 | |
15 namespace { | |
16 | |
17 const char kDefaultWalletServiceUrl[] = "https://wallet.google.com/"; | |
18 | |
19 GURL GetWalletHostUrl() { | |
20 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
21 std::string wallet_service_hostname = | |
22 command_line.GetSwitchValueASCII(switches::kWalletServiceUrl); | |
23 return !wallet_service_hostname.empty() ? GURL(wallet_service_hostname) : | |
24 GURL(kDefaultWalletServiceUrl); | |
25 } | |
26 | |
27 GURL GetBaseWalletUrl() { | |
28 return GetWalletHostUrl().Resolve("online/v2/"); | |
29 } | |
30 | |
31 GURL GetBaseAutocheckoutUrl() { | |
32 return GetBaseWalletUrl().Resolve("wallet/autocheckout/v1/"); | |
33 } | |
34 | |
35 GURL GetBaseSecureUrl() { | |
36 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
37 std::string wallet_secure_url = | |
38 command_line.GetSwitchValueASCII(switches::kWalletSecureServiceUrl); | |
39 return !wallet_secure_url.empty() ? GURL(wallet_secure_url) : | |
40 GURL(kDefaultWalletServiceUrl); | |
41 } | |
42 | |
43 } // anonymous namespace | |
44 | |
45 namespace autofill { | |
46 namespace wallet { | |
47 | |
48 GURL GetGetWalletItemsUrl() { | |
49 return GetBaseAutocheckoutUrl().Resolve("getWalletItemsJwtless"); | |
50 } | |
51 | |
52 GURL GetGetFullWalletUrl() { | |
53 return GetBaseAutocheckoutUrl().Resolve("getFullWalletJwtless"); | |
54 } | |
55 | |
56 GURL GetAcceptLegalDocumentsUrl() { | |
57 return GetBaseAutocheckoutUrl().Resolve("acceptLegalDocument"); | |
58 } | |
59 | |
60 GURL GetAuthenticateInstrumentUrl() { | |
61 return GetBaseAutocheckoutUrl().Resolve("authenticateInstrument"); | |
62 } | |
63 | |
64 GURL GetSendStatusUrl() { | |
65 return GetBaseAutocheckoutUrl().Resolve("reportStatus"); | |
66 } | |
67 | |
68 GURL GetSaveToWalletUrl() { | |
69 return GetBaseAutocheckoutUrl().Resolve("saveToWallet"); | |
70 } | |
71 | |
72 GURL GetPassiveAuthUrl() { | |
73 return GetBaseWalletUrl().Resolve("passiveauth"); | |
74 } | |
75 | |
76 GURL GetEncryptionUrl() { | |
77 return GetWalletHostUrl().Resolve("online-secure/temporarydata/cvv?s7e=cvv"); | |
78 } | |
79 | |
80 GURL GetEscrowUrl() { | |
81 return GetBaseSecureUrl().Resolve("dehEfe?s7e=cardNumber%3Bcvv"); | |
82 } | |
83 | |
84 GURL GetSignInUrl() { | |
85 GURL url(GaiaUrls::GetInstance()->service_login_url()); | |
86 url = net::AppendQueryParameter(url, "service", "sierra"); | |
87 url = net::AppendQueryParameter(url, "btmpl", "popup"); | |
88 url = net::AppendQueryParameter(url, | |
89 "continue", | |
90 GetSignInContinueUrl().spec()); | |
91 return url; | |
92 } | |
93 | |
94 // The continue url portion of the sign-in URL. | |
95 GURL GetSignInContinueUrl() { | |
96 return GetPassiveAuthUrl(); | |
97 } | |
98 | |
99 bool IsSignInContinueUrl(const GURL& url) { | |
100 GURL final_url = wallet::GetSignInContinueUrl(); | |
101 return url.SchemeIsSecure() && | |
102 url.host() == final_url.host() && | |
103 url.path() == final_url.path(); | |
104 } | |
105 | |
106 } // namespace wallet | |
107 } // namespace autofill | |
OLD | NEW |