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 15 matching lines...) Expand all Loading... |
26 const char kProdWalletServiceUrl[] = "https://wallet.google.com/"; | 26 const char kProdWalletServiceUrl[] = "https://wallet.google.com/"; |
27 | 27 |
28 const char kSandboxWalletServiceUrl[] = | 28 const char kSandboxWalletServiceUrl[] = |
29 "https://wallet-web.sandbox.google.com/"; | 29 "https://wallet-web.sandbox.google.com/"; |
30 | 30 |
31 const char kSandboxWalletSecureServiceUrl[] = | 31 const char kSandboxWalletSecureServiceUrl[] = |
32 "https://wallet-web.sandbox.google.com/"; | 32 "https://wallet-web.sandbox.google.com/"; |
33 | 33 |
34 bool IsWalletProductionEnabled() { | 34 bool IsWalletProductionEnabled() { |
35 // If the command line flag exists, it takes precedence. | 35 // If the command line flag exists, it takes precedence. |
36 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 36 const base::CommandLine* command_line = |
| 37 base::CommandLine::ForCurrentProcess(); |
37 std::string sandbox_enabled( | 38 std::string sandbox_enabled( |
38 command_line->GetSwitchValueASCII(switches::kWalletServiceUseSandbox)); | 39 command_line->GetSwitchValueASCII(switches::kWalletServiceUseSandbox)); |
39 if (!sandbox_enabled.empty()) | 40 if (!sandbox_enabled.empty()) |
40 return sandbox_enabled != "1"; | 41 return sandbox_enabled != "1"; |
41 | 42 |
42 // Default to sandbox when --reduce-security-for-testing is passed to allow | 43 // Default to sandbox when --reduce-security-for-testing is passed to allow |
43 // rAc on http:// pages. | 44 // rAc on http:// pages. |
44 if (command_line->HasSwitch(::switches::kReduceSecurityForTesting)) | 45 if (command_line->HasSwitch(::switches::kReduceSecurityForTesting)) |
45 return false; | 46 return false; |
46 | 47 |
47 #if defined(ENABLE_PROD_WALLET_SERVICE) | 48 #if defined(ENABLE_PROD_WALLET_SERVICE) |
48 return true; | 49 return true; |
49 #else | 50 #else |
50 return false; | 51 return false; |
51 #endif | 52 #endif |
52 } | 53 } |
53 | 54 |
54 GURL GetWalletHostUrl() { | 55 GURL GetWalletHostUrl() { |
55 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 56 const base::CommandLine& command_line = |
| 57 *base::CommandLine::ForCurrentProcess(); |
56 std::string wallet_service_hostname = | 58 std::string wallet_service_hostname = |
57 command_line.GetSwitchValueASCII(switches::kWalletServiceUrl); | 59 command_line.GetSwitchValueASCII(switches::kWalletServiceUrl); |
58 if (!wallet_service_hostname.empty()) | 60 if (!wallet_service_hostname.empty()) |
59 return GURL(wallet_service_hostname); | 61 return GURL(wallet_service_hostname); |
60 if (IsWalletProductionEnabled()) | 62 if (IsWalletProductionEnabled()) |
61 return GURL(kProdWalletServiceUrl); | 63 return GURL(kProdWalletServiceUrl); |
62 return GURL(kSandboxWalletServiceUrl); | 64 return GURL(kSandboxWalletServiceUrl); |
63 } | 65 } |
64 | 66 |
65 GURL GetBaseWalletUrl(size_t user_index) { | 67 GURL GetBaseWalletUrl(size_t user_index) { |
66 std::string path = base::StringPrintf("online/v2/u/%" PRIuS "/", user_index); | 68 std::string path = base::StringPrintf("online/v2/u/%" PRIuS "/", user_index); |
67 return GetWalletHostUrl().Resolve(path); | 69 return GetWalletHostUrl().Resolve(path); |
68 } | 70 } |
69 | 71 |
70 GURL GetBaseAutocheckoutUrl(size_t user_index) { | 72 GURL GetBaseAutocheckoutUrl(size_t user_index) { |
71 return GetBaseWalletUrl(user_index).Resolve("wallet/autocheckout/v1/"); | 73 return GetBaseWalletUrl(user_index).Resolve("wallet/autocheckout/v1/"); |
72 } | 74 } |
73 | 75 |
74 GURL GetBaseSecureUrl() { | 76 GURL GetBaseSecureUrl() { |
75 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 77 const base::CommandLine& command_line = |
| 78 *base::CommandLine::ForCurrentProcess(); |
76 std::string wallet_secure_url = | 79 std::string wallet_secure_url = |
77 command_line.GetSwitchValueASCII(switches::kWalletSecureServiceUrl); | 80 command_line.GetSwitchValueASCII(switches::kWalletSecureServiceUrl); |
78 if (!wallet_secure_url.empty()) | 81 if (!wallet_secure_url.empty()) |
79 return GURL(wallet_secure_url); | 82 return GURL(wallet_secure_url); |
80 if (IsWalletProductionEnabled()) | 83 if (IsWalletProductionEnabled()) |
81 return GURL(kProdWalletServiceUrl); | 84 return GURL(kProdWalletServiceUrl); |
82 return GURL(kSandboxWalletSecureServiceUrl); | 85 return GURL(kSandboxWalletSecureServiceUrl); |
83 } | 86 } |
84 | 87 |
85 GURL GetBaseEncryptedFrontendUrl(size_t user_index) { | 88 GURL GetBaseEncryptedFrontendUrl(size_t user_index) { |
86 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 89 const base::CommandLine& command_line = |
| 90 *base::CommandLine::ForCurrentProcess(); |
87 GURL base_url = IsWalletProductionEnabled() || | 91 GURL base_url = IsWalletProductionEnabled() || |
88 command_line.HasSwitch(switches::kWalletServiceUrl) ? | 92 command_line.HasSwitch(switches::kWalletServiceUrl) ? |
89 GetWalletHostUrl() : GetBaseSecureUrl(); | 93 GetWalletHostUrl() : GetBaseSecureUrl(); |
90 std::string path = | 94 std::string path = |
91 base::StringPrintf("online-secure/v2/u/%" PRIuS "/autocheckout/v1/", | 95 base::StringPrintf("online-secure/v2/u/%" PRIuS "/autocheckout/v1/", |
92 user_index); | 96 user_index); |
93 return base_url.Resolve(path); | 97 return base_url.Resolve(path); |
94 } | 98 } |
95 | 99 |
96 } // namespace | 100 } // namespace |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 false) || | 212 false) || |
209 IsSignInContinueUrl(url, &unused); | 213 IsSignInContinueUrl(url, &unused); |
210 } | 214 } |
211 | 215 |
212 bool IsUsingProd() { | 216 bool IsUsingProd() { |
213 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); | 217 return GetWalletHostUrl() == GURL(kProdWalletServiceUrl); |
214 } | 218 } |
215 | 219 |
216 } // namespace wallet | 220 } // namespace wallet |
217 } // namespace autofill | 221 } // namespace autofill |
OLD | NEW |