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

Side by Side Diff: ios/chrome/browser/tabs/tab.mm

Issue 2642463002: Implemented FormResubmissionTabHelper. (Closed)
Patch Set: Moved FormResubmissionTabHelper::CreateForWebState to init 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import "ios/chrome/browser/tabs/tab.h" 5 #import "ios/chrome/browser/tabs/tab.h"
6 6
7 #import <CoreLocation/CoreLocation.h> 7 #import <CoreLocation/CoreLocation.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "ios/chrome/browser/history/history_service_factory.h" 67 #include "ios/chrome/browser/history/history_service_factory.h"
68 #include "ios/chrome/browser/history/top_sites_factory.h" 68 #include "ios/chrome/browser/history/top_sites_factory.h"
69 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" 69 #include "ios/chrome/browser/infobars/infobar_manager_impl.h"
70 #include "ios/chrome/browser/metrics/ios_chrome_origins_seen_service_factory.h" 70 #include "ios/chrome/browser/metrics/ios_chrome_origins_seen_service_factory.h"
71 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" 71 #import "ios/chrome/browser/metrics/tab_usage_recorder.h"
72 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller .h" 72 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller .h"
73 #import "ios/chrome/browser/passwords/credential_manager.h" 73 #import "ios/chrome/browser/passwords/credential_manager.h"
74 #import "ios/chrome/browser/passwords/js_credential_manager.h" 74 #import "ios/chrome/browser/passwords/js_credential_manager.h"
75 #import "ios/chrome/browser/passwords/password_controller.h" 75 #import "ios/chrome/browser/passwords/password_controller.h"
76 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h" 76 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h"
77 #import "ios/chrome/browser/web/form_resubmission_tab_helper.h"
77 #include "ios/chrome/browser/pref_names.h" 78 #include "ios/chrome/browser/pref_names.h"
78 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" 79 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
79 #include "ios/chrome/browser/reading_list/reading_list_web_state_observer.h" 80 #include "ios/chrome/browser/reading_list/reading_list_web_state_observer.h"
80 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" 81 #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
81 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" 82 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h"
82 #include "ios/chrome/browser/signin/account_consistency_service_factory.h" 83 #include "ios/chrome/browser/signin/account_consistency_service_factory.h"
83 #include "ios/chrome/browser/signin/account_reconcilor_factory.h" 84 #include "ios/chrome/browser/signin/account_reconcilor_factory.h"
84 #include "ios/chrome/browser/signin/authentication_service.h" 85 #include "ios/chrome/browser/signin/authentication_service.h"
85 #include "ios/chrome/browser/signin/authentication_service_factory.h" 86 #include "ios/chrome/browser/signin/authentication_service_factory.h"
86 #include "ios/chrome/browser/signin/signin_capability.h" 87 #include "ios/chrome/browser/signin/signin_capability.h"
87 #import "ios/chrome/browser/snapshots/snapshot_manager.h" 88 #import "ios/chrome/browser/snapshots/snapshot_manager.h"
88 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" 89 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h"
89 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" 90 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h"
90 #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h" 91 #include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h"
91 #import "ios/chrome/browser/storekit_launcher.h" 92 #import "ios/chrome/browser/storekit_launcher.h"
92 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h" 93 #include "ios/chrome/browser/sync/ios_chrome_synced_tab_delegate.h"
93 #import "ios/chrome/browser/tabs/tab_delegate.h" 94 #import "ios/chrome/browser/tabs/tab_delegate.h"
94 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" 95 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h"
95 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" 96 #import "ios/chrome/browser/tabs/tab_headers_delegate.h"
96 #import "ios/chrome/browser/tabs/tab_model.h" 97 #import "ios/chrome/browser/tabs/tab_model.h"
97 #import "ios/chrome/browser/tabs/tab_private.h" 98 #import "ios/chrome/browser/tabs/tab_private.h"
98 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" 99 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h"
99 #include "ios/chrome/browser/translate/chrome_ios_translate_client.h" 100 #include "ios/chrome/browser/translate/chrome_ios_translate_client.h"
100 #import "ios/chrome/browser/u2f/u2f_controller.h" 101 #import "ios/chrome/browser/u2f/u2f_controller.h"
101 #import "ios/chrome/browser/ui/alert_coordinator/form_resubmission_coordinator.h "
102 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" 102 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
103 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 103 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
104 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 104 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
105 #import "ios/chrome/browser/ui/commands/open_url_command.h" 105 #import "ios/chrome/browser/ui/commands/open_url_command.h"
106 #import "ios/chrome/browser/ui/commands/show_signin_command.h" 106 #import "ios/chrome/browser/ui/commands/show_signin_command.h"
107 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h" 107 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h"
108 #import "ios/chrome/browser/ui/fullscreen_controller.h" 108 #import "ios/chrome/browser/ui/fullscreen_controller.h"
109 #import "ios/chrome/browser/ui/open_in_controller.h" 109 #import "ios/chrome/browser/ui/open_in_controller.h"
110 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller. h" 110 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller. h"
111 #import "ios/chrome/browser/ui/prerender_delegate.h" 111 #import "ios/chrome/browser/ui/prerender_delegate.h"
112 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h" 112 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h"
113 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h" 113 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h"
114 #import "ios/chrome/browser/ui/sad_tab/sad_tab_view.h" 114 #import "ios/chrome/browser/ui/sad_tab/sad_tab_view.h"
115 #include "ios/chrome/browser/ui/ui_util.h" 115 #include "ios/chrome/browser/ui/ui_util.h"
116 #import "ios/chrome/browser/ui/util/top_view_controller.h"
117 #import "ios/chrome/browser/web/auto_reload_bridge.h" 116 #import "ios/chrome/browser/web/auto_reload_bridge.h"
118 #import "ios/chrome/browser/web/blocked_popup_handler.h" 117 #import "ios/chrome/browser/web/blocked_popup_handler.h"
119 #import "ios/chrome/browser/web/external_app_launcher.h" 118 #import "ios/chrome/browser/web/external_app_launcher.h"
120 #include "ios/chrome/browser/web/network_activity_indicator_tab_helper.h" 119 #include "ios/chrome/browser/web/network_activity_indicator_tab_helper.h"
121 #import "ios/chrome/browser/web/passkit_dialog_provider.h" 120 #import "ios/chrome/browser/web/passkit_dialog_provider.h"
122 #include "ios/chrome/browser/web/print_observer.h" 121 #include "ios/chrome/browser/web/print_observer.h"
123 #import "ios/chrome/browser/xcallback_parameters.h" 122 #import "ios/chrome/browser/xcallback_parameters.h"
124 #include "ios/chrome/grit/ios_strings.h" 123 #include "ios/chrome/grit/ios_strings.h"
125 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 124 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
126 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metad ata.h" 125 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metad ata.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 nativeAppNavigationController_; 289 nativeAppNavigationController_;
291 290
292 // Handles caching and retrieving of snapshots. 291 // Handles caching and retrieving of snapshots.
293 base::scoped_nsobject<SnapshotManager> snapshotManager_; 292 base::scoped_nsobject<SnapshotManager> snapshotManager_;
294 293
295 // Handles retrieving, generating and updating snapshots of CRWWebController's 294 // Handles retrieving, generating and updating snapshots of CRWWebController's
296 // web page. 295 // web page.
297 base::scoped_nsobject<WebControllerSnapshotHelper> 296 base::scoped_nsobject<WebControllerSnapshotHelper>
298 webControllerSnapshotHelper_; 297 webControllerSnapshotHelper_;
299 298
300 // Coordinates Form Resubmission dialog presentation.
301 base::scoped_nsobject<FormResubmissionCoordinator>
302 formResubmissionCoordinator_;
303
304 // Handles support for window.print JavaScript calls. 299 // Handles support for window.print JavaScript calls.
305 std::unique_ptr<PrintObserver> printObserver_; 300 std::unique_ptr<PrintObserver> printObserver_;
306 301
307 // AutoReloadBridge for this tab. 302 // AutoReloadBridge for this tab.
308 base::scoped_nsobject<AutoReloadBridge> autoReloadBridge_; 303 base::scoped_nsobject<AutoReloadBridge> autoReloadBridge_;
309 304
310 // WebStateImpl for this tab. 305 // WebStateImpl for this tab.
311 std::unique_ptr<web::WebStateImpl> webStateImpl_; 306 std::unique_ptr<web::WebStateImpl> webStateImpl_;
312 307
313 // Allows Tab to conform CRWWebStateDelegate protocol. 308 // Allows Tab to conform CRWWebStateDelegate protocol.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 558
564 [self initNativeAppNavigationController]; 559 [self initNativeAppNavigationController];
565 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and 560 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and
566 // other helpers may rely on that. 561 // other helpers may rely on that.
567 IOSChromeSessionTabHelper::CreateForWebState(self.webState); 562 IOSChromeSessionTabHelper::CreateForWebState(self.webState);
568 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, 563 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState,
569 self.tabId); 564 self.tabId);
570 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); 565 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState);
571 InfoBarManagerImpl::CreateForWebState(self.webState); 566 InfoBarManagerImpl::CreateForWebState(self.webState);
572 IOSSecurityStateTabHelper::CreateForWebState(self.webState); 567 IOSSecurityStateTabHelper::CreateForWebState(self.webState);
568 FormResubmissionTabHelper::CreateForWebState(self.webState);
573 569
574 if (reading_list::switches::IsReadingListEnabled()) { 570 if (reading_list::switches::IsReadingListEnabled()) {
575 ReadingListModel* model = 571 ReadingListModel* model =
576 ReadingListModelFactory::GetForBrowserState(browserState_); 572 ReadingListModelFactory::GetForBrowserState(browserState_);
577 ReadingListWebStateObserver::FromWebState(self.webState, model); 573 ReadingListWebStateObserver::FromWebState(self.webState, model);
578 } 574 }
579 575
580 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); 576 tabInfoBarObserver_.reset(new TabInfoBarObserver(self));
581 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); 577 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true);
582 578
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 [self.webController removeObserver:fullScreenController_]; 1230 [self.webController removeObserver:fullScreenController_];
1235 [fullScreenController_ invalidate]; 1231 [fullScreenController_ invalidate];
1236 fullScreenController_.reset(); 1232 fullScreenController_.reset();
1237 if (overscrollActionsController_) 1233 if (overscrollActionsController_)
1238 [self.webController removeObserver:overscrollActionsController_]; 1234 [self.webController removeObserver:overscrollActionsController_];
1239 [overscrollActionsController_ invalidate]; 1235 [overscrollActionsController_ invalidate];
1240 overscrollActionsController_.reset(); 1236 overscrollActionsController_.reset();
1241 [readerModeController_ detachFromWebState]; 1237 [readerModeController_ detachFromWebState];
1242 readerModeController_.reset(); 1238 readerModeController_.reset();
1243 1239
1244 formResubmissionCoordinator_.reset();
1245
1246 // Invalidate any snapshot stored for this session. 1240 // Invalidate any snapshot stored for this session.
1247 NSString* sessionID = [self currentSessionID]; 1241 NSString* sessionID = [self currentSessionID];
1248 DCHECK(sessionID); 1242 DCHECK(sessionID);
1249 [snapshotManager_ removeImageWithSessionID:sessionID]; 1243 [snapshotManager_ removeImageWithSessionID:sessionID];
1250 // Reset association with the webController. 1244 // Reset association with the webController.
1251 [self.webController setDelegate:nil]; 1245 [self.webController setDelegate:nil];
1252 [self.webController setUIDelegate:nil]; 1246 [self.webController setUIDelegate:nil];
1253 1247
1254 webStateImpl_->ClearTransientContentView(); 1248 webStateImpl_->ClearTransientContentView();
1255 // Terminate the network activity before notifying the parent model, because 1249 // Terminate the network activity before notifying the parent model, because
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 openedByDOM:YES 1687 openedByDOM:YES
1694 atIndex:TabModelConstants::kTabPositionAutomatically 1688 atIndex:TabModelConstants::kTabPositionAutomatically
1695 inBackground:NO]; 1689 inBackground:NO];
1696 return tab.webController; 1690 return tab.webController;
1697 } 1691 }
1698 1692
1699 - (void)webController:(CRWWebController*)webController 1693 - (void)webController:(CRWWebController*)webController
1700 onFormResubmissionForRequest:(NSURLRequest*)request 1694 onFormResubmissionForRequest:(NSURLRequest*)request
1701 continueBlock:(ProceduralBlock)continueBlock 1695 continueBlock:(ProceduralBlock)continueBlock
1702 cancelBlock:(ProceduralBlock)cancelBlock { 1696 cancelBlock:(ProceduralBlock)cancelBlock {
1703 UIViewController* topController =
1704 top_view_controller::TopPresentedViewControllerFrom(
1705 [UIApplication sharedApplication].keyWindow.rootViewController);
1706
1707 // Display the action sheet with the arrow pointing at the top center of the 1697 // Display the action sheet with the arrow pointing at the top center of the
1708 // web contents. 1698 // web contents.
1709 CGPoint dialogLocation = 1699 CGPoint dialogLocation =
1710 CGPointMake(CGRectGetMidX(webController.view.frame), 1700 CGPointMake(CGRectGetMidX(webController.view.frame),
1711 CGRectGetMinY(webController.view.frame) + 1701 CGRectGetMinY(webController.view.frame) +
1712 [self.tabHeadersDelegate headerHeightForTab:self]); 1702 [self.tabHeadersDelegate headerHeightForTab:self]);
1713 1703 auto helper = FormResubmissionTabHelper::FromWebState(webController.webState);
1714 formResubmissionCoordinator_.reset([[FormResubmissionCoordinator alloc] 1704 helper->PresentFormResubmissionDialog(dialogLocation,
1715 initWithBaseViewController:topController 1705 base::BindBlock(^(bool shouldContinue) {
1716 dialogLocation:dialogLocation 1706 if (shouldContinue)
1717 webState:webController.webState 1707 continueBlock();
1718 completionHandler:^(BOOL shouldContinue) { 1708 else
1719 if (shouldContinue) 1709 cancelBlock();
1720 continueBlock(); 1710 }));
1721 else
1722 cancelBlock();
1723 }]);
1724 [formResubmissionCoordinator_ start];
1725 } 1711 }
1726 1712
1727 // The web page wants to close its own window. 1713 // The web page wants to close its own window.
1728 - (void)webPageOrderedClose { 1714 - (void)webPageOrderedClose {
1729 // Only allow a web page to close itself if it was opened by DOM, or if there 1715 // Only allow a web page to close itself if it was opened by DOM, or if there
1730 // are no navigation items. 1716 // are no navigation items.
1731 DCHECK([[self navigationManager]->GetSessionController() isOpenedByDOM] || 1717 DCHECK([[self navigationManager]->GetSessionController() isOpenedByDOM] ||
1732 ![self navigationManager]->GetItemCount()); 1718 ![self navigationManager]->GetItemCount());
1733 [self closeThisTab]; 1719 [self closeThisTab];
1734 } 1720 }
1735 1721
1736 // This method is invoked whenever the system believes the URL is about to 1722 // This method is invoked whenever the system believes the URL is about to
1737 // change, or immediately after any unexpected change of the URL. The apparent 1723 // change, or immediately after any unexpected change of the URL. The apparent
1738 // destination URL is included in the |url| parameter. 1724 // destination URL is included in the |url| parameter.
1739 // Warning: because of the present design it is possible for malicious websites 1725 // Warning: because of the present design it is possible for malicious websites
1740 // to invoke superflous instances of this delegate with artibrary URLs. 1726 // to invoke superflous instances of this delegate with artibrary URLs.
1741 // Ensure there is nothing here that could be a risk to the user beyond mild 1727 // Ensure there is nothing here that could be a risk to the user beyond mild
1742 // confusion in that event (e.g. progress bar starting unexpectedly). 1728 // confusion in that event (e.g. progress bar starting unexpectedly).
1743 - (void)webWillAddPendingURL:(const GURL&)url 1729 - (void)webWillAddPendingURL:(const GURL&)url
1744 transition:(ui::PageTransition)transition { 1730 transition:(ui::PageTransition)transition {
1745 DCHECK(self.webController.loadPhase == web::LOAD_REQUESTED); 1731 DCHECK(self.webController.loadPhase == web::LOAD_REQUESTED);
1746 DCHECK([self navigationManager]); 1732 DCHECK([self navigationManager]);
1747 formResubmissionCoordinator_.reset();
1748 1733
1749 // Move the toolbar to visible during page load. 1734 // Move the toolbar to visible during page load.
1750 [fullScreenController_ disableFullScreen]; 1735 [fullScreenController_ disableFullScreen];
1751 1736
1752 isUserNavigationEvent_ = 1737 isUserNavigationEvent_ =
1753 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0; 1738 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0;
1754 // Check for link-follow clobbers. These are changes where there is no 1739 // Check for link-follow clobbers. These are changes where there is no
1755 // pending entry (since that means the change wasn't caused by this class), 1740 // pending entry (since that means the change wasn't caused by this class),
1756 // and where the URL changes (to avoid counting page resurrection). 1741 // and where the URL changes (to avoid counting page resurrection).
1757 // TODO(crbug.com/546401): Consider moving this into NavigationManager, or 1742 // TODO(crbug.com/546401): Consider moving this into NavigationManager, or
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 2360
2376 - (TabModel*)parentTabModel { 2361 - (TabModel*)parentTabModel {
2377 return parentTabModel_; 2362 return parentTabModel_;
2378 } 2363 }
2379 2364
2380 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2365 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2381 return inputAccessoryViewController_.get(); 2366 return inputAccessoryViewController_.get();
2382 } 2367 }
2383 2368
2384 @end 2369 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/web/BUILD.gn » ('j') | ios/chrome/browser/web/form_resubmission_tab_helper.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698