| OLD | NEW |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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/web/auto_reload_bridge.h" | 116 #import "ios/chrome/browser/web/auto_reload_bridge.h" |
| 117 #import "ios/chrome/browser/web/blocked_popup_handler.h" | 117 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h" |
| 118 #import "ios/chrome/browser/web/external_app_launcher.h" | 118 #import "ios/chrome/browser/web/external_app_launcher.h" |
| 119 #include "ios/chrome/browser/web/network_activity_indicator_tab_helper.h" | 119 #include "ios/chrome/browser/web/network_activity_indicator_tab_helper.h" |
| 120 #import "ios/chrome/browser/web/passkit_dialog_provider.h" | 120 #import "ios/chrome/browser/web/passkit_dialog_provider.h" |
| 121 #include "ios/chrome/browser/web/print_observer.h" | 121 #include "ios/chrome/browser/web/print_observer.h" |
| 122 #import "ios/chrome/browser/xcallback_parameters.h" | 122 #import "ios/chrome/browser/xcallback_parameters.h" |
| 123 #include "ios/chrome/grit/ios_strings.h" | 123 #include "ios/chrome/grit/ios_strings.h" |
| 124 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 124 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 125 #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" |
| 126 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white
list_manager.h" | 126 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white
list_manager.h" |
| 127 #import "ios/web/navigation/crw_session_controller.h" | 127 #import "ios/web/navigation/crw_session_controller.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // These two values are for when the app is in the foreground. | 192 // These two values are for when the app is in the foreground. |
| 193 FOREGROUND_TAB_FOREGROUND_APP = 0, | 193 FOREGROUND_TAB_FOREGROUND_APP = 0, |
| 194 BACKGROUND_TAB_FOREGROUND_APP, | 194 BACKGROUND_TAB_FOREGROUND_APP, |
| 195 // These are for when the app is in the background. | 195 // These are for when the app is in the background. |
| 196 FOREGROUND_TAB_BACKGROUND_APP, | 196 FOREGROUND_TAB_BACKGROUND_APP, |
| 197 BACKGROUND_TAB_BACKGROUND_APP, | 197 BACKGROUND_TAB_BACKGROUND_APP, |
| 198 TERMINATION_TAB_STATE_COUNT | 198 TERMINATION_TAB_STATE_COUNT |
| 199 }; | 199 }; |
| 200 } // namespace | 200 } // namespace |
| 201 | 201 |
| 202 @interface Tab ()<BlockedPopupHandlerDelegate, | 202 @interface Tab ()<CRWWebStateObserver, |
| 203 CRWWebStateObserver, | |
| 204 CRWWebUserInterfaceDelegate, | 203 CRWWebUserInterfaceDelegate, |
| 205 FindInPageControllerDelegate, | 204 FindInPageControllerDelegate, |
| 206 ReaderModeControllerDelegate> { | 205 ReaderModeControllerDelegate> { |
| 207 TabModel* parentTabModel_; // weak | 206 TabModel* parentTabModel_; // weak |
| 208 ios::ChromeBrowserState* browserState_; // weak | 207 ios::ChromeBrowserState* browserState_; // weak |
| 209 | 208 |
| 210 base::scoped_nsobject<OpenInController> openInController_; | 209 base::scoped_nsobject<OpenInController> openInController_; |
| 211 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; | 210 base::WeakNSProtocol<id<PassKitDialogProvider>> passKitDialogProvider_; |
| 212 // TODO(crbug.com/546213): Move this out of Tab, probably to native app | 211 // TODO(crbug.com/546213): Move this out of Tab, probably to native app |
| 213 // launcher since that's the only thing that uses it. | 212 // launcher since that's the only thing that uses it. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 inputAccessoryViewController_; | 270 inputAccessoryViewController_; |
| 272 | 271 |
| 273 // TODO(crbug.com/661665): move the WebContentsObservers into their own | 272 // TODO(crbug.com/661665): move the WebContentsObservers into their own |
| 274 // container. | 273 // container. |
| 275 // Handles saving and autofill of passwords. | 274 // Handles saving and autofill of passwords. |
| 276 base::scoped_nsobject<PasswordController> passwordController_; | 275 base::scoped_nsobject<PasswordController> passwordController_; |
| 277 | 276 |
| 278 // Handles autofill. | 277 // Handles autofill. |
| 279 base::scoped_nsobject<AutofillController> autofillController_; | 278 base::scoped_nsobject<AutofillController> autofillController_; |
| 280 | 279 |
| 281 // The popup blocker to show blocked popup to the user. | |
| 282 std::unique_ptr<BlockedPopupHandler> popupHandler_; | |
| 283 | |
| 284 // Handles find on page. | 280 // Handles find on page. |
| 285 base::scoped_nsobject<FindInPageController> findInPageController_; | 281 base::scoped_nsobject<FindInPageController> findInPageController_; |
| 286 | 282 |
| 287 // Handles GAL infobar on web pages. | 283 // Handles GAL infobar on web pages. |
| 288 base::scoped_nsobject<NativeAppNavigationController> | 284 base::scoped_nsobject<NativeAppNavigationController> |
| 289 nativeAppNavigationController_; | 285 nativeAppNavigationController_; |
| 290 | 286 |
| 291 // Handles caching and retrieving of snapshots. | 287 // Handles caching and retrieving of snapshots. |
| 292 base::scoped_nsobject<SnapshotManager> snapshotManager_; | 288 base::scoped_nsobject<SnapshotManager> snapshotManager_; |
| 293 | 289 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // Sets the favicon on the current NavigationItem. | 345 // Sets the favicon on the current NavigationItem. |
| 350 - (void)setFavicon:(const gfx::Image*)image; | 346 - (void)setFavicon:(const gfx::Image*)image; |
| 351 | 347 |
| 352 // Updates the title field of the current session entry. Also updates the | 348 // Updates the title field of the current session entry. Also updates the |
| 353 // history database. | 349 // history database. |
| 354 - (void)updateTitle:(NSString*)title; | 350 - (void)updateTitle:(NSString*)title; |
| 355 | 351 |
| 356 // Saves the current title to the history database. | 352 // Saves the current title to the history database. |
| 357 - (void)saveTitleToHistoryDB; | 353 - (void)saveTitleToHistoryDB; |
| 358 | 354 |
| 359 // Returns a lazily instantiated popup handler. | |
| 360 - (BlockedPopupHandler*)popupHandler; | |
| 361 | |
| 362 // Adds the current session entry to this history database. | 355 // Adds the current session entry to this history database. |
| 363 - (void)addCurrentEntryToHistoryDB; | 356 - (void)addCurrentEntryToHistoryDB; |
| 364 | 357 |
| 365 // Adds any cached entries from |addPageVector_| to the history DB. | 358 // Adds any cached entries from |addPageVector_| to the history DB. |
| 366 - (void)commitCachedEntriesToHistoryDB; | 359 - (void)commitCachedEntriesToHistoryDB; |
| 367 | 360 |
| 368 // Returns the OpenInController for this tab. | 361 // Returns the OpenInController for this tab. |
| 369 - (OpenInController*)openInController; | 362 - (OpenInController*)openInController; |
| 370 | 363 |
| 371 // Calls the model and ask to close this tab. | 364 // Calls the model and ask to close this tab. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 tab:self]); | 546 tab:self]); |
| 554 | 547 |
| 555 findInPageController_.reset([[FindInPageController alloc] | 548 findInPageController_.reset([[FindInPageController alloc] |
| 556 initWithWebState:self.webState | 549 initWithWebState:self.webState |
| 557 delegate:self]); | 550 delegate:self]); |
| 558 | 551 |
| 559 [self initNativeAppNavigationController]; | 552 [self initNativeAppNavigationController]; |
| 560 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and | 553 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and |
| 561 // other helpers may rely on that. | 554 // other helpers may rely on that. |
| 562 IOSChromeSessionTabHelper::CreateForWebState(self.webState); | 555 IOSChromeSessionTabHelper::CreateForWebState(self.webState); |
| 556 |
| 563 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, | 557 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, |
| 564 self.tabId); | 558 self.tabId); |
| 565 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); | 559 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); |
| 566 InfoBarManagerImpl::CreateForWebState(self.webState); | 560 InfoBarManagerImpl::CreateForWebState(self.webState); |
| 567 IOSSecurityStateTabHelper::CreateForWebState(self.webState); | 561 IOSSecurityStateTabHelper::CreateForWebState(self.webState); |
| 568 FormResubmissionTabHelper::CreateForWebState(self.webState); | 562 FormResubmissionTabHelper::CreateForWebState(self.webState); |
| 563 BlockedPopupTabHelper::CreateForWebState(self.webState); |
| 569 | 564 |
| 570 if (reading_list::switches::IsReadingListEnabled()) { | 565 if (reading_list::switches::IsReadingListEnabled()) { |
| 571 ReadingListModel* model = | 566 ReadingListModel* model = |
| 572 ReadingListModelFactory::GetForBrowserState(browserState_); | 567 ReadingListModelFactory::GetForBrowserState(browserState_); |
| 573 ReadingListWebStateObserver::FromWebState(self.webState, model); | 568 ReadingListWebStateObserver::FromWebState(self.webState, model); |
| 574 } | 569 } |
| 575 | 570 |
| 576 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); | 571 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); |
| 577 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); | 572 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); |
| 578 | 573 |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 | 1607 |
| 1613 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { | 1608 - (id<SnapshotOverlayProvider>)snapshotOverlayProvider { |
| 1614 return snapshotOverlayProvider_.get(); | 1609 return snapshotOverlayProvider_.get(); |
| 1615 } | 1610 } |
| 1616 | 1611 |
| 1617 - (void)setSnapshotOverlayProvider: | 1612 - (void)setSnapshotOverlayProvider: |
| 1618 (id<SnapshotOverlayProvider>)snapshotOverlayProvider { | 1613 (id<SnapshotOverlayProvider>)snapshotOverlayProvider { |
| 1619 snapshotOverlayProvider_.reset(snapshotOverlayProvider); | 1614 snapshotOverlayProvider_.reset(snapshotOverlayProvider); |
| 1620 } | 1615 } |
| 1621 | 1616 |
| 1622 - (BlockedPopupHandler*)popupHandler { | |
| 1623 if (!popupHandler_.get()) { | |
| 1624 popupHandler_.reset(new BlockedPopupHandler(self.browserState)); | |
| 1625 popupHandler_->SetDelegate(self); | |
| 1626 } | |
| 1627 return popupHandler_.get(); | |
| 1628 } | |
| 1629 | |
| 1630 - (void)evaluateU2FResultFromURL:(const GURL&)URL { | 1617 - (void)evaluateU2FResultFromURL:(const GURL&)URL { |
| 1631 DCHECK(U2FController_); | 1618 DCHECK(U2FController_); |
| 1632 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; | 1619 [U2FController_ evaluateU2FResultFromU2FURL:URL webState:self.webState]; |
| 1633 } | 1620 } |
| 1634 | 1621 |
| 1635 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods. | 1622 #pragma mark - CRWWebDelegate and CRWWebStateObserver protocol methods. |
| 1636 | 1623 |
| 1637 - (CRWWebController*)webPageOrderedOpen:(const GURL&)URL | 1624 - (CRWWebController*)webPageOrderedOpen:(const GURL&)URL |
| 1638 referrer:(const web::Referrer&)referrer | 1625 referrer:(const web::Referrer&)referrer |
| 1639 windowName:(NSString*)windowName | 1626 windowName:(NSString*)windowName |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 ContentSetting setting = | 2056 ContentSetting setting = |
| 2070 ios::HostContentSettingsMapFactory::GetForBrowserState(browserState_) | 2057 ios::HostContentSettingsMapFactory::GetForBrowserState(browserState_) |
| 2071 ->GetContentSetting(sourceURL, sourceURL, | 2058 ->GetContentSetting(sourceURL, sourceURL, |
| 2072 CONTENT_SETTINGS_TYPE_POPUPS, std::string()); | 2059 CONTENT_SETTINGS_TYPE_POPUPS, std::string()); |
| 2073 | 2060 |
| 2074 return setting != CONTENT_SETTING_ALLOW; | 2061 return setting != CONTENT_SETTING_ALLOW; |
| 2075 } | 2062 } |
| 2076 | 2063 |
| 2077 - (void)webController:(CRWWebController*)webController | 2064 - (void)webController:(CRWWebController*)webController |
| 2078 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo { | 2065 didBlockPopup:(const web::BlockedPopupInfo&)blockedPopupInfo { |
| 2079 [self popupHandler]->HandlePopup(blockedPopupInfo); | 2066 BlockedPopupTabHelper::FromWebState(self.webState) |
| 2067 ->HandlePopup(blockedPopupInfo); |
| 2080 } | 2068 } |
| 2081 | 2069 |
| 2082 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController { | 2070 - (CGFloat)headerHeightForWebController:(CRWWebController*)webController { |
| 2083 return [self.tabHeadersDelegate headerHeightForTab:self]; | 2071 return [self.tabHeadersDelegate headerHeightForTab:self]; |
| 2084 } | 2072 } |
| 2085 | 2073 |
| 2086 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: | 2074 - (void)webControllerDidUpdateSSLStatusForCurrentNavigationItem: |
| 2087 (CRWWebController*)webController { | 2075 (CRWWebController*)webController { |
| 2088 // Disable fullscreen if SSL cert is invalid. | 2076 // Disable fullscreen if SSL cert is invalid. |
| 2089 web::NavigationItem* item = [self navigationManager]->GetTransientItem(); | 2077 web::NavigationItem* item = [self navigationManager]->GetTransientItem(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 | 2309 |
| 2322 - (TabModel*)parentTabModel { | 2310 - (TabModel*)parentTabModel { |
| 2323 return parentTabModel_; | 2311 return parentTabModel_; |
| 2324 } | 2312 } |
| 2325 | 2313 |
| 2326 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2314 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2327 return inputAccessoryViewController_.get(); | 2315 return inputAccessoryViewController_.get(); |
| 2328 } | 2316 } |
| 2329 | 2317 |
| 2330 @end | 2318 @end |
| OLD | NEW |