Chromium Code Reviews| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 #include "ios/chrome/grit/ios_strings.h" | 162 #include "ios/chrome/grit/ios_strings.h" |
| 163 #import "ios/net/request_tracker.h" | 163 #import "ios/net/request_tracker.h" |
| 164 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 164 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 165 #include "ios/public/provider/chrome/browser/ui/app_rating_prompt.h" | 165 #include "ios/public/provider/chrome/browser/ui/app_rating_prompt.h" |
| 166 #include "ios/public/provider/chrome/browser/ui/default_ios_web_view_factory.h" | 166 #include "ios/public/provider/chrome/browser/ui/default_ios_web_view_factory.h" |
| 167 #import "ios/public/provider/chrome/browser/voice/voice_search_bar.h" | 167 #import "ios/public/provider/chrome/browser/voice/voice_search_bar.h" |
| 168 #import "ios/public/provider/chrome/browser/voice/voice_search_bar_owner.h" | 168 #import "ios/public/provider/chrome/browser/voice/voice_search_bar_owner.h" |
| 169 #include "ios/public/provider/chrome/browser/voice/voice_search_controller.h" | 169 #include "ios/public/provider/chrome/browser/voice/voice_search_controller.h" |
| 170 #include "ios/public/provider/chrome/browser/voice/voice_search_controller_deleg ate.h" | 170 #include "ios/public/provider/chrome/browser/voice/voice_search_controller_deleg ate.h" |
| 171 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h" | 171 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h" |
| 172 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" | |
| 172 #import "ios/shared/chrome/browser/ui/tools_menu/tools_menu_configuration.h" | 173 #import "ios/shared/chrome/browser/ui/tools_menu/tools_menu_configuration.h" |
| 173 #include "ios/web/public/active_state_manager.h" | 174 #include "ios/web/public/active_state_manager.h" |
| 174 #include "ios/web/public/navigation_item.h" | 175 #include "ios/web/public/navigation_item.h" |
| 175 #import "ios/web/public/navigation_manager.h" | 176 #import "ios/web/public/navigation_manager.h" |
| 176 #include "ios/web/public/referrer_util.h" | 177 #include "ios/web/public/referrer_util.h" |
| 177 #include "ios/web/public/ssl_status.h" | 178 #include "ios/web/public/ssl_status.h" |
| 178 #include "ios/web/public/url_scheme_util.h" | 179 #include "ios/web/public/url_scheme_util.h" |
| 179 #include "ios/web/public/user_agent.h" | 180 #include "ios/web/public/user_agent.h" |
| 180 #include "ios/web/public/web_client.h" | 181 #include "ios/web/public/web_client.h" |
| 181 #import "ios/web/public/web_state/context_menu_params.h" | 182 #import "ios/web/public/web_state/context_menu_params.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 | 394 |
| 394 // Handles displaying the context menu for all form factors. | 395 // Handles displaying the context menu for all form factors. |
| 395 ContextMenuCoordinator* _contextMenuCoordinator; | 396 ContextMenuCoordinator* _contextMenuCoordinator; |
| 396 | 397 |
| 397 // Backing object for property of the same name. | 398 // Backing object for property of the same name. |
| 398 DialogPresenter* _dialogPresenter; | 399 DialogPresenter* _dialogPresenter; |
| 399 | 400 |
| 400 // Handles presentation of JavaScript dialogs. | 401 // Handles presentation of JavaScript dialogs. |
| 401 std::unique_ptr<JavaScriptDialogPresenterImpl> _javaScriptDialogPresenter; | 402 std::unique_ptr<JavaScriptDialogPresenterImpl> _javaScriptDialogPresenter; |
| 402 | 403 |
| 404 // Handles command dispatching. | |
| 405 CommandDispatcher* _dispatcher; | |
| 406 | |
| 403 // Keyboard commands provider. It offloads most of the keyboard commands | 407 // Keyboard commands provider. It offloads most of the keyboard commands |
| 404 // management off of the BVC. | 408 // management off of the BVC. |
| 405 KeyCommandsProvider* _keyCommandsProvider; | 409 KeyCommandsProvider* _keyCommandsProvider; |
| 406 | 410 |
| 407 // Calls to |-relinquishedToolbarController| will set this to yes, and calls | 411 // Calls to |-relinquishedToolbarController| will set this to yes, and calls |
| 408 // to |-reparentToolbarController| will reset it to NO. | 412 // to |-reparentToolbarController| will reset it to NO. |
| 409 BOOL _isToolbarControllerRelinquished; | 413 BOOL _isToolbarControllerRelinquished; |
| 410 | 414 |
| 411 // The controller that owns the currently relinquished toolbar controller. | 415 // The controller that owns the currently relinquished toolbar controller. |
| 412 // The reference is weak because it's possible for the toolbar owner to be | 416 // The reference is weak because it's possible for the toolbar owner to be |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 dependencyFactory: | 945 dependencyFactory: |
| 942 (BrowserViewControllerDependencyFactory*)factory { | 946 (BrowserViewControllerDependencyFactory*)factory { |
| 943 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; | 947 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; |
| 944 if (self) { | 948 if (self) { |
| 945 DCHECK(factory); | 949 DCHECK(factory); |
| 946 | 950 |
| 947 _dependencyFactory = factory; | 951 _dependencyFactory = factory; |
| 948 _nativeControllersForTabIDs = [NSMapTable strongToWeakObjectsMapTable]; | 952 _nativeControllersForTabIDs = [NSMapTable strongToWeakObjectsMapTable]; |
| 949 _dialogPresenter = [[DialogPresenter alloc] initWithDelegate:self | 953 _dialogPresenter = [[DialogPresenter alloc] initWithDelegate:self |
| 950 presentingViewController:self]; | 954 presentingViewController:self]; |
| 955 _dispatcher = [[CommandDispatcher alloc] init]; | |
| 956 [_dispatcher startDispatchingToTarget:self | |
| 957 forProtocol:@protocol(UrlLoader)]; | |
| 958 [_dispatcher startDispatchingToTarget:self | |
| 959 forProtocol:@protocol(WebToolbarDelegate)]; | |
| 960 [_dispatcher startDispatchingToTarget:self | |
| 961 forSelector:@selector(chromeExecuteCommand:)]; | |
| 962 | |
| 951 _javaScriptDialogPresenter.reset( | 963 _javaScriptDialogPresenter.reset( |
| 952 new JavaScriptDialogPresenterImpl(_dialogPresenter)); | 964 new JavaScriptDialogPresenterImpl(_dialogPresenter)); |
| 953 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); | 965 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); |
| 954 // TODO(leng): Delay this. | 966 // TODO(leng): Delay this. |
| 955 [[UpgradeCenter sharedInstance] registerClient:self]; | 967 [[UpgradeCenter sharedInstance] registerClient:self]; |
| 956 _inNewTabAnimation = NO; | 968 _inNewTabAnimation = NO; |
| 957 if (model && browserState) | 969 if (model && browserState) |
| 958 [self updateWithTabModel:model browserState:browserState]; | 970 [self updateWithTabModel:model browserState:browserState]; |
| 959 if ([[NSUserDefaults standardUserDefaults] | 971 if ([[NSUserDefaults standardUserDefaults] |
| 960 boolForKey:@"fullScreenShowAlert"]) { | 972 boolForKey:@"fullScreenShowAlert"]) { |
| 961 _fullScreenAlertShown = [[NSMutableSet alloc] init]; | 973 _fullScreenAlertShown = [[NSMutableSet alloc] init]; |
| 962 } | 974 } |
| 963 } | 975 } |
| 964 return self; | 976 return self; |
| 965 } | 977 } |
| 966 | 978 |
| 967 - (instancetype)initWithNibName:(NSString*)nibNameOrNil | 979 - (instancetype)initWithNibName:(NSString*)nibNameOrNil |
| 968 bundle:(NSBundle*)nibBundleOrNil { | 980 bundle:(NSBundle*)nibBundleOrNil { |
| 969 NOTREACHED(); | 981 NOTREACHED(); |
| 970 return nil; | 982 return nil; |
| 971 } | 983 } |
| 972 | 984 |
| 973 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 985 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 974 NOTREACHED(); | 986 NOTREACHED(); |
| 975 return nil; | 987 return nil; |
| 976 } | 988 } |
| 977 | 989 |
| 978 - (void)dealloc { | 990 - (void)dealloc { |
| 991 [_dispatcher stopDispatchingToTarget:self]; | |
|
rohitrao (ping after 24h)
2017/04/28 11:56:22
The way the dispatcher is currently written, it's
justincohen
2017/04/28 14:02:20
Done.
| |
| 992 | |
| 979 _tabStripController = nil; | 993 _tabStripController = nil; |
| 980 _infoBarContainer = nil; | 994 _infoBarContainer = nil; |
| 981 _readingListMenuNotifier = nil; | 995 _readingListMenuNotifier = nil; |
| 982 if (_bookmarkModel) | 996 if (_bookmarkModel) |
| 983 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); | 997 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); |
| 984 [_model removeObserver:self]; | 998 [_model removeObserver:self]; |
| 985 [[UpgradeCenter sharedInstance] unregisterClient:self]; | 999 [[UpgradeCenter sharedInstance] unregisterClient:self]; |
| 986 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 1000 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 987 [_toolbarController setDelegate:nil]; | 1001 [_toolbarController setDelegate:nil]; |
| 988 if (_voiceSearchController) | 1002 if (_voiceSearchController) |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1755 | 1769 |
| 1756 // Create the toolbar model and controller. | 1770 // Create the toolbar model and controller. |
| 1757 _toolbarModelDelegate.reset( | 1771 _toolbarModelDelegate.reset( |
| 1758 new ToolbarModelDelegateIOS([_model webStateList])); | 1772 new ToolbarModelDelegateIOS([_model webStateList])); |
| 1759 _toolbarModelIOS.reset([_dependencyFactory | 1773 _toolbarModelIOS.reset([_dependencyFactory |
| 1760 newToolbarModelIOSWithDelegate:_toolbarModelDelegate.get()]); | 1774 newToolbarModelIOSWithDelegate:_toolbarModelDelegate.get()]); |
| 1761 _toolbarController = [_dependencyFactory | 1775 _toolbarController = [_dependencyFactory |
| 1762 newWebToolbarControllerWithDelegate:self | 1776 newWebToolbarControllerWithDelegate:self |
| 1763 urlLoader:self | 1777 urlLoader:self |
| 1764 preloadProvider:_preloadController]; | 1778 preloadProvider:_preloadController]; |
| 1779 [_dispatcher startDispatchingToTarget:_toolbarController | |
| 1780 forProtocol:@protocol(OmniboxFocuser)]; | |
| 1765 [_toolbarController setTabCount:[_model count]]; | 1781 [_toolbarController setTabCount:[_model count]]; |
| 1766 if (_voiceSearchController) | 1782 if (_voiceSearchController) |
| 1767 _voiceSearchController->SetDelegate(_toolbarController); | 1783 _voiceSearchController->SetDelegate(_toolbarController); |
| 1768 | 1784 |
| 1769 // If needed, create the tabstrip. | 1785 // If needed, create the tabstrip. |
| 1770 if (IsIPadIdiom()) { | 1786 if (IsIPadIdiom()) { |
| 1771 _tabStripController = | 1787 _tabStripController = |
| 1772 [_dependencyFactory newTabStripControllerWithTabModel:_model]; | 1788 [_dependencyFactory newTabStripControllerWithTabModel:_model]; |
| 1773 _tabStripController.fullscreenDelegate = self; | 1789 _tabStripController.fullscreenDelegate = self; |
| 1774 } | 1790 } |
| (...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3021 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) { | 3037 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) { |
| 3022 NewTabPageController* pageController = | 3038 NewTabPageController* pageController = |
| 3023 [[NewTabPageController alloc] initWithUrl:url | 3039 [[NewTabPageController alloc] initWithUrl:url |
| 3024 loader:self | 3040 loader:self |
| 3025 focuser:_toolbarController | 3041 focuser:_toolbarController |
| 3026 ntpObserver:self | 3042 ntpObserver:self |
| 3027 browserState:_browserState | 3043 browserState:_browserState |
| 3028 colorCache:_dominantColorCache | 3044 colorCache:_dominantColorCache |
| 3029 webToolbarDelegate:self | 3045 webToolbarDelegate:self |
| 3030 tabModel:_model | 3046 tabModel:_model |
| 3031 parentViewController:self]; | 3047 parentViewController:self |
| 3048 dispatcher:_dispatcher]; | |
| 3032 pageController.swipeRecognizerProvider = self.sideSwipeController; | 3049 pageController.swipeRecognizerProvider = self.sideSwipeController; |
| 3033 | 3050 |
| 3034 // Panel is always NTP for iPhone. | 3051 // Panel is always NTP for iPhone. |
| 3035 NewTabPage::PanelIdentifier panelType = NewTabPage::kMostVisitedPanel; | 3052 NewTabPage::PanelIdentifier panelType = NewTabPage::kMostVisitedPanel; |
| 3036 | 3053 |
| 3037 if (IsIPadIdiom()) { | 3054 if (IsIPadIdiom()) { |
| 3038 // New Tab Page can have multiple panels. Each panel is addressable | 3055 // New Tab Page can have multiple panels. Each panel is addressable |
| 3039 // by a #fragment, e.g. chrome://newtab/#most_visited takes user to | 3056 // by a #fragment, e.g. chrome://newtab/#most_visited takes user to |
| 3040 // the Most Visited page, chrome://newtab/#bookmarks takes user to | 3057 // the Most Visited page, chrome://newtab/#bookmarks takes user to |
| 3041 // the Bookmark Manager, etc. | 3058 // the Bookmark Manager, etc. |
| (...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5167 | 5184 |
| 5168 - (UIView*)voiceSearchButton { | 5185 - (UIView*)voiceSearchButton { |
| 5169 return _voiceSearchButton; | 5186 return _voiceSearchButton; |
| 5170 } | 5187 } |
| 5171 | 5188 |
| 5172 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5189 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5173 return [self currentLogoAnimationControllerOwner]; | 5190 return [self currentLogoAnimationControllerOwner]; |
| 5174 } | 5191 } |
| 5175 | 5192 |
| 5176 @end | 5193 @end |
| OLD | NEW |