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

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

Issue 2640463002: [ios] Convert BlockedPopupHandler into a tab helper class. (Closed)
Patch Set: Review. 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
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" 116 #import "ios/chrome/browser/ui/util/top_view_controller.h"
117 #import "ios/chrome/browser/web/auto_reload_bridge.h" 117 #import "ios/chrome/browser/web/auto_reload_bridge.h"
118 #import "ios/chrome/browser/web/blocked_popup_handler.h" 118 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h"
119 #import "ios/chrome/browser/web/external_app_launcher.h" 119 #import "ios/chrome/browser/web/external_app_launcher.h"
120 #include "ios/chrome/browser/web/network_activity_indicator_tab_helper.h" 120 #include "ios/chrome/browser/web/network_activity_indicator_tab_helper.h"
121 #import "ios/chrome/browser/web/passkit_dialog_provider.h" 121 #import "ios/chrome/browser/web/passkit_dialog_provider.h"
122 #include "ios/chrome/browser/web/print_observer.h" 122 #include "ios/chrome/browser/web/print_observer.h"
123 #import "ios/chrome/browser/xcallback_parameters.h" 123 #import "ios/chrome/browser/xcallback_parameters.h"
124 #include "ios/chrome/grit/ios_strings.h" 124 #include "ios/chrome/grit/ios_strings.h"
125 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 125 #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" 126 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metad ata.h"
127 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white list_manager.h" 127 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white list_manager.h"
128 #import "ios/web/navigation/crw_session_controller.h" 128 #import "ios/web/navigation/crw_session_controller.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // These two values are for when the app is in the foreground. 193 // These two values are for when the app is in the foreground.
194 FOREGROUND_TAB_FOREGROUND_APP = 0, 194 FOREGROUND_TAB_FOREGROUND_APP = 0,
195 BACKGROUND_TAB_FOREGROUND_APP, 195 BACKGROUND_TAB_FOREGROUND_APP,
196 // These are for when the app is in the background. 196 // These are for when the app is in the background.
197 FOREGROUND_TAB_BACKGROUND_APP, 197 FOREGROUND_TAB_BACKGROUND_APP,
198 BACKGROUND_TAB_BACKGROUND_APP, 198 BACKGROUND_TAB_BACKGROUND_APP,
199 TERMINATION_TAB_STATE_COUNT 199 TERMINATION_TAB_STATE_COUNT
200 }; 200 };
201 } // namespace 201 } // namespace
202 202
203 @interface Tab ()<BlockedPopupHandlerDelegate, 203 @interface Tab ()<CRWWebStateObserver,
204 CRWWebStateObserver,
205 CRWWebUserInterfaceDelegate, 204 CRWWebUserInterfaceDelegate,
206 FindInPageControllerDelegate, 205 FindInPageControllerDelegate,
207 ReaderModeControllerDelegate> { 206 ReaderModeControllerDelegate> {
208 TabModel* parentTabModel_; // weak 207 TabModel* parentTabModel_; // weak
209 ios::ChromeBrowserState* browserState_; // weak 208 ios::ChromeBrowserState* browserState_; // weak
210 209
211 base::scoped_nsobject<OpenInController> openInController_; 210 base::scoped_nsobject<OpenInController> openInController_;
212 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; 211 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_;
213 // TODO(crbug.com/546213): Move this out of Tab, probably to native app 212 // TODO(crbug.com/546213): Move this out of Tab, probably to native app
214 // launcher since that's the only thing that uses it. 213 // launcher since that's the only thing that uses it.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 inputAccessoryViewController_; 271 inputAccessoryViewController_;
273 272
274 // TODO(crbug.com/661665): move the WebContentsObservers into their own 273 // TODO(crbug.com/661665): move the WebContentsObservers into their own
275 // container. 274 // container.
276 // Handles saving and autofill of passwords. 275 // Handles saving and autofill of passwords.
277 base::scoped_nsobject<PasswordController> passwordController_; 276 base::scoped_nsobject<PasswordController> passwordController_;
278 277
279 // Handles autofill. 278 // Handles autofill.
280 base::scoped_nsobject<AutofillController> autofillController_; 279 base::scoped_nsobject<AutofillController> autofillController_;
281 280
282 // The popup blocker to show blocked popup to the user.
283 std::unique_ptr<BlockedPopupHandler> popupHandler_;
284
285 // Handles find on page. 281 // Handles find on page.
286 base::scoped_nsobject<FindInPageController> findInPageController_; 282 base::scoped_nsobject<FindInPageController> findInPageController_;
287 283
288 // Handles GAL infobar on web pages. 284 // Handles GAL infobar on web pages.
289 base::scoped_nsobject<NativeAppNavigationController> 285 base::scoped_nsobject<NativeAppNavigationController>
290 nativeAppNavigationController_; 286 nativeAppNavigationController_;
291 287
292 // Handles caching and retrieving of snapshots. 288 // Handles caching and retrieving of snapshots.
293 base::scoped_nsobject<SnapshotManager> snapshotManager_; 289 base::scoped_nsobject<SnapshotManager> snapshotManager_;
294 290
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // Sets the favicon on the current NavigationItem. 350 // Sets the favicon on the current NavigationItem.
355 - (void)setFavicon:(const gfx::Image*)image; 351 - (void)setFavicon:(const gfx::Image*)image;
356 352
357 // Updates the title field of the current session entry. Also updates the 353 // Updates the title field of the current session entry. Also updates the
358 // history database. 354 // history database.
359 - (void)updateTitle:(NSString*)title; 355 - (void)updateTitle:(NSString*)title;
360 356
361 // Saves the current title to the history database. 357 // Saves the current title to the history database.
362 - (void)saveTitleToHistoryDB; 358 - (void)saveTitleToHistoryDB;
363 359
364 // Returns a lazily instantiated popup handler.
365 - (BlockedPopupHandler*)popupHandler;
366
367 // Adds the current session entry to this history database. 360 // Adds the current session entry to this history database.
368 - (void)addCurrentEntryToHistoryDB; 361 - (void)addCurrentEntryToHistoryDB;
369 362
370 // Adds any cached entries from |addPageVector_| to the history DB. 363 // Adds any cached entries from |addPageVector_| to the history DB.
371 - (void)commitCachedEntriesToHistoryDB; 364 - (void)commitCachedEntriesToHistoryDB;
372 365
373 // Returns the OpenInController for this tab. 366 // Returns the OpenInController for this tab.
374 - (OpenInController*)openInController; 367 - (OpenInController*)openInController;
375 368
376 // Calls the model and ask to close this tab. 369 // Calls the model and ask to close this tab.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 556
564 [self initNativeAppNavigationController]; 557 [self initNativeAppNavigationController];
565 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and 558 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and
566 // other helpers may rely on that. 559 // other helpers may rely on that.
567 IOSChromeSessionTabHelper::CreateForWebState(self.webState); 560 IOSChromeSessionTabHelper::CreateForWebState(self.webState);
568 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, 561 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState,
569 self.tabId); 562 self.tabId);
570 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); 563 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState);
571 InfoBarManagerImpl::CreateForWebState(self.webState); 564 InfoBarManagerImpl::CreateForWebState(self.webState);
572 IOSSecurityStateTabHelper::CreateForWebState(self.webState); 565 IOSSecurityStateTabHelper::CreateForWebState(self.webState);
566 BlockedPopupTabHelper::CreateForWebState(self.webState);
573 567
574 if (reading_list::switches::IsReadingListEnabled()) { 568 if (reading_list::switches::IsReadingListEnabled()) {
575 ReadingListModel* model = 569 ReadingListModel* model =
576 ReadingListModelFactory::GetForBrowserState(browserState_); 570 ReadingListModelFactory::GetForBrowserState(browserState_);
577 ReadingListWebStateObserver::FromWebState(self.webState, model); 571 ReadingListWebStateObserver::FromWebState(self.webState, model);
578 } 572 }
579 573
580 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); 574 tabInfoBarObserver_.reset(new TabInfoBarObserver(self));
581 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); 575 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true);
582 576
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 1627
1634 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { 1628 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider {
1635 return snapshotOverlayProvider_.get(); 1629 return snapshotOverlayProvider_.get();
1636 } 1630 }
1637 1631
1638 - (void)setSnapshotOverlayProvider: 1632 - (void)setSnapshotOverlayProvider:
1639 (id<SnapshotOverlayProvider>)snapshotOverlayProvider { 1633 (id<SnapshotOverlayProvider>)snapshotOverlayProvider {
1640 snapshotOverlayProvider_.reset(snapshotOverlayProvider); 1634 snapshotOverlayProvider_.reset(snapshotOverlayProvider);
1641 } 1635 }
1642 1636
1643 - (BlockedPopupHandler*)popupHandler {
1644 if (!popupHandler_.get()) {
1645 popupHandler_.reset(new BlockedPopupHandler(self.browserState));
1646 popupHandler_->SetDelegate(self);
1647 }
1648 return popupHandler_.get();
1649 }
1650
1651 - (void)evaluateU2FResultFromURL:(const GURL&)URL { 1637 - (void)evaluateU2FResultFromURL:(const GURL&)URL {
1652 DCHECK(U2FController_); 1638 DCHECK(U2FController_);
1653 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; 1639 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState];
1654 } 1640 }
1655 1641
1656 - (NSString*)currentSessionID { 1642 - (NSString*)currentSessionID {
1657 return [self tabId]; 1643 return [self tabId];
1658 } 1644 }
1659 1645
1660 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods. 1646 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods.
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2108 ContentSetting setting = 2094 ContentSetting setting =
2109 ios::HostContentSettingsMapFactory::GetForBrowserState(browserState_) 2095 ios::HostContentSettingsMapFactory::GetForBrowserState(browserState_)
2110 ->GetContentSetting(sourceURL, sourceURL, 2096 ->GetContentSetting(sourceURL, sourceURL,
2111 CONTENT_SETTINGS_TYPE_POPUPS, std::string()); 2097 CONTENT_SETTINGS_TYPE_POPUPS, std::string());
2112 2098
2113 return setting != CONTENT_SETTING_ALLOW; 2099 return setting != CONTENT_SETTING_ALLOW;
2114 } 2100 }
2115 2101
2116 - (void)webController:(CRWWebController*)webController 2102 - (void)webController:(CRWWebController*)webController
2117 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo { 2103 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo {
2118 [self popupHandler]->HandlePopup(blockedPopupInfo); 2104 BlockedPopupTabHelper::FromWebState(self.webState)
2105 ->HandlePopup(blockedPopupInfo);
2119 } 2106 }
2120 2107
2121 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController { 2108 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController {
2122 return [self.tabHeadersDelegate headerHeightForTab:self]; 2109 return [self.tabHeadersDelegate headerHeightForTab:self];
2123 } 2110 }
2124 2111
2125 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: 2112 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem:
2126 (CRWWebController*)webController { 2113 (CRWWebController*)webController {
2127 // Disable fullscreen if SSL cert is invalid. 2114 // Disable fullscreen if SSL cert is invalid.
2128 web::NavigationItem* item = [self navigationManager]->GetTransientItem(); 2115 web::NavigationItem* item = [self navigationManager]->GetTransientItem();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 2362
2376 - (TabModel*)parentTabModel { 2363 - (TabModel*)parentTabModel {
2377 return parentTabModel_; 2364 return parentTabModel_;
2378 } 2365 }
2379 2366
2380 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2367 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2381 return inputAccessoryViewController_.get(); 2368 return inputAccessoryViewController_.get();
2382 } 2369 }
2383 2370
2384 @end 2371 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/web/BUILD.gn » ('j') | ios/chrome/browser/web/blocked_popup_tab_helper.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698