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

Side by Side Diff: ios/chrome/browser/tabs/tab.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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/web/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 [self.webController removeObserver:fullScreenController_]; 1229 [self.webController removeObserver:fullScreenController_];
1235 [fullScreenController_ invalidate]; 1230 [fullScreenController_ invalidate];
1236 fullScreenController_.reset(); 1231 fullScreenController_.reset();
1237 if (overscrollActionsController_) 1232 if (overscrollActionsController_)
1238 [self.webController removeObserver:overscrollActionsController_]; 1233 [self.webController removeObserver:overscrollActionsController_];
1239 [overscrollActionsController_ invalidate]; 1234 [overscrollActionsController_ invalidate];
1240 overscrollActionsController_.reset(); 1235 overscrollActionsController_.reset();
1241 [readerModeController_ detachFromWebState]; 1236 [readerModeController_ detachFromWebState];
1242 readerModeController_.reset(); 1237 readerModeController_.reset();
1243 1238
1244 formResubmissionCoordinator_.reset();
1245
1246 // Invalidate any snapshot stored for this session. 1239 // Invalidate any snapshot stored for this session.
1247 NSString* sessionID = [self currentSessionID]; 1240 NSString* sessionID = [self currentSessionID];
1248 DCHECK(sessionID); 1241 DCHECK(sessionID);
1249 [snapshotManager_ removeImageWithSessionID:sessionID]; 1242 [snapshotManager_ removeImageWithSessionID:sessionID];
1250 // Reset association with the webController. 1243 // Reset association with the webController.
1251 [self.webController setDelegate:nil]; 1244 [self.webController setDelegate:nil];
1252 [self.webController setUIDelegate:nil]; 1245 [self.webController setUIDelegate:nil];
1253 1246
1254 webStateImpl_->ClearTransientContentView(); 1247 webStateImpl_->ClearTransientContentView();
1255 // Terminate the network activity before notifying the parent model, because 1248 // 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 1686 openedByDOM:YES
1694 atIndex:TabModelConstants::kTabPositionAutomatically 1687 atIndex:TabModelConstants::kTabPositionAutomatically
1695 inBackground:NO]; 1688 inBackground:NO];
1696 return tab.webController; 1689 return tab.webController;
1697 } 1690 }
1698 1691
1699 - (void)webController:(CRWWebController*)webController 1692 - (void)webController:(CRWWebController*)webController
1700 onFormResubmissionForRequest:(NSURLRequest*)request 1693 onFormResubmissionForRequest:(NSURLRequest*)request
1701 continueBlock:(ProceduralBlock)continueBlock 1694 continueBlock:(ProceduralBlock)continueBlock
1702 cancelBlock:(ProceduralBlock)cancelBlock { 1695 cancelBlock:(ProceduralBlock)cancelBlock {
1703 UIViewController* topController = 1696 FormResubmissionTabHelper::CreateForWebState(webController.webState);
rohitrao (ping after 24h) 2017/01/17 21:07:31 This should go into initWithWebState, somewhere ar
Eugene But (OOO till 7-30) 2017/01/17 21:25:39 Form resubmission callback will move from Tab to B
rohitrao (ping after 24h) 2017/01/17 21:31:24 I'd like to follow desktop, which has https://cs.c
rohitrao (ping after 24h) 2017/01/17 21:32:49 This object needs to be one-per-WebState, right?
Eugene But (OOO till 7-30) 2017/01/17 21:48:59 I see. This makes total sense. Moved FormResubmiss
1704 top_view_controller::TopPresentedViewControllerFrom(
1705 [UIApplication sharedApplication].keyWindow.rootViewController);
1706 1697
1707 // Display the action sheet with the arrow pointing at the top center of the 1698 // Display the action sheet with the arrow pointing at the top center of the
1708 // web contents. 1699 // web contents.
1709 CGPoint dialogLocation = 1700 CGPoint dialogLocation =
1710 CGPointMake(CGRectGetMidX(webController.view.frame), 1701 CGPointMake(CGRectGetMidX(webController.view.frame),
1711 CGRectGetMinY(webController.view.frame) + 1702 CGRectGetMinY(webController.view.frame) +
1712 [self.tabHeadersDelegate headerHeightForTab:self]); 1703 [self.tabHeadersDelegate headerHeightForTab:self]);
1713 1704 auto helper = FormResubmissionTabHelper::FromWebState(webController.webState);
1714 formResubmissionCoordinator_.reset([[FormResubmissionCoordinator alloc] 1705 helper->PresentFormResubmissionDialog(dialogLocation,
1715 initWithBaseViewController:topController 1706 base::BindBlock(^(bool shouldContinue) {
1716 dialogLocation:dialogLocation 1707 if (shouldContinue)
1717 webState:webController.webState 1708 continueBlock();
1718 completionHandler:^(BOOL shouldContinue) { 1709 else
1719 if (shouldContinue) 1710 cancelBlock();
1720 continueBlock(); 1711 }));
1721 else
1722 cancelBlock();
1723 }]);
1724 [formResubmissionCoordinator_ start];
1725 } 1712 }
1726 1713
1727 // The web page wants to close its own window. 1714 // The web page wants to close its own window.
1728 - (void)webPageOrderedClose { 1715 - (void)webPageOrderedClose {
1729 // Only allow a web page to close itself if it was opened by DOM, or if there 1716 // Only allow a web page to close itself if it was opened by DOM, or if there
1730 // are no navigation items. 1717 // are no navigation items.
1731 DCHECK([[self navigationManager]->GetSessionController() isOpenedByDOM] || 1718 DCHECK([[self navigationManager]->GetSessionController() isOpenedByDOM] ||
1732 ![self navigationManager]->GetItemCount()); 1719 ![self navigationManager]->GetItemCount());
1733 [self closeThisTab]; 1720 [self closeThisTab];
1734 } 1721 }
1735 1722
1736 // This method is invoked whenever the system believes the URL is about to 1723 // 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 1724 // change, or immediately after any unexpected change of the URL. The apparent
1738 // destination URL is included in the |url| parameter. 1725 // destination URL is included in the |url| parameter.
1739 // Warning: because of the present design it is possible for malicious websites 1726 // Warning: because of the present design it is possible for malicious websites
1740 // to invoke superflous instances of this delegate with artibrary URLs. 1727 // 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 1728 // 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). 1729 // confusion in that event (e.g. progress bar starting unexpectedly).
1743 - (void)webWillAddPendingURL:(const GURL&)url 1730 - (void)webWillAddPendingURL:(const GURL&)url
1744 transition:(ui::PageTransition)transition { 1731 transition:(ui::PageTransition)transition {
1745 DCHECK(self.webController.loadPhase == web::LOAD_REQUESTED); 1732 DCHECK(self.webController.loadPhase == web::LOAD_REQUESTED);
1746 DCHECK([self navigationManager]); 1733 DCHECK([self navigationManager]);
1747 formResubmissionCoordinator_.reset();
1748 1734
1749 // Move the toolbar to visible during page load. 1735 // Move the toolbar to visible during page load.
1750 [fullScreenController_ disableFullScreen]; 1736 [fullScreenController_ disableFullScreen];
1751 1737
1752 isUserNavigationEvent_ = 1738 isUserNavigationEvent_ =
1753 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0; 1739 (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0;
1754 // Check for link-follow clobbers. These are changes where there is no 1740 // 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), 1741 // pending entry (since that means the change wasn't caused by this class),
1756 // and where the URL changes (to avoid counting page resurrection). 1742 // and where the URL changes (to avoid counting page resurrection).
1757 // TODO(crbug.com/546401): Consider moving this into NavigationManager, or 1743 // TODO(crbug.com/546401): Consider moving this into NavigationManager, or
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 2361
2376 - (TabModel*)parentTabModel { 2362 - (TabModel*)parentTabModel {
2377 return parentTabModel_; 2363 return parentTabModel_;
2378 } 2364 }
2379 2365
2380 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2366 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2381 return inputAccessoryViewController_.get(); 2367 return inputAccessoryViewController_.get();
2382 } 2368 }
2383 2369
2384 @end 2370 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698