| 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/ui/browser_view_controller.h" | 5 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 6 | 6 |
| 7 #import <AssetsLibrary/AssetsLibrary.h> | 7 #import <AssetsLibrary/AssetsLibrary.h> |
| 8 #import <MobileCoreServices/MobileCoreServices.h> | 8 #import <MobileCoreServices/MobileCoreServices.h> |
| 9 #import <PassKit/PassKit.h> | 9 #import <PassKit/PassKit.h> |
| 10 #import <Photos/Photos.h> | 10 #import <Photos/Photos.h> |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 #import "ios/chrome/browser/tabs/tab_model.h" | 81 #import "ios/chrome/browser/tabs/tab_model.h" |
| 82 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 82 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
| 83 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" | 83 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" |
| 84 #import "ios/chrome/browser/ui/activity_services/share_protocol.h" | 84 #import "ios/chrome/browser/ui/activity_services/share_protocol.h" |
| 85 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" | 85 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" |
| 86 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" | 86 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" |
| 87 #import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" | 87 #import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" |
| 88 #import "ios/chrome/browser/ui/background_generator.h" | 88 #import "ios/chrome/browser/ui/background_generator.h" |
| 89 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" | 89 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" |
| 90 #import "ios/chrome/browser/ui/browser_container_view.h" | 90 #import "ios/chrome/browser/ui/browser_container_view.h" |
| 91 #import "ios/chrome/browser/ui/browser_list_ios.h" | |
| 92 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" | 91 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" |
| 93 #import "ios/chrome/browser/ui/chrome_web_view_factory.h" | 92 #import "ios/chrome/browser/ui/chrome_web_view_factory.h" |
| 94 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 93 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 95 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 94 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 96 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 95 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 97 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 96 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
| 98 #import "ios/chrome/browser/ui/commands/reading_list_add_command.h" | 97 #import "ios/chrome/browser/ui/commands/reading_list_add_command.h" |
| 99 #import "ios/chrome/browser/ui/commands/show_mail_composer_command.h" | 98 #import "ios/chrome/browser/ui/commands/show_mail_composer_command.h" |
| 100 #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" | 99 #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" |
| 101 #import "ios/chrome/browser/ui/contextual_search/contextual_search_controller.h" | 100 #import "ios/chrome/browser/ui/contextual_search/contextual_search_controller.h" |
| (...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 _nativeControllersForTabIDs.reset( | 909 _nativeControllersForTabIDs.reset( |
| 911 [[NSMapTable strongToWeakObjectsMapTable] retain]); | 910 [[NSMapTable strongToWeakObjectsMapTable] retain]); |
| 912 _dialogPresenter.reset([[DialogPresenter alloc] initWithDelegate:self | 911 _dialogPresenter.reset([[DialogPresenter alloc] initWithDelegate:self |
| 913 presentingViewController:self]); | 912 presentingViewController:self]); |
| 914 _javaScriptDialogPresenter.reset( | 913 _javaScriptDialogPresenter.reset( |
| 915 new JavaScriptDialogPresenterImpl(_dialogPresenter)); | 914 new JavaScriptDialogPresenterImpl(_dialogPresenter)); |
| 916 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); | 915 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); |
| 917 // TODO(leng): Delay this. | 916 // TODO(leng): Delay this. |
| 918 [[UpgradeCenter sharedInstance] registerClient:self]; | 917 [[UpgradeCenter sharedInstance] registerClient:self]; |
| 919 _inNewTabAnimation = NO; | 918 _inNewTabAnimation = NO; |
| 920 BrowserListIOS::AddBrowser(self); | |
| 921 if (model && browserState) | 919 if (model && browserState) |
| 922 [self updateWithTabModel:model browserState:browserState]; | 920 [self updateWithTabModel:model browserState:browserState]; |
| 923 if ([[NSUserDefaults standardUserDefaults] | 921 if ([[NSUserDefaults standardUserDefaults] |
| 924 boolForKey:@"fullScreenShowAlert"]) { | 922 boolForKey:@"fullScreenShowAlert"]) { |
| 925 _fullScreenAlertShown.reset([[NSMutableSet alloc] init]); | 923 _fullScreenAlertShown.reset([[NSMutableSet alloc] init]); |
| 926 } | 924 } |
| 927 } | 925 } |
| 928 return self; | 926 return self; |
| 929 } | 927 } |
| 930 | 928 |
| 931 - (instancetype)initWithNibName:(NSString*)nibNameOrNil | 929 - (instancetype)initWithNibName:(NSString*)nibNameOrNil |
| 932 bundle:(NSBundle*)nibBundleOrNil { | 930 bundle:(NSBundle*)nibBundleOrNil { |
| 933 NOTREACHED(); | 931 NOTREACHED(); |
| 934 return nil; | 932 return nil; |
| 935 } | 933 } |
| 936 | 934 |
| 937 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 935 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 938 NOTREACHED(); | 936 NOTREACHED(); |
| 939 return nil; | 937 return nil; |
| 940 } | 938 } |
| 941 | 939 |
| 942 - (void)dealloc { | 940 - (void)dealloc { |
| 943 _tabStripController.reset(); | 941 _tabStripController.reset(); |
| 944 _infoBarContainer.reset(); | 942 _infoBarContainer.reset(); |
| 945 _readingListMenuNotifier.reset(); | 943 _readingListMenuNotifier.reset(); |
| 946 BrowserListIOS::RemoveBrowser(self); | |
| 947 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); | 944 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); |
| 948 [_model removeObserver:self]; | 945 [_model removeObserver:self]; |
| 949 [[UpgradeCenter sharedInstance] unregisterClient:self]; | 946 [[UpgradeCenter sharedInstance] unregisterClient:self]; |
| 950 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 947 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 951 [_toolbarController setDelegate:nil]; | 948 [_toolbarController setDelegate:nil]; |
| 952 if (_voiceSearchController.get()) | 949 if (_voiceSearchController.get()) |
| 953 _voiceSearchController->SetDelegate(nil); | 950 _voiceSearchController->SetDelegate(nil); |
| 954 [_rateThisAppDialog setDelegate:nil]; | 951 [_rateThisAppDialog setDelegate:nil]; |
| 955 [_model closeAllTabs]; | 952 [_model closeAllTabs]; |
| 956 [super dealloc]; | 953 [super dealloc]; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 [self updateDialogPresenterActiveState]; | 1034 [self updateDialogPresenterActiveState]; |
| 1038 } else { | 1035 } else { |
| 1039 self.dialogPresenter.active = false; | 1036 self.dialogPresenter.active = false; |
| 1040 } | 1037 } |
| 1041 } | 1038 } |
| 1042 | 1039 |
| 1043 - (BOOL)isPlayingTTS { | 1040 - (BOOL)isPlayingTTS { |
| 1044 return _voiceSearchController && _voiceSearchController->IsPlayingAudio(); | 1041 return _voiceSearchController && _voiceSearchController->IsPlayingAudio(); |
| 1045 } | 1042 } |
| 1046 | 1043 |
| 1044 - (ios::ChromeBrowserState*)browserState { |
| 1045 return _browserState; |
| 1046 } |
| 1047 |
| 1048 - (TabModel*)tabModel { |
| 1049 return _model.get(); |
| 1050 } |
| 1051 |
| 1047 - (SideSwipeController*)sideSwipeController { | 1052 - (SideSwipeController*)sideSwipeController { |
| 1048 if (!_sideSwipeController) { | 1053 if (!_sideSwipeController) { |
| 1049 _sideSwipeController.reset([[SideSwipeController alloc] | 1054 _sideSwipeController.reset([[SideSwipeController alloc] |
| 1050 initWithTabModel:_model | 1055 initWithTabModel:_model |
| 1051 browserState:_browserState]); | 1056 browserState:_browserState]); |
| 1052 [_sideSwipeController setSnapshotDelegate:self]; | 1057 [_sideSwipeController setSnapshotDelegate:self]; |
| 1053 [_sideSwipeController setSwipeDelegate:self]; | 1058 [_sideSwipeController setSwipeDelegate:self]; |
| 1054 } | 1059 } |
| 1055 return _sideSwipeController; | 1060 return _sideSwipeController; |
| 1056 } | 1061 } |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 [self setActive:NO]; | 1670 [self setActive:NO]; |
| 1666 // Reset the toolbar opacity in case it was changed for contextual search. | 1671 // Reset the toolbar opacity in case it was changed for contextual search. |
| 1667 [self updateToolbarControlsAlpha:1.0]; | 1672 [self updateToolbarControlsAlpha:1.0]; |
| 1668 [self updateToolbarBackgroundAlpha:1.0]; | 1673 [self updateToolbarBackgroundAlpha:1.0]; |
| 1669 [_contextualSearchController close]; | 1674 [_contextualSearchController close]; |
| 1670 _contextualSearchController.reset(); | 1675 _contextualSearchController.reset(); |
| 1671 [_contextualSearchPanel removeFromSuperview]; | 1676 [_contextualSearchPanel removeFromSuperview]; |
| 1672 [_contextualSearchMask removeFromSuperview]; | 1677 [_contextualSearchMask removeFromSuperview]; |
| 1673 [_paymentRequestManager close]; | 1678 [_paymentRequestManager close]; |
| 1674 _paymentRequestManager.reset(); | 1679 _paymentRequestManager.reset(); |
| 1675 BrowserListIOS::RemoveBrowser(self); | |
| 1676 [_toolbarController browserStateDestroyed]; | 1680 [_toolbarController browserStateDestroyed]; |
| 1677 [_model browserStateDestroyed]; | 1681 [_model browserStateDestroyed]; |
| 1678 [_preloadController browserStateDestroyed]; | 1682 [_preloadController browserStateDestroyed]; |
| 1679 _preloadController.reset(); | 1683 _preloadController.reset(); |
| 1680 // The file remover needs the browser state, so needs to be destroyed now. | 1684 // The file remover needs the browser state, so needs to be destroyed now. |
| 1681 _externalFileRemover.reset(); | 1685 _externalFileRemover.reset(); |
| 1682 _browserState = nullptr; | 1686 _browserState = nullptr; |
| 1683 } | 1687 } |
| 1684 | 1688 |
| 1685 - (void)installFakeStatusBar { | 1689 - (void)installFakeStatusBar { |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 // the error on the main thread. | 3236 // the error on the main thread. |
| 3233 [self displayPrivacyErrorAlertOnMainQueue:errorMessage]; | 3237 [self displayPrivacyErrorAlertOnMainQueue:errorMessage]; |
| 3234 } else { | 3238 } else { |
| 3235 // TODO(noyau): Ideally I'd like to show an infobar with a link to switch to | 3239 // TODO(noyau): Ideally I'd like to show an infobar with a link to switch to |
| 3236 // the photo application. The current behaviour is to create the photo there | 3240 // the photo application. The current behaviour is to create the photo there |
| 3237 // but not providing any link to it is suboptimal. That's what Safari is | 3241 // but not providing any link to it is suboptimal. That's what Safari is |
| 3238 // doing, and what the PM want, but it doesn't make it right. | 3242 // doing, and what the PM want, but it doesn't make it right. |
| 3239 } | 3243 } |
| 3240 } | 3244 } |
| 3241 | 3245 |
| 3242 #pragma mark - BrowserIOS methods | |
| 3243 | |
| 3244 - (ios::ChromeBrowserState*)browserState { | |
| 3245 return _browserState; | |
| 3246 } | |
| 3247 | |
| 3248 - (TabModel*)tabModel { | |
| 3249 return _model.get(); | |
| 3250 } | |
| 3251 | |
| 3252 #pragma mark - No-tabs UI methods | 3246 #pragma mark - No-tabs UI methods |
| 3253 | 3247 |
| 3254 // Show the No-Tabs UI (hiding normal tab/web ui). | 3248 // Show the No-Tabs UI (hiding normal tab/web ui). |
| 3255 - (void)showNoTabsUI { | 3249 - (void)showNoTabsUI { |
| 3256 // The No-Tabs UI is only shown on tablet for non-incognito BVCs. (Incognito | 3250 // The No-Tabs UI is only shown on tablet for non-incognito BVCs. (Incognito |
| 3257 // mode does not have a No-Tabs UI; the user is simply shown the non-incognito | 3251 // mode does not have a No-Tabs UI; the user is simply shown the non-incognito |
| 3258 // BVC when the last incognito tab is closed.) | 3252 // BVC when the last incognito tab is closed.) |
| 3259 DCHECK(IsIPadIdiom()); | 3253 DCHECK(IsIPadIdiom()); |
| 3260 DCHECK(!_isOffTheRecord); | 3254 DCHECK(!_isOffTheRecord); |
| 3261 | 3255 |
| (...skipping 1880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5142 | 5136 |
| 5143 - (UIView*)voiceSearchButton { | 5137 - (UIView*)voiceSearchButton { |
| 5144 return _voiceSearchButton; | 5138 return _voiceSearchButton; |
| 5145 } | 5139 } |
| 5146 | 5140 |
| 5147 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5141 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5148 return [self currentLogoAnimationControllerOwner]; | 5142 return [self currentLogoAnimationControllerOwner]; |
| 5149 } | 5143 } |
| 5150 | 5144 |
| 5151 @end | 5145 @end |
| OLD | NEW |