| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" | 56 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" |
| 57 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" | 57 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" |
| 58 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 58 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
| 59 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 59 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 60 #include "ios/chrome/browser/chrome_url_constants.h" | 60 #include "ios/chrome/browser/chrome_url_constants.h" |
| 61 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" | 61 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" |
| 62 #import "ios/chrome/browser/crash_loop_detection_util.h" | 62 #import "ios/chrome/browser/crash_loop_detection_util.h" |
| 63 #include "ios/chrome/browser/experimental_flags.h" | 63 #include "ios/chrome/browser/experimental_flags.h" |
| 64 #include "ios/chrome/browser/favicon/favicon_service_factory.h" | 64 #include "ios/chrome/browser/favicon/favicon_service_factory.h" |
| 65 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" | 65 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" |
| 66 #import "ios/chrome/browser/find_in_page/find_tab_helper.h" |
| 66 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" | 67 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" |
| 67 #include "ios/chrome/browser/history/history_service_factory.h" | 68 #include "ios/chrome/browser/history/history_service_factory.h" |
| 68 #include "ios/chrome/browser/history/top_sites_factory.h" | 69 #include "ios/chrome/browser/history/top_sites_factory.h" |
| 69 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 70 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
| 70 #include "ios/chrome/browser/metrics/ios_chrome_origins_seen_service_factory.h" | 71 #include "ios/chrome/browser/metrics/ios_chrome_origins_seen_service_factory.h" |
| 71 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" | 72 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" |
| 72 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller
.h" | 73 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller
.h" |
| 73 #import "ios/chrome/browser/passwords/password_controller.h" | 74 #import "ios/chrome/browser/passwords/password_controller.h" |
| 74 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h" | 75 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h" |
| 75 #include "ios/chrome/browser/pref_names.h" | 76 #include "ios/chrome/browser/pref_names.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 inputAccessoryViewController_; | 267 inputAccessoryViewController_; |
| 267 | 268 |
| 268 // TODO(crbug.com/661665): move the WebContentsObservers into their own | 269 // TODO(crbug.com/661665): move the WebContentsObservers into their own |
| 269 // container. | 270 // container. |
| 270 // Handles saving and autofill of passwords. | 271 // Handles saving and autofill of passwords. |
| 271 base::scoped_nsobject<PasswordController> passwordController_; | 272 base::scoped_nsobject<PasswordController> passwordController_; |
| 272 | 273 |
| 273 // Handles autofill. | 274 // Handles autofill. |
| 274 base::scoped_nsobject<AutofillController> autofillController_; | 275 base::scoped_nsobject<AutofillController> autofillController_; |
| 275 | 276 |
| 276 // Handles find on page. | |
| 277 base::scoped_nsobject<FindInPageController> findInPageController_; | |
| 278 | |
| 279 // Handles GAL infobar on web pages. | 277 // Handles GAL infobar on web pages. |
| 280 base::scoped_nsobject<NativeAppNavigationController> | 278 base::scoped_nsobject<NativeAppNavigationController> |
| 281 nativeAppNavigationController_; | 279 nativeAppNavigationController_; |
| 282 | 280 |
| 283 // Handles caching and retrieving of snapshots. | 281 // Handles caching and retrieving of snapshots. |
| 284 base::scoped_nsobject<SnapshotManager> snapshotManager_; | 282 base::scoped_nsobject<SnapshotManager> snapshotManager_; |
| 285 | 283 |
| 286 // Handles retrieving, generating and updating snapshots of CRWWebController's | 284 // Handles retrieving, generating and updating snapshots of CRWWebController's |
| 287 // web page. | 285 // web page. |
| 288 base::scoped_nsobject<WebControllerSnapshotHelper> | 286 base::scoped_nsobject<WebControllerSnapshotHelper> |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 [self.webController setDelegate:self]; | 528 [self.webController setDelegate:self]; |
| 531 | 529 |
| 532 NSString* sessionID = self.tabId; | 530 NSString* sessionID = self.tabId; |
| 533 DCHECK(sessionID); | 531 DCHECK(sessionID); |
| 534 snapshotManager_.reset([[SnapshotManager alloc] init]); | 532 snapshotManager_.reset([[SnapshotManager alloc] init]); |
| 535 | 533 |
| 536 webControllerSnapshotHelper_.reset([[WebControllerSnapshotHelper alloc] | 534 webControllerSnapshotHelper_.reset([[WebControllerSnapshotHelper alloc] |
| 537 initWithSnapshotManager:snapshotManager_ | 535 initWithSnapshotManager:snapshotManager_ |
| 538 tab:self]); | 536 tab:self]); |
| 539 | 537 |
| 540 findInPageController_.reset([[FindInPageController alloc] | |
| 541 initWithWebState:self.webState | |
| 542 delegate:self]); | |
| 543 | |
| 544 [self initNativeAppNavigationController]; | 538 [self initNativeAppNavigationController]; |
| 545 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and | 539 // IOSChromeSessionTabHelper comes first because it sets up the tab ID, and |
| 546 // other helpers may rely on that. | 540 // other helpers may rely on that. |
| 547 IOSChromeSessionTabHelper::CreateForWebState(self.webState); | 541 IOSChromeSessionTabHelper::CreateForWebState(self.webState); |
| 548 | 542 |
| 549 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, | 543 NetworkActivityIndicatorTabHelper::CreateForWebState(self.webState, |
| 550 self.tabId); | 544 self.tabId); |
| 551 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); | 545 IOSChromeSyncedTabDelegate::CreateForWebState(self.webState); |
| 552 InfoBarManagerImpl::CreateForWebState(self.webState); | 546 InfoBarManagerImpl::CreateForWebState(self.webState); |
| 553 IOSSecurityStateTabHelper::CreateForWebState(self.webState); | 547 IOSSecurityStateTabHelper::CreateForWebState(self.webState); |
| 554 RepostFormTabHelper::CreateForWebState(self.webState); | 548 RepostFormTabHelper::CreateForWebState(self.webState); |
| 555 BlockedPopupTabHelper::CreateForWebState(self.webState); | 549 BlockedPopupTabHelper::CreateForWebState(self.webState); |
| 550 FindTabHelper::CreateForWebState(self.webState, self); |
| 556 | 551 |
| 557 if (reading_list::switches::IsReadingListEnabled()) { | 552 if (reading_list::switches::IsReadingListEnabled()) { |
| 558 ReadingListModel* model = | 553 ReadingListModel* model = |
| 559 ReadingListModelFactory::GetForBrowserState(browserState_); | 554 ReadingListModelFactory::GetForBrowserState(browserState_); |
| 560 ReadingListWebStateObserver::FromWebState(self.webState, model); | 555 ReadingListWebStateObserver::FromWebState(self.webState, model); |
| 561 } | 556 } |
| 562 | 557 |
| 563 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); | 558 tabInfoBarObserver_.reset(new TabInfoBarObserver(self)); |
| 564 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); | 559 tabInfoBarObserver_->SetShouldObserveInfoBarManager(true); |
| 565 | 560 |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 // random time. | 1169 // random time. |
| 1175 - (void)close { | 1170 - (void)close { |
| 1176 self.fullScreenControllerDelegate = nil; | 1171 self.fullScreenControllerDelegate = nil; |
| 1177 self.overscrollActionsControllerDelegate = nil; | 1172 self.overscrollActionsControllerDelegate = nil; |
| 1178 self.passKitDialogProvider = nil; | 1173 self.passKitDialogProvider = nil; |
| 1179 self.snapshotOverlayProvider = nil; | 1174 self.snapshotOverlayProvider = nil; |
| 1180 self.storeKitLauncher = nil; | 1175 self.storeKitLauncher = nil; |
| 1181 | 1176 |
| 1182 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 1177 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 1183 | 1178 |
| 1184 [findInPageController_ detachFromWebState]; | |
| 1185 findInPageController_.reset(); | |
| 1186 | |
| 1187 [passwordController_ detach]; | 1179 [passwordController_ detach]; |
| 1188 passwordController_.reset(); | 1180 passwordController_.reset(); |
| 1189 tabInfoBarObserver_.reset(); | 1181 tabInfoBarObserver_.reset(); |
| 1190 | 1182 |
| 1191 faviconDriverObserverBridge_.reset(); | 1183 faviconDriverObserverBridge_.reset(); |
| 1192 [openInController_ detachFromWebController]; | 1184 [openInController_ detachFromWebController]; |
| 1193 openInController_.reset(); | 1185 openInController_.reset(); |
| 1194 [autofillController_ detachFromWebState]; | 1186 [autofillController_ detachFromWebState]; |
| 1195 [suggestionController_ detachFromWebState]; | 1187 [suggestionController_ detachFromWebState]; |
| 1196 if (fullScreenController_) | 1188 if (fullScreenController_) |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 [parentTabModel_ notifyTabChanged:self]; | 1671 [parentTabModel_ notifyTabChanged:self]; |
| 1680 } | 1672 } |
| 1681 | 1673 |
| 1682 - (void)webState:(web::WebState*)webState | 1674 - (void)webState:(web::WebState*)webState |
| 1683 didCommitNavigationWithDetails:(const web::LoadCommittedDetails&)details { | 1675 didCommitNavigationWithDetails:(const web::LoadCommittedDetails&)details { |
| 1684 DCHECK([self navigationManager]); | 1676 DCHECK([self navigationManager]); |
| 1685 // |webWillAddPendingURL:transition:| is not called for native page loads. | 1677 // |webWillAddPendingURL:transition:| is not called for native page loads. |
| 1686 // TODO(crbug.com/381201): Move this call there once that bug is fixed so that | 1678 // TODO(crbug.com/381201): Move this call there once that bug is fixed so that |
| 1687 // |disableFullScreen| is called only from one place. | 1679 // |disableFullScreen| is called only from one place. |
| 1688 [fullScreenController_ disableFullScreen]; | 1680 [fullScreenController_ disableFullScreen]; |
| 1689 [findInPageController_ disableFindInPageWithCompletionHandler:nil]; | |
| 1690 GURL lastCommittedURL = webState->GetLastCommittedURL(); | 1681 GURL lastCommittedURL = webState->GetLastCommittedURL(); |
| 1691 [autoReloadBridge_ loadStartedForURL:lastCommittedURL]; | 1682 [autoReloadBridge_ loadStartedForURL:lastCommittedURL]; |
| 1692 | 1683 |
| 1693 if (isUserNavigationEvent_) { | 1684 if (isUserNavigationEvent_) { |
| 1694 [[NSNotificationCenter defaultCenter] | 1685 [[NSNotificationCenter defaultCenter] |
| 1695 postNotificationName:kTabModelUserNavigatedNotification | 1686 postNotificationName:kTabModelUserNavigatedNotification |
| 1696 object:self]; | 1687 object:self]; |
| 1697 } | 1688 } |
| 1698 if (parentTabModel_) { | 1689 if (parentTabModel_) { |
| 1699 [[NSNotificationCenter defaultCenter] | 1690 [[NSNotificationCenter defaultCenter] |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 inBackground:NO | 2156 inBackground:NO |
| 2166 appendTo:kLastTab]); | 2157 appendTo:kLastTab]); |
| 2167 [self.view chromeExecuteCommand:command]; | 2158 [self.view chromeExecuteCommand:command]; |
| 2168 } else { | 2159 } else { |
| 2169 base::scoped_nsobject<GenericChromeCommand> chromeCommand( | 2160 base::scoped_nsobject<GenericChromeCommand> chromeCommand( |
| 2170 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); | 2161 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); |
| 2171 [self.view chromeExecuteCommand:chromeCommand]; | 2162 [self.view chromeExecuteCommand:chromeCommand]; |
| 2172 } | 2163 } |
| 2173 } | 2164 } |
| 2174 | 2165 |
| 2175 - (FindInPageController*)findInPageController { | |
| 2176 return findInPageController_; | |
| 2177 } | |
| 2178 | |
| 2179 - (NativeAppNavigationController*)nativeAppNavigationController { | 2166 - (NativeAppNavigationController*)nativeAppNavigationController { |
| 2180 return nativeAppNavigationController_; | 2167 return nativeAppNavigationController_; |
| 2181 } | 2168 } |
| 2182 | 2169 |
| 2183 - (void)initNativeAppNavigationController { | 2170 - (void)initNativeAppNavigationController { |
| 2184 if (browserState_->IsOffTheRecord()) | 2171 if (browserState_->IsOffTheRecord()) |
| 2185 return; | 2172 return; |
| 2186 DCHECK(!nativeAppNavigationController_); | 2173 DCHECK(!nativeAppNavigationController_); |
| 2187 nativeAppNavigationController_.reset([[NativeAppNavigationController alloc] | 2174 nativeAppNavigationController_.reset([[NativeAppNavigationController alloc] |
| 2188 initWithWebState:self.webState | 2175 initWithWebState:self.webState |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 [self.webController setDelegate:self]; | 2228 [self.webController setDelegate:self]; |
| 2242 webStateObserver_.reset( | 2229 webStateObserver_.reset( |
| 2243 new web::WebStateObserverBridge(webStateImpl_.get(), self)); | 2230 new web::WebStateObserverBridge(webStateImpl_.get(), self)); |
| 2244 // SessionTabHelper comes first because it sets up the tab ID, and other | 2231 // SessionTabHelper comes first because it sets up the tab ID, and other |
| 2245 // helpers may rely on that. | 2232 // helpers may rely on that. |
| 2246 IOSChromeSessionTabHelper::CreateForWebState(webStateImpl_.get()); | 2233 IOSChromeSessionTabHelper::CreateForWebState(webStateImpl_.get()); |
| 2247 IOSChromeSyncedTabDelegate::CreateForWebState(webStateImpl_.get()); | 2234 IOSChromeSyncedTabDelegate::CreateForWebState(webStateImpl_.get()); |
| 2248 // Start observing the new web controller's InfoBarManager and FaviconDriver. | 2235 // Start observing the new web controller's InfoBarManager and FaviconDriver. |
| 2249 [self setShouldObserveInfoBarManager:YES]; | 2236 [self setShouldObserveInfoBarManager:YES]; |
| 2250 [self setShouldObserveFaviconChanges:YES]; | 2237 [self setShouldObserveFaviconChanges:YES]; |
| 2251 findInPageController_.reset(); | |
| 2252 } | 2238 } |
| 2253 | 2239 |
| 2254 - (void)replaceExternalAppLauncher:(id)externalAppLauncher { | 2240 - (void)replaceExternalAppLauncher:(id)externalAppLauncher { |
| 2255 externalAppLauncher_.reset([externalAppLauncher retain]); | 2241 externalAppLauncher_.reset([externalAppLauncher retain]); |
| 2256 } | 2242 } |
| 2257 | 2243 |
| 2258 - (TabModel*)parentTabModel { | 2244 - (TabModel*)parentTabModel { |
| 2259 return parentTabModel_; | 2245 return parentTabModel_; |
| 2260 } | 2246 } |
| 2261 | 2247 |
| 2262 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2248 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2263 return inputAccessoryViewController_.get(); | 2249 return inputAccessoryViewController_.get(); |
| 2264 } | 2250 } |
| 2265 | 2251 |
| 2266 @end | 2252 @end |
| OLD | NEW |