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

Side by Side Diff: components/payments/content/payment_request_web_contents_manager.cc

Issue 2870153002: [Payments] Record navigations that close the Payment Request as aborts. (Closed)
Patch Set: Fixed Windows error Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/payments/content/payment_request_web_contents_manager.h" 5 #include "components/payments/content/payment_request_web_contents_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "components/payments/content/payment_request.h" 11 #include "components/payments/content/payment_request.h"
12 #include "components/payments/core/payment_request_delegate.h" 12 #include "components/payments/core/payment_request_delegate.h"
13 #include "content/public/browser/navigation_handle.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 15
15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(payments::PaymentRequestWebContentsManager); 16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(payments::PaymentRequestWebContentsManager);
16 17
17 namespace payments { 18 namespace payments {
18 19
19 PaymentRequestWebContentsManager::~PaymentRequestWebContentsManager() {} 20 PaymentRequestWebContentsManager::~PaymentRequestWebContentsManager() {}
20 21
21 PaymentRequestWebContentsManager* 22 PaymentRequestWebContentsManager*
22 PaymentRequestWebContentsManager::GetOrCreateForWebContents( 23 PaymentRequestWebContentsManager::GetOrCreateForWebContents(
(...skipping 10 matching lines...) Expand all
33 std::unique_ptr<PaymentRequestDelegate> delegate, 34 std::unique_ptr<PaymentRequestDelegate> delegate,
34 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request, 35 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request,
35 PaymentRequest::ObserverForTest* observer_for_testing) { 36 PaymentRequest::ObserverForTest* observer_for_testing) {
36 auto new_request = base::MakeUnique<PaymentRequest>( 37 auto new_request = base::MakeUnique<PaymentRequest>(
37 render_frame_host, web_contents, std::move(delegate), this, 38 render_frame_host, web_contents, std::move(delegate), this,
38 std::move(request), observer_for_testing); 39 std::move(request), observer_for_testing);
39 PaymentRequest* request_ptr = new_request.get(); 40 PaymentRequest* request_ptr = new_request.get();
40 payment_requests_.insert(std::make_pair(request_ptr, std::move(new_request))); 41 payment_requests_.insert(std::make_pair(request_ptr, std::move(new_request)));
41 } 42 }
42 43
44 void PaymentRequestWebContentsManager::DidStartNavigation(
45 content::NavigationHandle* navigation_handle) {
46 for (auto& it : payment_requests_) {
47 // Since the PaymentRequest dialog blocks the content of the page, the user
48 // cannot click on a link to navigate away. Therefore, if the navigation
49 // is initiated in the renderer, it does not come from the user.
50 it.second->DidStartNavigation(!navigation_handle->IsRendererInitiated());
51 }
52 }
53
43 void PaymentRequestWebContentsManager::DestroyRequest(PaymentRequest* request) { 54 void PaymentRequestWebContentsManager::DestroyRequest(PaymentRequest* request) {
44 if (request == showing_) 55 if (request == showing_)
45 showing_ = nullptr; 56 showing_ = nullptr;
46 payment_requests_.erase(request); 57 payment_requests_.erase(request);
47 } 58 }
48 59
49 bool PaymentRequestWebContentsManager::CanShow(PaymentRequest* request) { 60 bool PaymentRequestWebContentsManager::CanShow(PaymentRequest* request) {
50 DCHECK(request); 61 DCHECK(request);
51 DCHECK(payment_requests_.find(request) != payment_requests_.end()); 62 DCHECK(payment_requests_.find(request) != payment_requests_.end());
52 if (!showing_) { 63 if (!showing_) {
53 showing_ = request; 64 showing_ = request;
54 return true; 65 return true;
55 } else { 66 } else {
56 return false; 67 return false;
57 } 68 }
58 } 69 }
59 70
60 PaymentRequestWebContentsManager::PaymentRequestWebContentsManager( 71 PaymentRequestWebContentsManager::PaymentRequestWebContentsManager(
61 content::WebContents* web_contents) 72 content::WebContents* web_contents)
62 : showing_(nullptr) {} 73 : content::WebContentsObserver(web_contents), showing_(nullptr) {}
63 74
64 } // namespace payments 75 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/payment_request_web_contents_manager.h ('k') | components/payments/core/journey_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698