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