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

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

Issue 2640463002: [ios] Convert BlockedPopupHandler into a tab helper class. (Closed)
Patch Set: 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // These two values are for when the app is in the foreground. 195 // These two values are for when the app is in the foreground.
196 FOREGROUND_TAB_FOREGROUND_APP = 0, 196 FOREGROUND_TAB_FOREGROUND_APP = 0,
197 BACKGROUND_TAB_FOREGROUND_APP, 197 BACKGROUND_TAB_FOREGROUND_APP,
198 // These are for when the app is in the background. 198 // These are for when the app is in the background.
199 FOREGROUND_TAB_BACKGROUND_APP, 199 FOREGROUND_TAB_BACKGROUND_APP,
200 BACKGROUND_TAB_BACKGROUND_APP, 200 BACKGROUND_TAB_BACKGROUND_APP,
201 TERMINATION_TAB_STATE_COUNT 201 TERMINATION_TAB_STATE_COUNT
202 }; 202 };
203 } // namespace 203 } // namespace
204 204
205 @interface Tab ()<BlockedPopupHandlerDelegate, 205 @interface Tab ()<CRWWebStateObserver,
206 CRWWebStateObserver,
207 CRWWebUserInterfaceDelegate, 206 CRWWebUserInterfaceDelegate,
208 FindInPageControllerDelegate, 207 FindInPageControllerDelegate,
209 ReaderModeControllerDelegate> { 208 ReaderModeControllerDelegate> {
210 TabModel* parentTabModel_; // weak 209 TabModel* parentTabModel_; // weak
211 ios::ChromeBrowserState* browserState_; // weak 210 ios::ChromeBrowserState* browserState_; // weak
212 211
213 base::scoped_nsobject<OpenInController> openInController_; 212 base::scoped_nsobject<OpenInController> openInController_;
214 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; 213 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_;
215 // TODO(crbug.com/546213): Move this out of Tab, probably to native app 214 // TODO(crbug.com/546213): Move this out of Tab, probably to native app
216 // launcher since that's the only thing that uses it. 215 // launcher since that's the only thing that uses it.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 inputAccessoryViewController_; 273 inputAccessoryViewController_;
275 274
276 // TODO(crbug.com/661665): move the WebContentsObservers into their own 275 // TODO(crbug.com/661665): move the WebContentsObservers into their own
277 // container. 276 // container.
278 // Handles saving and autofill of passwords. 277 // Handles saving and autofill of passwords.
279 base::scoped_nsobject<PasswordController> passwordController_; 278 base::scoped_nsobject<PasswordController> passwordController_;
280 279
281 // Handles autofill. 280 // Handles autofill.
282 base::scoped_nsobject<AutofillController> autofillController_; 281 base::scoped_nsobject<AutofillController> autofillController_;
283 282
284 // The popup blocker to show blocked popup to the user.
285 std::unique_ptr<BlockedPopupHandler> popupHandler_;
286
287 // Handles find on page. 283 // Handles find on page.
288 base::scoped_nsobject<FindInPageController> findInPageController_; 284 base::scoped_nsobject<FindInPageController> findInPageController_;
289 285
290 // Handles GAL infobar on web pages. 286 // Handles GAL infobar on web pages.
291 base::scoped_nsobject<NativeAppNavigationController> 287 base::scoped_nsobject<NativeAppNavigationController>
292 nativeAppNavigationController_; 288 nativeAppNavigationController_;
293 289
294 // Handles caching and retrieving of snapshots. 290 // Handles caching and retrieving of snapshots.
295 base::scoped_nsobject<SnapshotManager> snapshotManager_; 291 base::scoped_nsobject<SnapshotManager> snapshotManager_;
296 292
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // Sets the favicon on the current NavigationItem. 356 // Sets the favicon on the current NavigationItem.
361 - (void)setFavicon:(const gfx::Image*)image; 357 - (void)setFavicon:(const gfx::Image*)image;
362 358
363 // Updates the title field of the current session entry. Also updates the 359 // Updates the title field of the current session entry. Also updates the
364 // history database. 360 // history database.
365 - (void)updateTitle:(NSString*)title; 361 - (void)updateTitle:(NSString*)title;
366 362
367 // Saves the current title to the history database. 363 // Saves the current title to the history database.
368 - (void)saveTitleToHistoryDB; 364 - (void)saveTitleToHistoryDB;
369 365
370 // Returns a lazily instantiated popup handler.
371 - (BlockedPopupHandler*)popupHandler;
372
373 // Adds the current session entry to this history database. 366 // Adds the current session entry to this history database.
374 - (void)addCurrentEntryToHistoryDB; 367 - (void)addCurrentEntryToHistoryDB;
375 368
376 // Adds any cached entries from |addPageVector_| to the history DB. 369 // Adds any cached entries from |addPageVector_| to the history DB.
377 - (void)commitCachedEntriesToHistoryDB; 370 - (void)commitCachedEntriesToHistoryDB;
378 371
379 // Returns the OpenInController for this tab. 372 // Returns the OpenInController for this tab.
380 - (OpenInController*)openInController; 373 - (OpenInController*)openInController;
381 374
382 // Calls the model and ask to close this tab. 375 // Calls the model and ask to close this tab.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 initWithSnapshotManager:snapshotManager_ 566 initWithSnapshotManager:snapshotManager_
574 tab:self]); 567 tab:self]);
575 568
576 findInPageController_.reset([[FindInPageController alloc] 569 findInPageController_.reset([[FindInPageController alloc]
577 initWithWebState:self.webState 570 initWithWebState:self.webState
578 delegate:self]); 571 delegate:self]);
579 572
580 [self initNativeAppNavigationController]; 573 [self initNativeAppNavigationController];
581 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and 574 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and
582 // other helpers may rely on that. 575 // other helpers may rely on that.
576 BlockedPopupHandler::CreateForWebState(self.webState);
583 IOSChromeSessionTabHelper::CreateForWebState(self.webState); 577 IOSChromeSessionTabHelper::CreateForWebState(self.webState);
584 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, 578 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState,
585 self.tabId); 579 self.tabId);
586 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); 580 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState);
587 InfoBarManagerImpl::CreateForWebState(self.webState); 581 InfoBarManagerImpl::CreateForWebState(self.webState);
588 IOSSecurityStateTabHelper::CreateForWebState(self.webState); 582 IOSSecurityStateTabHelper::CreateForWebState(self.webState);
589 583
590 if (reading_list::switches::IsReadingListEnabled()) { 584 if (reading_list::switches::IsReadingListEnabled()) {
591 ReadingListModel* model = 585 ReadingListModel* model =
592 ReadingListModelFactory::GetForBrowserState(browserState_); 586 ReadingListModelFactory::GetForBrowserState(browserState_);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 // WebState changes. 658 // WebState changes.
665 if (experimental_flags::IsReaderModeEnabled()) { 659 if (experimental_flags::IsReaderModeEnabled()) {
666 readerModeController_.reset([[ReaderModeController alloc] 660 readerModeController_.reset([[ReaderModeController alloc]
667 initWithWebState:self.webState 661 initWithWebState:self.webState
668 delegate:self]); 662 delegate:self]);
669 } 663 }
670 664
671 // Allow the embedder to attach tab helpers. 665 // Allow the embedder to attach tab helpers.
672 ios::GetChromeBrowserProvider()->AttachTabHelpers(self.webState, self); 666 ios::GetChromeBrowserProvider()->AttachTabHelpers(self.webState, self);
673 667
668 // Allow tab helpers to initialize themselves, if necessary.
669 BlockedPopupHandler::FromWebState(self.webState)->Initialize();
670
674 [[NSNotificationCenter defaultCenter] 671 [[NSNotificationCenter defaultCenter]
675 addObserver:self 672 addObserver:self
676 selector:@selector(applicationDidBecomeActive) 673 selector:@selector(applicationDidBecomeActive)
677 name:UIApplicationDidBecomeActiveNotification 674 name:UIApplicationDidBecomeActiveNotification
678 object:nil]; 675 object:nil];
679 } 676 }
680 return self; 677 return self;
681 } 678 }
682 679
683 - (instancetype)init { 680 - (instancetype)init {
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 1651
1655 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { 1652 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider {
1656 return snapshotOverlayProvider_.get(); 1653 return snapshotOverlayProvider_.get();
1657 } 1654 }
1658 1655
1659 - (void)setSnapshotOverlayProvider: 1656 - (void)setSnapshotOverlayProvider:
1660 (id<SnapshotOverlayProvider>)snapshotOverlayProvider { 1657 (id<SnapshotOverlayProvider>)snapshotOverlayProvider {
1661 snapshotOverlayProvider_.reset(snapshotOverlayProvider); 1658 snapshotOverlayProvider_.reset(snapshotOverlayProvider);
1662 } 1659 }
1663 1660
1664 - (BlockedPopupHandler*)popupHandler {
1665 if (!popupHandler_.get()) {
1666 popupHandler_.reset(new BlockedPopupHandler(self.browserState));
1667 popupHandler_->SetDelegate(self);
1668 }
1669 return popupHandler_.get();
1670 }
1671
1672 - (void)evaluateU2FResultFromURL:(const GURL&)URL { 1661 - (void)evaluateU2FResultFromURL:(const GURL&)URL {
1673 DCHECK(U2FController_); 1662 DCHECK(U2FController_);
1674 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; 1663 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState];
1675 } 1664 }
1676 1665
1677 - (NSString*)currentSessionID { 1666 - (NSString*)currentSessionID {
1678 return [self tabId]; 1667 return [self tabId];
1679 } 1668 }
1680 1669
1681 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods. 1670 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods.
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 ContentSetting setting = 2120 ContentSetting setting =
2132 ios::HostContentSettingsMapFactory::GetForBrowserState(browserState_) 2121 ios::HostContentSettingsMapFactory::GetForBrowserState(browserState_)
2133 ->GetContentSetting(sourceURL, sourceURL, 2122 ->GetContentSetting(sourceURL, sourceURL,
2134 CONTENT_SETTINGS_TYPE_POPUPS, std::string()); 2123 CONTENT_SETTINGS_TYPE_POPUPS, std::string());
2135 2124
2136 return setting != CONTENT_SETTING_ALLOW; 2125 return setting != CONTENT_SETTING_ALLOW;
2137 } 2126 }
2138 2127
2139 - (void)webController:(CRWWebController*)webController 2128 - (void)webController:(CRWWebController*)webController
2140 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo { 2129 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo {
2141 [self popupHandler]->HandlePopup(blockedPopupInfo); 2130 BlockedPopupHandler::FromWebState(self.webState)
2131 ->HandlePopup(blockedPopupInfo);
2142 } 2132 }
2143 2133
2144 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController { 2134 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController {
2145 return [self.tabHeadersDelegate headerHeightForTab:self]; 2135 return [self.tabHeadersDelegate headerHeightForTab:self];
2146 } 2136 }
2147 2137
2148 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: 2138 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem:
2149 (CRWWebController*)webController { 2139 (CRWWebController*)webController {
2150 // Disable fullscreen if SSL cert is invalid. 2140 // Disable fullscreen if SSL cert is invalid.
2151 web::NavigationItem* item = [self navigationManager]->GetTransientItem(); 2141 web::NavigationItem* item = [self navigationManager]->GetTransientItem();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2398 2388
2399 - (TabModel*)parentTabModel { 2389 - (TabModel*)parentTabModel {
2400 return parentTabModel_; 2390 return parentTabModel_;
2401 } 2391 }
2402 2392
2403 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2393 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2404 return inputAccessoryViewController_.get(); 2394 return inputAccessoryViewController_.get();
2405 } 2395 }
2406 2396
2407 @end 2397 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/web/blocked_popup_handler.h » ('j') | ios/chrome/browser/web/blocked_popup_handler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698