Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: components/autofill/content/browser/wallet/wallet_service_url.cc

Issue 1999923002: Move the Google Payments URL functions out of content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
6
7 #include <string>
8
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"
21 #include "url/gurl.h"
22
23 namespace autofill {
24 namespace {
25
26 const char kProdWalletServiceUrl[] = "https://wallet.google.com/";
27
28 const char kSandboxWalletSecureServiceUrl[] =
29 "https://wallet-web.sandbox.google.com/";
30
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";
39
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))
43 return false;
44
45 #if defined(ENABLE_PROD_WALLET_SERVICE)
46 return true;
47 #else
48 return false;
49 #endif
50 }
51
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);
62 }
63
64 } // namespace
65
66 namespace wallet {
67
68 GURL GetManageInstrumentsUrl(size_t user_index) {
69 std::string path =
70 base::StringPrintf("manage/w/%" PRIuS "/paymentMethods", user_index);
71 return GetBaseSecureUrl().Resolve(path);
72 }
73
74 GURL GetManageAddressesUrl(size_t user_index) {
75 std::string path =
76 base::StringPrintf("manage/w/%" PRIuS "/settings/addresses", user_index);
77 return GetBaseSecureUrl().Resolve(path);
78 }
79
80 } // namespace wallet
81 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698