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

Unified Diff: chrome/browser/payments/payment_request_impl.cc

Issue 2529733002: [WebPayments] Move views-specific code to c/b/ui/views/ (Closed)
Patch Set: Implement ShowWebPaymentsDialog in TestBrowserWindow Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/payments/payment_request_impl.cc
diff --git a/chrome/browser/payments/payment_request_impl.cc b/chrome/browser/payments/payment_request_impl.cc
index 04e24681ea55124bf20874f6b68954a9f9503276..e5dde0296da38cda73ecd41678fcf1f2111eb935 100644
--- a/chrome/browser/payments/payment_request_impl.cc
+++ b/chrome/browser/payments/payment_request_impl.cc
@@ -7,10 +7,8 @@
#include <map>
#include "base/lazy_instance.h"
-#include "chrome/browser/payments/ui/payment_request_dialog.h"
-#include "components/web_modal/web_contents_modal_dialog_host.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
-#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
@@ -51,8 +49,7 @@ PaymentRequestImpl::PaymentRequestImpl(
content::WebContents* web_contents,
mojo::InterfaceRequest<payments::mojom::PaymentRequest> request)
: web_contents_(web_contents),
- binding_(this, std::move(request)),
- dialog_(nullptr) {
+ binding_(this, std::move(request)) {
binding_.set_connection_error_handler(
base::Bind(&PaymentRequestImpl::OnError, this));
}
@@ -65,19 +62,19 @@ void PaymentRequestImpl::Init(
payments::mojom::PaymentDetailsPtr details,
payments::mojom::PaymentOptionsPtr options) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- dialog_ = new PaymentRequestDialog(std::move(client));
- views::DialogDelegate::CreateDialogWidget(
- dialog_, nullptr,
- web_modal::WebContentsModalDialogManager::FromWebContents(web_contents_)
- ->delegate()
- ->GetWebContentsModalDialogHost()
- ->GetHostView())
- ->Show();
+ client_ = std::move(client);
+ chrome::FindBrowserWithWebContents(web_contents_)
+ ->window()
+ ->ShowWebPaymentsDialog(this);
+}
+
+void PaymentRequestImpl::Cancel() {
+ client_->OnError(payments::mojom::PaymentErrorReason::USER_CANCEL);
}
void PaymentRequestImpl::OnError() {
binding_.Close();
- // TODO(krb): Call dialog_->Close() here, but avoid double-free
+ // TODO(krb): Close the dialog here, but avoid double-free
payment_request_factory.Get().UnassignPaymentRequest(web_contents_);
}

Powered by Google App Engine
This is Rietveld 408576698