summaryrefslogtreecommitdiffstats
path: root/components/autofill/content/browser/wallet/wallet_client_delegate.h
blob: fd04293759e270b1c577bc74031dd6c4bfeef534 (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// 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_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_
#define COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_

#include <string>

#include "base/memory/scoped_ptr.h"
#include "components/autofill/browser/autofill_manager_delegate.h"
#include "components/autofill/content/browser/wallet/form_field_error.h"
#include "components/autofill/content/browser/wallet/wallet_client.h"

class AutofillMetrics;

namespace autofill {
namespace wallet {

class FullWallet;
class WalletItems;

// WalletClientDelegate is to be implemented any classes making calls with
// WalletClient. The appropriate callback method will be called on
// WalletClientDelegate with the response from the Online Wallet backend.
class WalletClientDelegate {
 public:
  // --------------------------------------
  // Accessors called when making requests.
  // --------------------------------------

  // Returns the MetricLogger instance that should be used for logging Online
  // Wallet metrics.
  virtual const AutofillMetrics& GetMetricLogger() const = 0;

  // Returns the dialog type that the delegate corresponds to.
  virtual DialogType GetDialogType() const = 0;

  // Returns the serialized fingerprint data to be sent to the Risk server.
  virtual std::string GetRiskData() const = 0;

  // --------------------------------------------------------------------------
  // Callbacks called with responses from the Online Wallet backend.
  // --------------------------------------------------------------------------

  // Called when an AcceptLegalDocuments request finishes successfully.
  virtual void OnDidAcceptLegalDocuments() = 0;

  // Called when an AuthenticateInstrument request finishes successfully.
  virtual void OnDidAuthenticateInstrument(bool success) = 0;

  // Called when a GetFullWallet request finishes successfully. Ownership is
  // transferred to implementer of this interface.
  virtual void OnDidGetFullWallet(scoped_ptr<FullWallet> full_wallet) = 0;

  // Called when a GetWalletItems request finishes successfully. Ownership is
  // transferred to implementer of this interface.
  virtual void OnDidGetWalletItems(scoped_ptr<WalletItems> wallet_items) = 0;

  // Called when a SaveAddress request finishes successfully. |address_id| can
  // be used in subsequent GetFullWallet calls. |required_actions| is populated
  // if there was a validation error with the data being saved.
  // |form_field_errors| is populated with the actual form fields that are
  // failing validation.
  virtual void OnDidSaveAddress(
      const std::string& address_id,
      const std::vector<RequiredAction>& required_actions,
      const std::vector<FormFieldError>& form_field_errors) = 0;

  // Called when a SaveInstrument request finishes sucessfully. |instrument_id|
  // can be used in subsequent GetFullWallet calls. |required_actions| is
  // populated if there was a validation error with the data being saved.
  // |form_field_errors| is populated with the actual form fields that are
  // failing validation.
  virtual void OnDidSaveInstrument(
      const std::string& instrument_id,
      const std::vector<RequiredAction>& required_actions,
      const std::vector<FormFieldError>& form_field_errors) = 0;

  // Called when a SaveInstrumentAndAddress request finishes succesfully.
  // |instrument_id| and |address_id| can be used in subsequent
  // GetFullWallet calls. |required_actions| is populated if there was a
  // validation error with the data being saved. |form_field_errors| is
  // populated with the actual form fields that are failing validation.
  virtual void OnDidSaveInstrumentAndAddress(
      const std::string& instrument_id,
      const std::string& address_id,
      const std::vector<RequiredAction>& required_actions,
      const std::vector<FormFieldError>& form_field_errors) = 0;

  // Called when an UpdateAddress request finishes successfully.
  // |required_actions| is populated if there was a validation error with the
  // data being saved. |form_field_errors| is populated with the actual form
  // fields that are failing validation.
  virtual void OnDidUpdateAddress(
      const std::string& address_id,
      const std::vector<RequiredAction>& required_actions,
      const std::vector<FormFieldError>& form_field_errors) = 0;

  // Called when an UpdateInstrument request finishes successfully.
  // |required_actions| is populated if there was a validation error with the
  // data being saved. |form_field_errors| is populated with the actual form
  // fields that are failing validation.
  virtual void OnDidUpdateInstrument(
      const std::string& instrument_id,
      const std::vector<RequiredAction>& required_actions,
      const std::vector<FormFieldError>& form_field_errors) = 0;

  // Called when a request fails.
  virtual void OnWalletError(WalletClient::ErrorType error_type) = 0;

 protected:
  virtual ~WalletClientDelegate() {}
};

}  // namespace wallet
}  // namespace autofill

#endif  // COMPONENTS_AUTOFILL_BROWSER_WALLET_WALLET_CLIENT_OBSERVER_H_