Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller.mm

Issue 2829003002: Add CommandDispatcher to BrowserViewController. (Closed)
Patch Set: Cleaner Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
951 _javaScriptDialogPresenter.reset( 961 _javaScriptDialogPresenter.reset(
952 new JavaScriptDialogPresenterImpl(_dialogPresenter)); 962 new JavaScriptDialogPresenterImpl(_dialogPresenter));
953 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); 963 _webStateDelegate.reset(new web::WebStateDelegateBridge(self));
954 // TODO(leng): Delay this. 964 // TODO(leng): Delay this.
955 [[UpgradeCenter sharedInstance] registerClient:self]; 965 [[UpgradeCenter sharedInstance] registerClient:self];
956 _inNewTabAnimation = NO; 966 _inNewTabAnimation = NO;
957 if (model && browserState) 967 if (model && browserState)
958 [self updateWithTabModel:model browserState:browserState]; 968 [self updateWithTabModel:model browserState:browserState];
959 if ([[NSUserDefaults standardUserDefaults] 969 if ([[NSUserDefaults standardUserDefaults]
960 boolForKey:@"fullScreenShowAlert"]) { 970 boolForKey:@"fullScreenShowAlert"]) {
961 _fullScreenAlertShown = [[NSMutableSet alloc] init]; 971 _fullScreenAlertShown = [[NSMutableSet alloc] init];
962 } 972 }
963 } 973 }
964 return self; 974 return self;
965 } 975 }
966 976
967 - (instancetype)initWithNibName:(NSString*)nibNameOrNil 977 - (instancetype)initWithNibName:(NSString*)nibNameOrNil
968 bundle:(NSBundle*)nibBundleOrNil { 978 bundle:(NSBundle*)nibBundleOrNil {
969 NOTREACHED(); 979 NOTREACHED();
970 return nil; 980 return nil;
971 } 981 }
972 982
973 - (instancetype)initWithCoder:(NSCoder*)aDecoder { 983 - (instancetype)initWithCoder:(NSCoder*)aDecoder {
974 NOTREACHED(); 984 NOTREACHED();
975 return nil; 985 return nil;
976 } 986 }
977 987
978 - (void)dealloc { 988 - (void)dealloc {
989 [_dispatcher stopDispatchingForProtocol:@protocol(OmniboxFocuser)];
990 [_dispatcher stopDispatchingForProtocol:@protocol(UrlLoader)];
991 [_dispatcher stopDispatchingForProtocol:@protocol(WebToolbarDelegate)];
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
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 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
3022 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) { 3038 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) {
3023 NewTabPageController* pageController = 3039 NewTabPageController* pageController =
3024 [[NewTabPageController alloc] initWithUrl:url 3040 [[NewTabPageController alloc] initWithUrl:url
3025 loader:self 3041 loader:self
3026 focuser:_toolbarController 3042 focuser:_toolbarController
3027 ntpObserver:self 3043 ntpObserver:self
3028 browserState:_browserState 3044 browserState:_browserState
3029 colorCache:_dominantColorCache 3045 colorCache:_dominantColorCache
3030 webToolbarDelegate:self 3046 webToolbarDelegate:self
3031 tabModel:_model 3047 tabModel:_model
3032 parentViewController:self]; 3048 parentViewController:self
3049 dispatcher:_dispatcher];
3033 pageController.swipeRecognizerProvider = self.sideSwipeController; 3050 pageController.swipeRecognizerProvider = self.sideSwipeController;
3034 3051
3035 // Panel is always NTP for iPhone. 3052 // Panel is always NTP for iPhone.
3036 NewTabPage::PanelIdentifier panelType = NewTabPage::kMostVisitedPanel; 3053 NewTabPage::PanelIdentifier panelType = NewTabPage::kMostVisitedPanel;
3037 3054
3038 if (IsIPadIdiom()) { 3055 if (IsIPadIdiom()) {
3039 // New Tab Page can have multiple panels. Each panel is addressable 3056 // New Tab Page can have multiple panels. Each panel is addressable
3040 // by a #fragment, e.g. chrome://newtab/#most_visited takes user to 3057 // by a #fragment, e.g. chrome://newtab/#most_visited takes user to
3041 // the Most Visited page, chrome://newtab/#bookmarks takes user to 3058 // the Most Visited page, chrome://newtab/#bookmarks takes user to
3042 // the Bookmark Manager, etc. 3059 // the Bookmark Manager, etc.
(...skipping 2125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 5185
5169 - (UIView*)voiceSearchButton { 5186 - (UIView*)voiceSearchButton {
5170 return _voiceSearchButton; 5187 return _voiceSearchButton;
5171 } 5188 }
5172 5189
5173 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5190 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5174 return [self currentLogoAnimationControllerOwner]; 5191 return [self currentLogoAnimationControllerOwner];
5175 } 5192 }
5176 5193
5177 @end 5194 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698