| 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/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 56 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 57 std::string wallet_secure_url = | 57 std::string wallet_secure_url = |
| 58 command_line.GetSwitchValueASCII(switches::kWalletSecureServiceUrl); | 58 command_line.GetSwitchValueASCII(switches::kWalletSecureServiceUrl); |
| 59 if (!wallet_secure_url.empty()) | 59 if (!wallet_secure_url.empty()) |
| 60 return GURL(wallet_secure_url); | 60 return GURL(wallet_secure_url); |
| 61 if (IsWalletProductionEnabled()) | 61 if (IsWalletProductionEnabled()) |
| 62 return GURL(kProdWalletServiceUrl); | 62 return GURL(kProdWalletServiceUrl); |
| 63 return GURL(kSandboxWalletSecureServiceUrl); | 63 return GURL(kSandboxWalletSecureServiceUrl); |
| 64 } | 64 } |
| 65 | 65 |
| 66 GURL GetBaseEncryptedFrontendUrl() { |
| 67 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 68 // TODO(ahutter): Stop checking these switches once we switch over to prod. |
| 69 GURL base_url = IsWalletProductionEnabled() || |
| 70 command_line.HasSwitch(switches::kWalletServiceUrl) ? |
| 71 GetWalletHostUrl() : GetBaseSecureUrl(); |
| 72 return base_url.Resolve("online-secure/v2/autocheckout/v1/"); |
| 73 } |
| 74 |
| 66 } // namespace | 75 } // namespace |
| 67 | 76 |
| 68 namespace wallet { | 77 namespace wallet { |
| 69 | 78 |
| 70 GURL GetGetWalletItemsUrl() { | 79 GURL GetGetWalletItemsUrl() { |
| 71 return GetBaseAutocheckoutUrl().Resolve("getWalletItemsJwtless"); | 80 return GetBaseAutocheckoutUrl().Resolve("getWalletItemsJwtless"); |
| 72 } | 81 } |
| 73 | 82 |
| 74 GURL GetGetFullWalletUrl() { | 83 GURL GetGetFullWalletUrl() { |
| 75 return GetBaseAutocheckoutUrl().Resolve("getFullWalletJwtless"); | 84 return GetBaseEncryptedFrontendUrl().Resolve("getFullWalletJwtless?s7e=otp"); |
| 76 } | 85 } |
| 77 | 86 |
| 78 GURL GetManageInstrumentsUrl() { | 87 GURL GetManageInstrumentsUrl() { |
| 79 return GetBaseSecureUrl().Resolve("manage/w/0/#paymentMethods:"); | 88 return GetBaseSecureUrl().Resolve("manage/w/0/#paymentMethods:"); |
| 80 } | 89 } |
| 81 | 90 |
| 82 GURL GetManageAddressesUrl() { | 91 GURL GetManageAddressesUrl() { |
| 83 return GetBaseSecureUrl().Resolve("manage/w/0/#settings:addresses"); | 92 return GetBaseSecureUrl().Resolve("manage/w/0/#settings:addresses"); |
| 84 } | 93 } |
| 85 | 94 |
| 86 GURL GetAcceptLegalDocumentsUrl() { | 95 GURL GetAcceptLegalDocumentsUrl() { |
| 87 return GetBaseAutocheckoutUrl().Resolve("acceptLegalDocument"); | 96 return GetBaseAutocheckoutUrl().Resolve("acceptLegalDocument"); |
| 88 } | 97 } |
| 89 | 98 |
| 90 GURL GetAuthenticateInstrumentUrl() { | 99 GURL GetAuthenticateInstrumentUrl() { |
| 91 return GetBaseAutocheckoutUrl().Resolve("authenticateInstrument"); | 100 return GetBaseEncryptedFrontendUrl() |
| 101 .Resolve("authenticateInstrument?s7e=cvn"); |
| 92 } | 102 } |
| 93 | 103 |
| 94 GURL GetSendStatusUrl() { | 104 GURL GetSendStatusUrl() { |
| 95 return GetBaseAutocheckoutUrl().Resolve("reportStatus"); | 105 return GetBaseAutocheckoutUrl().Resolve("reportStatus"); |
| 96 } | 106 } |
| 97 | 107 |
| 108 GURL GetSaveToWalletNoEscrowUrl() { |
| 109 return GetBaseAutocheckoutUrl().Resolve("saveToWallet"); |
| 110 } |
| 111 |
| 98 GURL GetSaveToWalletUrl() { | 112 GURL GetSaveToWalletUrl() { |
| 99 return GetBaseAutocheckoutUrl().Resolve("saveToWallet"); | 113 return GetBaseEncryptedFrontendUrl() |
| 114 .Resolve("saveToWallet?s7e=card_number%3Bcvn"); |
| 100 } | 115 } |
| 101 | 116 |
| 102 GURL GetPassiveAuthUrl() { | 117 GURL GetPassiveAuthUrl() { |
| 103 return GetBaseWalletUrl().Resolve("passiveauth?isChromePayments=true"); | 118 return GetBaseWalletUrl().Resolve("passiveauth?isChromePayments=true"); |
| 104 } | 119 } |
| 105 | 120 |
| 106 GURL GetEncryptionUrl() { | |
| 107 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 108 // TODO(ahutter): Stop checking these switches once we switch over to prod. | |
| 109 if (IsWalletProductionEnabled() || | |
| 110 command_line.HasSwitch(switches::kWalletServiceUrl)) { | |
| 111 return GetWalletHostUrl().Resolve( | |
| 112 "online-secure/temporarydata/cvv?s7e=cvv"); | |
| 113 } else { | |
| 114 return GetBaseSecureUrl().Resolve( | |
| 115 "online-secure/temporarydata/cvv?s7e=cvv"); | |
| 116 } | |
| 117 } | |
| 118 | |
| 119 GURL GetEscrowUrl() { | |
| 120 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 121 // TODO(ahutter): Stop checking these switches once we switch over to prod. | |
| 122 if (IsWalletProductionEnabled() || | |
| 123 command_line.HasSwitch(switches::kWalletServiceUrl)) { | |
| 124 return GetBaseSecureUrl().Resolve("dehEfe?s7e=cardNumber%3Bcvv"); | |
| 125 } else { | |
| 126 return GetBaseSecureUrl().Resolve("checkout/dehEfe?s7e=cardNumber%3Bcvv"); | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 GURL GetSignInUrl() { | 121 GURL GetSignInUrl() { |
| 131 GURL url(GaiaUrls::GetInstance()->service_login_url()); | 122 GURL url(GaiaUrls::GetInstance()->service_login_url()); |
| 132 url = net::AppendQueryParameter(url, "service", "toolbar"); | 123 url = net::AppendQueryParameter(url, "service", "toolbar"); |
| 133 url = net::AppendQueryParameter(url, "nui", "1"); | 124 url = net::AppendQueryParameter(url, "nui", "1"); |
| 134 url = net::AppendQueryParameter(url, | 125 url = net::AppendQueryParameter(url, |
| 135 "continue", | 126 "continue", |
| 136 GetSignInContinueUrl().spec()); | 127 GetSignInContinueUrl().spec()); |
| 137 return url; | 128 return url; |
| 138 } | 129 } |
| 139 | 130 |
| 140 // The continue url portion of the sign-in URL. | 131 // The continue url portion of the sign-in URL. |
| 141 GURL GetSignInContinueUrl() { | 132 GURL GetSignInContinueUrl() { |
| 142 return GetPassiveAuthUrl(); | 133 return GetPassiveAuthUrl(); |
| 143 } | 134 } |
| 144 | 135 |
| 145 bool IsSignInContinueUrl(const GURL& url) { | 136 bool IsSignInContinueUrl(const GURL& url) { |
| 146 GURL final_url = wallet::GetSignInContinueUrl(); | 137 GURL final_url = wallet::GetSignInContinueUrl(); |
| 147 return url.SchemeIsSecure() && | 138 return url.SchemeIsSecure() && |
| 148 url.host() == final_url.host() && | 139 url.host() == final_url.host() && |
| 149 url.path() == final_url.path(); | 140 url.path() == final_url.path(); |
| 150 } | 141 } |
| 151 | 142 |
| 152 bool IsUsingProd() { | 143 bool IsUsingProd() { |
| 153 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); | 144 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); |
| 154 } | 145 } |
| 155 | 146 |
| 156 } // namespace wallet | 147 } // namespace wallet |
| 157 } // namespace autofill | 148 } // namespace autofill |
| OLD | NEW |