1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
#define COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
#include "base/supports_user_data.h"
#include "components/autofill/content/browser/wallet/wallet_client.h"
#include "components/autofill/content/browser/wallet/wallet_client_delegate.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/common/autocheckout_status.h"
#include "googleurl/src/gurl.h"
namespace content {
class BrowserContext;
}
namespace net {
class URLRequestContextGetter;
}
namespace autofill {
// AutocheckoutRequestManager's only responsiblity is to make sure any
// SendAutocheckoutStatus calls succeed regardless of any actions the user may
// make in the browser i.e. closing a tab, the requestAutocomplete dialog, etc.
// To that end, it is a piece of user data tied to the BrowserContext.
class AutocheckoutRequestManager : public base::SupportsUserData::Data,
public wallet::WalletClientDelegate {
public:
virtual ~AutocheckoutRequestManager();
// Creates a new AutocheckoutRequestManager and stores it as user data in
// |browser_context| if one does not already exist.
static void CreateForBrowserContext(
content::BrowserContext* browser_context);
// Retrieves the AutocheckoutRequestManager for |browser_context| if one
// exists.
static AutocheckoutRequestManager* FromBrowserContext(
content::BrowserContext* browser_context);
// Sends the |status| of an Autocheckout flow to Online Wallet using
// |wallet_client_|.
void SendAutocheckoutStatus(AutocheckoutStatus status,
const GURL& source_url,
const std::string& google_transaction_id);
// wallet::WalletClientDelegate:
virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE;
virtual DialogType GetDialogType() const OVERRIDE;
virtual std::string GetRiskData() const OVERRIDE;
virtual void OnDidAcceptLegalDocuments() OVERRIDE;
virtual void OnDidAuthenticateInstrument(bool success) OVERRIDE;
virtual void OnDidGetFullWallet(
scoped_ptr<wallet::FullWallet> full_wallet) OVERRIDE;
virtual void OnDidGetWalletItems(
scoped_ptr<wallet::WalletItems> wallet_items) OVERRIDE;
virtual void OnDidSaveAddress(
const std::string& address_id,
const std::vector<wallet::RequiredAction>& required_actions,
const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE;
virtual void OnDidSaveInstrument(
const std::string& instrument_id,
const std::vector<wallet::RequiredAction>& required_actions,
const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE;
virtual void OnDidSaveInstrumentAndAddress(
const std::string& instrument_id,
const std::string& address_id,
const std::vector<wallet::RequiredAction>& required_actions,
const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE;
virtual void OnDidUpdateAddress(
const std::string& address_id,
const std::vector<wallet::RequiredAction>& required_actions,
const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE;
virtual void OnDidUpdateInstrument(
const std::string& instrument_id,
const std::vector<wallet::RequiredAction>& required_actions,
const std::vector<wallet::FormFieldError>& form_field_errors) OVERRIDE;
virtual void OnWalletError(
wallet::WalletClient::ErrorType error_type) OVERRIDE;
private:
// |request_context_getter| is passed in to construct |wallet_client_|.
AutocheckoutRequestManager(
net::URLRequestContextGetter* request_context_getter);
// Logs various UMA metrics.
AutofillMetrics metric_logger_;
// Makes requests to Online Wallet. The only request this class is configured
// to make is SendAutocheckoutStatus.
wallet::WalletClient wallet_client_;
DISALLOW_COPY_AND_ASSIGN(AutocheckoutRequestManager);
};
} // namespace autofill
#endif // COMPONENTS_AUTOFILL_CONTENT_BROWSER_AUTOCHECKOUT_REQUEST_MANAGER_H_
|