| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 55 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 56 #include "ios/chrome/browser/chrome_url_constants.h" | 56 #include "ios/chrome/browser/chrome_url_constants.h" |
| 57 #import "ios/chrome/browser/crash_loop_detection_util.h" | 57 #import "ios/chrome/browser/crash_loop_detection_util.h" |
| 58 #include "ios/chrome/browser/experimental_flags.h" | 58 #include "ios/chrome/browser/experimental_flags.h" |
| 59 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" | 59 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" |
| 60 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" | 60 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" |
| 61 #include "ios/chrome/browser/history/history_service_factory.h" | 61 #include "ios/chrome/browser/history/history_service_factory.h" |
| 62 #include "ios/chrome/browser/history/top_sites_factory.h" | 62 #include "ios/chrome/browser/history/top_sites_factory.h" |
| 63 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" | 63 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
| 64 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" | 64 #import "ios/chrome/browser/metrics/tab_usage_recorder.h" |
| 65 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller
.h" |
| 65 #import "ios/chrome/browser/passwords/password_controller.h" | 66 #import "ios/chrome/browser/passwords/password_controller.h" |
| 66 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h" | 67 #import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h" |
| 67 #include "ios/chrome/browser/pref_names.h" | 68 #include "ios/chrome/browser/pref_names.h" |
| 68 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" | 69 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" |
| 69 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 70 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 70 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" | 71 #include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h" |
| 71 #include "ios/chrome/browser/signin/account_consistency_service_factory.h" | 72 #include "ios/chrome/browser/signin/account_consistency_service_factory.h" |
| 72 #include "ios/chrome/browser/signin/account_reconcilor_factory.h" | 73 #include "ios/chrome/browser/signin/account_reconcilor_factory.h" |
| 74 #include "ios/chrome/browser/signin/authentication_service.h" |
| 75 #include "ios/chrome/browser/signin/authentication_service_factory.h" |
| 73 #include "ios/chrome/browser/signin/signin_capability.h" | 76 #include "ios/chrome/browser/signin/signin_capability.h" |
| 74 #import "ios/chrome/browser/snapshots/snapshot_manager.h" | 77 #import "ios/chrome/browser/snapshots/snapshot_manager.h" |
| 75 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" | 78 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" |
| 76 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" | 79 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" |
| 77 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" | 80 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" |
| 78 #import "ios/chrome/browser/tabs/tab_delegate.h" | 81 #import "ios/chrome/browser/tabs/tab_delegate.h" |
| 79 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" | 82 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" |
| 80 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" | 83 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" |
| 81 #import "ios/chrome/browser/tabs/tab_helper_util.h" | 84 #import "ios/chrome/browser/tabs/tab_helper_util.h" |
| 82 #import "ios/chrome/browser/tabs/tab_model.h" | 85 #import "ios/chrome/browser/tabs/tab_model.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 97 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h" | 100 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h" |
| 98 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h" | 101 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h" |
| 99 #include "ios/chrome/browser/ui/ui_util.h" | 102 #include "ios/chrome/browser/ui/ui_util.h" |
| 100 #import "ios/chrome/browser/web/auto_reload_bridge.h" | 103 #import "ios/chrome/browser/web/auto_reload_bridge.h" |
| 101 #import "ios/chrome/browser/web/external_app_launcher.h" | 104 #import "ios/chrome/browser/web/external_app_launcher.h" |
| 102 #import "ios/chrome/browser/web/navigation_manager_util.h" | 105 #import "ios/chrome/browser/web/navigation_manager_util.h" |
| 103 #import "ios/chrome/browser/web/passkit_dialog_provider.h" | 106 #import "ios/chrome/browser/web/passkit_dialog_provider.h" |
| 104 #include "ios/chrome/browser/web/print_observer.h" | 107 #include "ios/chrome/browser/web/print_observer.h" |
| 105 #import "ios/chrome/browser/xcallback_parameters.h" | 108 #import "ios/chrome/browser/xcallback_parameters.h" |
| 106 #include "ios/chrome/grit/ios_strings.h" | 109 #include "ios/chrome/grit/ios_strings.h" |
| 110 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 111 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metad
ata.h" |
| 112 #import "ios/public/provider/chrome/browser/native_app_launcher/native_app_white
list_manager.h" |
| 107 #import "ios/web/navigation/crw_session_controller.h" | 113 #import "ios/web/navigation/crw_session_controller.h" |
| 108 #import "ios/web/navigation/navigation_item_impl.h" | 114 #import "ios/web/navigation/navigation_item_impl.h" |
| 109 #import "ios/web/navigation/navigation_manager_impl.h" | 115 #import "ios/web/navigation/navigation_manager_impl.h" |
| 110 #include "ios/web/public/favicon_status.h" | 116 #include "ios/web/public/favicon_status.h" |
| 111 #include "ios/web/public/favicon_url.h" | 117 #include "ios/web/public/favicon_url.h" |
| 112 #include "ios/web/public/interstitials/web_interstitial.h" | 118 #include "ios/web/public/interstitials/web_interstitial.h" |
| 113 #include "ios/web/public/load_committed_details.h" | 119 #include "ios/web/public/load_committed_details.h" |
| 114 #import "ios/web/public/navigation_manager.h" | 120 #import "ios/web/public/navigation_manager.h" |
| 115 #include "ios/web/public/referrer.h" | 121 #include "ios/web/public/referrer.h" |
| 116 #import "ios/web/public/serializable_user_data_manager.h" | 122 #import "ios/web/public/serializable_user_data_manager.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 inputAccessoryViewController_; | 276 inputAccessoryViewController_; |
| 271 | 277 |
| 272 // TODO(crbug.com/661665): move the WebContentsObservers into their own | 278 // TODO(crbug.com/661665): move the WebContentsObservers into their own |
| 273 // container. | 279 // container. |
| 274 // Handles saving and autofill of passwords. | 280 // Handles saving and autofill of passwords. |
| 275 base::scoped_nsobject<PasswordController> passwordController_; | 281 base::scoped_nsobject<PasswordController> passwordController_; |
| 276 | 282 |
| 277 // Handles autofill. | 283 // Handles autofill. |
| 278 base::scoped_nsobject<AutofillController> autofillController_; | 284 base::scoped_nsobject<AutofillController> autofillController_; |
| 279 | 285 |
| 286 // Handles GAL infobar on web pages. |
| 287 base::scoped_nsobject<NativeAppNavigationController> |
| 288 nativeAppNavigationController_; |
| 289 |
| 280 // Handles caching and retrieving of snapshots. | 290 // Handles caching and retrieving of snapshots. |
| 281 base::scoped_nsobject<SnapshotManager> snapshotManager_; | 291 base::scoped_nsobject<SnapshotManager> snapshotManager_; |
| 282 | 292 |
| 283 // Handles retrieving, generating and updating snapshots of CRWWebController's | 293 // Handles retrieving, generating and updating snapshots of CRWWebController's |
| 284 // web page. | 294 // web page. |
| 285 base::scoped_nsobject<WebControllerSnapshotHelper> | 295 base::scoped_nsobject<WebControllerSnapshotHelper> |
| 286 webControllerSnapshotHelper_; | 296 webControllerSnapshotHelper_; |
| 287 | 297 |
| 288 // Handles support for window.print JavaScript calls. | 298 // Handles support for window.print JavaScript calls. |
| 289 std::unique_ptr<PrintObserver> printObserver_; | 299 std::unique_ptr<PrintObserver> printObserver_; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 344 |
| 335 // Adds the current session entry to this history database. | 345 // Adds the current session entry to this history database. |
| 336 - (void)addCurrentEntryToHistoryDB; | 346 - (void)addCurrentEntryToHistoryDB; |
| 337 | 347 |
| 338 // Adds any cached entries from |addPageVector_| to the history DB. | 348 // Adds any cached entries from |addPageVector_| to the history DB. |
| 339 - (void)commitCachedEntriesToHistoryDB; | 349 - (void)commitCachedEntriesToHistoryDB; |
| 340 | 350 |
| 341 // Returns the OpenInController for this tab. | 351 // Returns the OpenInController for this tab. |
| 342 - (OpenInController*)openInController; | 352 - (OpenInController*)openInController; |
| 343 | 353 |
| 354 // Initialize the Native App Launcher controller. |
| 355 - (void)initNativeAppNavigationController; |
| 356 |
| 344 // Handles exportable files if possible. | 357 // Handles exportable files if possible. |
| 345 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; | 358 - (void)handleExportableFile:(net::HttpResponseHeaders*)headers; |
| 346 | 359 |
| 347 // Called after the session history is replaced, useful for updating members | 360 // Called after the session history is replaced, useful for updating members |
| 348 // with new sessionID. | 361 // with new sessionID. |
| 349 - (void)didReplaceSessionHistory; | 362 - (void)didReplaceSessionHistory; |
| 350 | 363 |
| 351 // Called when the UIApplication's state becomes active. | 364 // Called when the UIApplication's state becomes active. |
| 352 - (void)applicationDidBecomeActive; | 365 - (void)applicationDidBecomeActive; |
| 353 | 366 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 | 499 |
| 487 [self updateLastVisitedTimestamp]; | 500 [self updateLastVisitedTimestamp]; |
| 488 [[self webController] addObserver:self]; | 501 [[self webController] addObserver:self]; |
| 489 [[self webController] setDelegate:self]; | 502 [[self webController] setDelegate:self]; |
| 490 | 503 |
| 491 snapshotManager_.reset([[SnapshotManager alloc] init]); | 504 snapshotManager_.reset([[SnapshotManager alloc] init]); |
| 492 webControllerSnapshotHelper_.reset([[WebControllerSnapshotHelper alloc] | 505 webControllerSnapshotHelper_.reset([[WebControllerSnapshotHelper alloc] |
| 493 initWithSnapshotManager:snapshotManager_ | 506 initWithSnapshotManager:snapshotManager_ |
| 494 tab:self]); | 507 tab:self]); |
| 495 | 508 |
| 509 [self initNativeAppNavigationController]; |
| 510 |
| 496 [[NSNotificationCenter defaultCenter] | 511 [[NSNotificationCenter defaultCenter] |
| 497 addObserver:self | 512 addObserver:self |
| 498 selector:@selector(applicationDidBecomeActive) | 513 selector:@selector(applicationDidBecomeActive) |
| 499 name:UIApplicationDidBecomeActiveNotification | 514 name:UIApplicationDidBecomeActiveNotification |
| 500 object:nil]; | 515 object:nil]; |
| 501 } | 516 } |
| 502 return self; | 517 return self; |
| 503 } | 518 } |
| 504 | 519 |
| 505 - (void)attachTabHelpers { | 520 - (void)attachTabHelpers { |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) { | 1619 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) { |
| 1605 [delegate_ discardPrerender]; | 1620 [delegate_ discardPrerender]; |
| 1606 return NO; | 1621 return NO; |
| 1607 } | 1622 } |
| 1608 return YES; | 1623 return YES; |
| 1609 } | 1624 } |
| 1610 | 1625 |
| 1611 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url | 1626 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url |
| 1612 sourceURL:(const GURL&)sourceURL | 1627 sourceURL:(const GURL&)sourceURL |
| 1613 linkClicked:(BOOL)linkClicked { | 1628 linkClicked:(BOOL)linkClicked { |
| 1614 // TODO(crbug/711511): Returning NO bypasses all Link Navigation logic | 1629 // Don't open any native app directly when prerendering or from Incognito. |
| 1615 // for Native App Launcher. This call should eventually be eliminated. | 1630 if (isPrerenderTab_ || self.browserState->IsOffTheRecord()) |
| 1631 return NO; |
| 1632 |
| 1633 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata( |
| 1634 [[ios::GetChromeBrowserProvider()->GetNativeAppWhitelistManager() |
| 1635 nativeAppForURL:url] retain]); |
| 1636 if (![metadata shouldAutoOpenLinks]) |
| 1637 return NO; |
| 1638 |
| 1639 AuthenticationService* authenticationService = |
| 1640 AuthenticationServiceFactory::GetForBrowserState(self.browserState); |
| 1641 ChromeIdentity* identity = authenticationService->GetAuthenticatedIdentity(); |
| 1642 |
| 1643 // Attempts to open external app without x-callback. |
| 1644 if ([self openExternalURL:[metadata launchURLWithURL:url identity:identity] |
| 1645 sourceURL:sourceURL |
| 1646 linkClicked:linkClicked]) { |
| 1647 return YES; |
| 1648 } |
| 1649 |
| 1650 // Auto-open didn't work. Reset the auto-open flag. |
| 1651 [metadata unsetShouldAutoOpenLinks]; |
| 1616 return NO; | 1652 return NO; |
| 1617 } | 1653 } |
| 1618 | 1654 |
| 1619 - (double)lastVisitedTimestamp { | 1655 - (double)lastVisitedTimestamp { |
| 1620 return lastVisitedTimestamp_; | 1656 return lastVisitedTimestamp_; |
| 1621 } | 1657 } |
| 1622 | 1658 |
| 1623 - (void)updateLastVisitedTimestamp { | 1659 - (void)updateLastVisitedTimestamp { |
| 1624 lastVisitedTimestamp_ = [[NSDate date] timeIntervalSince1970]; | 1660 lastVisitedTimestamp_ = [[NSDate date] timeIntervalSince1970]; |
| 1625 } | 1661 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 appendTo:kLastTab]); | 1907 appendTo:kLastTab]); |
| 1872 [self.view chromeExecuteCommand:command]; | 1908 [self.view chromeExecuteCommand:command]; |
| 1873 } else { | 1909 } else { |
| 1874 base::scoped_nsobject<GenericChromeCommand> chromeCommand( | 1910 base::scoped_nsobject<GenericChromeCommand> chromeCommand( |
| 1875 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); | 1911 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); |
| 1876 [self.view chromeExecuteCommand:chromeCommand]; | 1912 [self.view chromeExecuteCommand:chromeCommand]; |
| 1877 } | 1913 } |
| 1878 } | 1914 } |
| 1879 | 1915 |
| 1880 - (NativeAppNavigationController*)nativeAppNavigationController { | 1916 - (NativeAppNavigationController*)nativeAppNavigationController { |
| 1881 // TODO(crbug.com/711511): This call should eventually be eliminated. | 1917 return nativeAppNavigationController_; |
| 1882 return nil; | 1918 } |
| 1919 |
| 1920 - (void)initNativeAppNavigationController { |
| 1921 if (browserState_->IsOffTheRecord()) |
| 1922 return; |
| 1923 DCHECK(!nativeAppNavigationController_); |
| 1924 nativeAppNavigationController_.reset( |
| 1925 [[NativeAppNavigationController alloc] initWithWebState:self.webState]); |
| 1926 DCHECK(nativeAppNavigationController_); |
| 1883 } | 1927 } |
| 1884 | 1928 |
| 1885 - (id<PassKitDialogProvider>)passKitDialogProvider { | 1929 - (id<PassKitDialogProvider>)passKitDialogProvider { |
| 1886 return passKitDialogProvider_.get(); | 1930 return passKitDialogProvider_.get(); |
| 1887 } | 1931 } |
| 1888 | 1932 |
| 1889 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { | 1933 - (void)setPassKitDialogProvider:(id<PassKitDialogProvider>)provider { |
| 1890 passKitDialogProvider_.reset(provider); | 1934 passKitDialogProvider_.reset(provider); |
| 1891 } | 1935 } |
| 1892 | 1936 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1923 | 1967 |
| 1924 - (TabModel*)parentTabModel { | 1968 - (TabModel*)parentTabModel { |
| 1925 return parentTabModel_; | 1969 return parentTabModel_; |
| 1926 } | 1970 } |
| 1927 | 1971 |
| 1928 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 1972 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 1929 return inputAccessoryViewController_.get(); | 1973 return inputAccessoryViewController_.get(); |
| 1930 } | 1974 } |
| 1931 | 1975 |
| 1932 @end | 1976 @end |
| OLD | NEW |