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"]) { |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 [_contextualSearchMask removeFromSuperview]; | 1721 [_contextualSearchMask removeFromSuperview]; |
1710 [_paymentRequestManager close]; | 1722 [_paymentRequestManager close]; |
1711 _paymentRequestManager = nil; | 1723 _paymentRequestManager = nil; |
1712 [_toolbarController browserStateDestroyed]; | 1724 [_toolbarController browserStateDestroyed]; |
1713 [_model browserStateDestroyed]; | 1725 [_model browserStateDestroyed]; |
1714 [_preloadController browserStateDestroyed]; | 1726 [_preloadController browserStateDestroyed]; |
1715 _preloadController = nil; | 1727 _preloadController = nil; |
1716 // The file remover needs the browser state, so needs to be destroyed now. | 1728 // The file remover needs the browser state, so needs to be destroyed now. |
1717 _externalFileRemover = nil; | 1729 _externalFileRemover = nil; |
1718 _browserState = nullptr; | 1730 _browserState = nullptr; |
| 1731 [_dispatcher stopDispatchingToTarget:self]; |
| 1732 _dispatcher = nil; |
1719 } | 1733 } |
1720 | 1734 |
1721 - (void)installFakeStatusBar { | 1735 - (void)installFakeStatusBar { |
1722 if (IsIPadIdiom()) { | 1736 if (IsIPadIdiom()) { |
1723 CGFloat statusBarHeight = StatusBarHeight(); | 1737 CGFloat statusBarHeight = StatusBarHeight(); |
1724 CGRect statusBarFrame = | 1738 CGRect statusBarFrame = |
1725 CGRectMake(0, 0, [[self view] frame].size.width, statusBarHeight); | 1739 CGRectMake(0, 0, [[self view] frame].size.width, statusBarHeight); |
1726 UIView* statusBarView = [[UIView alloc] initWithFrame:statusBarFrame]; | 1740 UIView* statusBarView = [[UIView alloc] initWithFrame:statusBarFrame]; |
1727 [statusBarView setBackgroundColor:TabStrip::BackgroundColor()]; | 1741 [statusBarView setBackgroundColor:TabStrip::BackgroundColor()]; |
1728 [statusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; | 1742 [statusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; |
(...skipping 26 matching lines...) Expand all 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 |