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

Side by Side Diff: components/payments/payment_request_impl.h

Issue 2611253004: [Payment Request] Change the lifetime management of PaymentRequestImpl (Closed)
Patch Set: added a browser test Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_IMPL_H_ 5 #ifndef COMPONENTS_PAYMENTS_PAYMENT_REQUEST_IMPL_H_
6 #define CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_IMPL_H_ 6 #define COMPONENTS_PAYMENTS_PAYMENT_REQUEST_IMPL_H_
7
8 #include <memory>
7 9
8 #include "components/payments/payment_request.mojom.h" 10 #include "components/payments/payment_request.mojom.h"
9 #include "mojo/public/cpp/bindings/binding.h" 11 #include "mojo/public/cpp/bindings/binding.h"
10 12
11 namespace content { 13 namespace content {
12 class WebContents; 14 class WebContents;
13 } 15 }
14 16
15 namespace payments { 17 namespace payments {
16 18
17 class PaymentRequestImpl : payments::mojom::PaymentRequest, 19 class PaymentRequestDelegate;
18 public base::RefCounted<PaymentRequestImpl> { 20 class PaymentRequestWebContentsManager;
21
22 class PaymentRequestImpl : payments::mojom::PaymentRequest {
19 public: 23 public:
20 PaymentRequestImpl( 24 PaymentRequestImpl(
21 content::WebContents* web_contents, 25 content::WebContents* web_contents,
26 std::unique_ptr<PaymentRequestDelegate> delegate,
27 PaymentRequestWebContentsManager* manager,
22 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request); 28 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request);
29 ~PaymentRequestImpl() override;
23 30
24 // payments::mojom::PaymentRequest "stub" 31 // payments::mojom::PaymentRequest "stub"
25 void Init(payments::mojom::PaymentRequestClientPtr client, 32 void Init(payments::mojom::PaymentRequestClientPtr client,
26 std::vector<payments::mojom::PaymentMethodDataPtr> methodData, 33 std::vector<payments::mojom::PaymentMethodDataPtr> methodData,
27 payments::mojom::PaymentDetailsPtr details, 34 payments::mojom::PaymentDetailsPtr details,
28 payments::mojom::PaymentOptionsPtr options) override; 35 payments::mojom::PaymentOptionsPtr options) override;
29 void Show() override; 36 void Show() override;
30 void UpdateWith(payments::mojom::PaymentDetailsPtr details) override {} 37 void UpdateWith(payments::mojom::PaymentDetailsPtr details) override {}
31 void Abort() override {} 38 void Abort() override {}
32 void Complete(payments::mojom::PaymentComplete result) override {} 39 void Complete(payments::mojom::PaymentComplete result) override {}
33 void CanMakePayment() override {} 40 void CanMakePayment() override {}
34 41
35 void Cancel(); 42 void Cancel();
36 void OnError(); 43 void OnError();
37 payments::mojom::PaymentDetails* details() { return details_.get(); } 44 payments::mojom::PaymentDetails* details() { return details_.get(); }
38 45
39 content::WebContents* web_contents() { return web_contents_; } 46 content::WebContents* web_contents() { return web_contents_; }
40 47
41 private: 48 private:
42 friend class base::RefCounted<PaymentRequestImpl>;
43 ~PaymentRequestImpl() override;
44
45 content::WebContents* web_contents_; 49 content::WebContents* web_contents_;
50 std::unique_ptr<PaymentRequestDelegate> delegate_;
51 PaymentRequestWebContentsManager* manager_; // Weakly owned.
please use gerrit instead 2017/01/06 21:49:09 Did you mean to say that |manager_| owns PaymentRe
Mathieu 2017/01/07 05:03:07 Done, clarified comment.
46 mojo::Binding<payments::mojom::PaymentRequest> binding_; 52 mojo::Binding<payments::mojom::PaymentRequest> binding_;
47 payments::mojom::PaymentRequestClientPtr client_; 53 payments::mojom::PaymentRequestClientPtr client_;
48 payments::mojom::PaymentDetailsPtr details_; 54 payments::mojom::PaymentDetailsPtr details_;
49 55
50 DISALLOW_COPY_AND_ASSIGN(PaymentRequestImpl); 56 DISALLOW_COPY_AND_ASSIGN(PaymentRequestImpl);
51 }; 57 };
52 58
53 } // namespace payments 59 } // namespace payments
54 60
55 void CreatePaymentRequestHandler( 61 #endif // COMPONENTS_PAYMENTS_PAYMENT_REQUEST_IMPL_H_
56 content::WebContents* web_contents,
57 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request);
58
59 #endif // CHROME_BROWSER_PAYMENTS_PAYMENT_REQUEST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698