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
3 // found in the LICENSE file.
5 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
9 #include "base/command_line.h"
10 #include "base/format_macros.h"
11 #include "base/metrics/field_trial.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h"
16 #include "components/autofill/core/common/autofill_switches.h"
17 #include "content/public/common/content_switches.h"
18 #include "content/public/common/url_constants.h"
19 #include "google_apis/gaia/gaia_urls.h"
20 #include "net/base/url_util.h"
26 const char kProdWalletServiceUrl
[] = "https://wallet.google.com/";
28 const char kSandboxWalletSecureServiceUrl
[] =
29 "https://wallet-web.sandbox.google.com/";
31 bool IsWalletProductionEnabled() {
32 // If the command line flag exists, it takes precedence.
33 const base::CommandLine
* command_line
=
34 base::CommandLine::ForCurrentProcess();
35 std::string
sandbox_enabled(
36 command_line
->GetSwitchValueASCII(switches::kWalletServiceUseSandbox
));
37 if (!sandbox_enabled
.empty())
38 return sandbox_enabled
!= "1";
40 // Default to sandbox when --reduce-security-for-testing is passed to allow
41 // rAc on http:// pages.
42 if (command_line
->HasSwitch(::switches::kReduceSecurityForTesting
))
45 #if defined(ENABLE_PROD_WALLET_SERVICE)
52 GURL
GetBaseSecureUrl() {
53 const base::CommandLine
& command_line
=
54 *base::CommandLine::ForCurrentProcess();
55 std::string wallet_secure_url
=
56 command_line
.GetSwitchValueASCII(switches::kWalletSecureServiceUrl
);
57 if (!wallet_secure_url
.empty())
58 return GURL(wallet_secure_url
);
59 if (IsWalletProductionEnabled())
60 return GURL(kProdWalletServiceUrl
);
61 return GURL(kSandboxWalletSecureServiceUrl
);
68 GURL
GetManageInstrumentsUrl(size_t user_index
) {
70 base::StringPrintf("manage/w/%" PRIuS
"/paymentMethods", user_index
);
71 return GetBaseSecureUrl().Resolve(path
);
74 GURL
GetManageAddressesUrl(size_t user_index
) {
76 base::StringPrintf("manage/w/%" PRIuS
"/settings/addresses", user_index
);
77 return GetBaseSecureUrl().Resolve(path
);
81 } // namespace autofill