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

Side by Side Diff: components/autofill/core/browser/payments/payments_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
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/core/browser/payments/payments_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"
11 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "components/autofill/core/common/autofill_switches.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" 17 #include "google_apis/gaia/gaia_urls.h"
20 #include "net/base/url_util.h" 18 #include "net/base/url_util.h"
21 #include "url/gurl.h" 19 #include "url/gurl.h"
22 20
23 namespace autofill { 21 namespace autofill {
24 namespace { 22 namespace {
25 23
26 const char kProdWalletServiceUrl[] = "https://wallet.google.com/"; 24 const char kProdPaymentsServiceUrl[] = "https://wallet.google.com/";
27 25
28 const char kSandboxWalletSecureServiceUrl[] = 26 const char kSandboxPaymentsSecureServiceUrl[] =
29 "https://wallet-web.sandbox.google.com/"; 27 "https://wallet-web.sandbox.google.com/";
30 28
31 bool IsWalletProductionEnabled() { 29 } // namespace
30
31 namespace payments {
32
33 bool IsPaymentsProductionEnabled() {
32 // If the command line flag exists, it takes precedence. 34 // If the command line flag exists, it takes precedence.
33 const base::CommandLine* command_line = 35 const base::CommandLine* command_line =
34 base::CommandLine::ForCurrentProcess(); 36 base::CommandLine::ForCurrentProcess();
35 std::string sandbox_enabled( 37 std::string sandbox_enabled(
36 command_line->GetSwitchValueASCII(switches::kWalletServiceUseSandbox)); 38 command_line->GetSwitchValueASCII(switches::kWalletServiceUseSandbox));
37 if (!sandbox_enabled.empty()) 39 if (!sandbox_enabled.empty())
38 return sandbox_enabled != "1"; 40 return sandbox_enabled != "1";
39 41
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) 42 #if defined(ENABLE_PROD_WALLET_SERVICE)
46 return true; 43 return true;
47 #else 44 #else
48 return false; 45 return false;
49 #endif 46 #endif
50 } 47 }
51 48
52 GURL GetBaseSecureUrl() { 49 GURL GetBaseSecureUrl() {
53 const base::CommandLine& command_line = 50 return GURL(IsPaymentsProductionEnabled() ? kProdPaymentsServiceUrl
54 *base::CommandLine::ForCurrentProcess(); 51 : kSandboxPaymentsSecureServiceUrl);
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 } 52 }
63 53
64 } // namespace
65
66 namespace wallet {
67
68 GURL GetManageInstrumentsUrl(size_t user_index) { 54 GURL GetManageInstrumentsUrl(size_t user_index) {
69 std::string path = 55 std::string path =
70 base::StringPrintf("manage/w/%" PRIuS "/paymentMethods", user_index); 56 base::StringPrintf("manage/w/%" PRIuS "/paymentMethods", user_index);
71 return GetBaseSecureUrl().Resolve(path); 57 return GetBaseSecureUrl().Resolve(path);
72 } 58 }
73 59
74 GURL GetManageAddressesUrl(size_t user_index) { 60 GURL GetManageAddressesUrl(size_t user_index) {
75 std::string path = 61 std::string path =
76 base::StringPrintf("manage/w/%" PRIuS "/settings/addresses", user_index); 62 base::StringPrintf("manage/w/%" PRIuS "/settings/addresses", user_index);
77 return GetBaseSecureUrl().Resolve(path); 63 return GetBaseSecureUrl().Resolve(path);
78 } 64 }
79 65
80 } // namespace wallet 66 } // namespace payments
81 } // namespace autofill 67 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698