Chromium Code Reviews| 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 if (IsWalletProductionEnabled() || | |
| 70 command_line.HasSwitch(switches::kWalletServiceUrl)) { | |
| 71 return GetWalletHostUrl().Resolve("online-secure/v2/autocheckout/v1/"); | |
| 72 } else { | |
| 73 return GetBaseSecureUrl().Resolve("online-secure/v2/autocheckout/v1/"); | |
| 74 } | |
|
Dan Beam
2013/07/02 01:25:52
nit:
GURL base_url = IsWalletProductionEnabled(
ahutter
2013/07/02 15:44:23
Done.
| |
| 75 } | |
| 76 | |
| 66 } // namespace | 77 } // namespace |
| 67 | 78 |
| 68 namespace wallet { | 79 namespace wallet { |
| 69 | 80 |
| 70 GURL GetGetWalletItemsUrl() { | 81 GURL GetGetWalletItemsUrl() { |
| 71 return GetBaseAutocheckoutUrl().Resolve("getWalletItemsJwtless"); | 82 return GetBaseAutocheckoutUrl().Resolve("getWalletItemsJwtless"); |
| 72 } | 83 } |
| 73 | 84 |
| 74 GURL GetGetFullWalletUrl() { | 85 GURL GetGetFullWalletUrl() { |
| 75 return GetBaseAutocheckoutUrl().Resolve("getFullWalletJwtless"); | 86 return GetBaseEncryptedFrontendUrl().Resolve("getFullWalletJwtless?s7e=otp"); |
| 76 } | 87 } |
| 77 | 88 |
| 78 GURL GetManageInstrumentsUrl() { | 89 GURL GetManageInstrumentsUrl() { |
| 79 return GetBaseSecureUrl().Resolve("manage/w/0/#paymentMethods:"); | 90 return GetBaseSecureUrl().Resolve("manage/w/0/#paymentMethods:"); |
| 80 } | 91 } |
| 81 | 92 |
| 82 GURL GetManageAddressesUrl() { | 93 GURL GetManageAddressesUrl() { |
| 83 return GetBaseSecureUrl().Resolve("manage/w/0/#settings:addresses"); | 94 return GetBaseSecureUrl().Resolve("manage/w/0/#settings:addresses"); |
| 84 } | 95 } |
| 85 | 96 |
| 86 GURL GetAcceptLegalDocumentsUrl() { | 97 GURL GetAcceptLegalDocumentsUrl() { |
| 87 return GetBaseAutocheckoutUrl().Resolve("acceptLegalDocument"); | 98 return GetBaseAutocheckoutUrl().Resolve("acceptLegalDocument"); |
| 88 } | 99 } |
| 89 | 100 |
| 90 GURL GetAuthenticateInstrumentUrl() { | 101 GURL GetAuthenticateInstrumentUrl() { |
| 91 return GetBaseAutocheckoutUrl().Resolve("authenticateInstrument"); | 102 return GetBaseEncryptedFrontendUrl() |
| 103 .Resolve("authenticateInstrument?s7e=cvn"); | |
| 92 } | 104 } |
| 93 | 105 |
| 94 GURL GetSendStatusUrl() { | 106 GURL GetSendStatusUrl() { |
| 95 return GetBaseAutocheckoutUrl().Resolve("reportStatus"); | 107 return GetBaseAutocheckoutUrl().Resolve("reportStatus"); |
| 96 } | 108 } |
| 97 | 109 |
| 98 GURL GetSaveToWalletUrl() { | 110 GURL GetSaveToWalletUrl() { |
| 99 return GetBaseAutocheckoutUrl().Resolve("saveToWallet"); | 111 return GetBaseEncryptedFrontendUrl() |
| 112 .Resolve("saveToWallet?s7e=card_number%3Bcvn"); | |
| 100 } | 113 } |
| 101 | 114 |
| 102 GURL GetPassiveAuthUrl() { | 115 GURL GetPassiveAuthUrl() { |
| 103 return GetBaseWalletUrl().Resolve("passiveauth?isChromePayments=true"); | 116 return GetBaseWalletUrl().Resolve("passiveauth?isChromePayments=true"); |
| 104 } | 117 } |
| 105 | 118 |
| 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() { | 119 GURL GetSignInUrl() { |
| 131 GURL url(GaiaUrls::GetInstance()->service_login_url()); | 120 GURL url(GaiaUrls::GetInstance()->service_login_url()); |
| 132 url = net::AppendQueryParameter(url, "service", "toolbar"); | 121 url = net::AppendQueryParameter(url, "service", "toolbar"); |
| 133 url = net::AppendQueryParameter(url, "nui", "1"); | 122 url = net::AppendQueryParameter(url, "nui", "1"); |
| 134 url = net::AppendQueryParameter(url, | 123 url = net::AppendQueryParameter(url, |
| 135 "continue", | 124 "continue", |
| 136 GetSignInContinueUrl().spec()); | 125 GetSignInContinueUrl().spec()); |
| 137 return url; | 126 return url; |
| 138 } | 127 } |
| 139 | 128 |
| 140 // The continue url portion of the sign-in URL. | 129 // The continue url portion of the sign-in URL. |
| 141 GURL GetSignInContinueUrl() { | 130 GURL GetSignInContinueUrl() { |
| 142 return GetPassiveAuthUrl(); | 131 return GetPassiveAuthUrl(); |
| 143 } | 132 } |
| 144 | 133 |
| 145 bool IsSignInContinueUrl(const GURL& url) { | 134 bool IsSignInContinueUrl(const GURL& url) { |
| 146 GURL final_url = wallet::GetSignInContinueUrl(); | 135 GURL final_url = wallet::GetSignInContinueUrl(); |
| 147 return url.SchemeIsSecure() && | 136 return url.SchemeIsSecure() && |
| 148 url.host() == final_url.host() && | 137 url.host() == final_url.host() && |
| 149 url.path() == final_url.path(); | 138 url.path() == final_url.path(); |
| 150 } | 139 } |
| 151 | 140 |
| 152 bool IsUsingProd() { | 141 bool IsUsingProd() { |
| 153 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); | 142 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); |
| 154 } | 143 } |
| 155 | 144 |
| 156 } // namespace wallet | 145 } // namespace wallet |
| 157 } // namespace autofill | 146 } // namespace autofill |
| OLD | NEW |