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

Unified Diff: ios/chrome/browser/web/form_resubmission_tab_helper.mm

Issue 2642463002: Implemented FormResubmissionTabHelper. (Closed)
Patch Set: Updated GN deps 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/web/form_resubmission_tab_helper.mm
diff --git a/ios/chrome/browser/web/form_resubmission_tab_helper.mm b/ios/chrome/browser/web/form_resubmission_tab_helper.mm
new file mode 100644
index 0000000000000000000000000000000000000000..2255a0df8760d3ada2021180eb5089202b68c1bd
--- /dev/null
+++ b/ios/chrome/browser/web/form_resubmission_tab_helper.mm
@@ -0,0 +1,41 @@
+// Copyright 2017 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.
+
+#import "ios/chrome/browser/web/form_resubmission_tab_helper.h"
+
+#import "ios/chrome/browser/ui/alert_coordinator/form_resubmission_coordinator.h"
+#import "ios/chrome/browser/ui/util/top_view_controller.h"
+
+DEFINE_WEB_STATE_USER_DATA_KEY(FormResubmissionTabHelper);
+
+FormResubmissionTabHelper::FormResubmissionTabHelper(web::WebState* web_state)
+ : web::WebStateObserver(web_state) {}
+
+FormResubmissionTabHelper::~FormResubmissionTabHelper() = default;
+
+void FormResubmissionTabHelper::PresentFormResubmissionDialog(
+ CGPoint location,
+ const base::Callback<void(bool)>& callback) {
+ UIViewController* top_controller =
+ top_view_controller::TopPresentedViewControllerFrom(
+ [UIApplication sharedApplication].keyWindow.rootViewController);
+
+ base::Callback<void(bool)> local_callback(callback);
+ coordinator_.reset([[FormResubmissionCoordinator alloc]
+ initWithBaseViewController:top_controller
+ dialogLocation:location
+ webState:web_state()
+ completionHandler:^(BOOL should_continue) {
+ local_callback.Run(should_continue);
+ }]);
+ [coordinator_ start];
+}
+
+void FormResubmissionTabHelper::ProvisionalNavigationStarted(const GURL&) {
+ coordinator_.reset();
+}
+
+void FormResubmissionTabHelper::WebStateDestroyed() {
+ coordinator_.reset();
+}

Powered by Google App Engine
This is Rietveld 408576698