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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" | 86 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" |
87 #import "ios/chrome/browser/ui/activity_services/share_to_data_builder.h" | 87 #import "ios/chrome/browser/ui/activity_services/share_to_data_builder.h" |
88 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" | 88 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" |
89 #import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" | 89 #import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" |
90 #import "ios/chrome/browser/ui/background_generator.h" | 90 #import "ios/chrome/browser/ui/background_generator.h" |
91 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" | 91 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" |
92 #import "ios/chrome/browser/ui/browser_container_view.h" | 92 #import "ios/chrome/browser/ui/browser_container_view.h" |
93 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" | 93 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" |
94 #import "ios/chrome/browser/ui/chrome_web_view_factory.h" | 94 #import "ios/chrome/browser/ui/chrome_web_view_factory.h" |
95 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 95 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 96 #import "ios/chrome/browser/ui/commands/browser_commands.h" |
96 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 97 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
97 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 98 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
98 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 99 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
99 #import "ios/chrome/browser/ui/commands/reading_list_add_command.h" | 100 #import "ios/chrome/browser/ui/commands/reading_list_add_command.h" |
100 #import "ios/chrome/browser/ui/commands/show_mail_composer_command.h" | 101 #import "ios/chrome/browser/ui/commands/show_mail_composer_command.h" |
101 #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" | 102 #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" |
102 #import "ios/chrome/browser/ui/contextual_search/contextual_search_controller.h" | 103 #import "ios/chrome/browser/ui/contextual_search/contextual_search_controller.h" |
103 #import "ios/chrome/browser/ui/contextual_search/contextual_search_mask_view.h" | 104 #import "ios/chrome/browser/ui/contextual_search/contextual_search_mask_view.h" |
104 #import "ios/chrome/browser/ui/contextual_search/contextual_search_metrics.h" | 105 #import "ios/chrome/browser/ui/contextual_search/contextual_search_metrics.h" |
105 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_protoco
ls.h" | 106 #import "ios/chrome/browser/ui/contextual_search/contextual_search_panel_protoco
ls.h" |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 _dialogPresenter = [[DialogPresenter alloc] initWithDelegate:self | 952 _dialogPresenter = [[DialogPresenter alloc] initWithDelegate:self |
952 presentingViewController:self]; | 953 presentingViewController:self]; |
953 _dispatcher = [[CommandDispatcher alloc] init]; | 954 _dispatcher = [[CommandDispatcher alloc] init]; |
954 [_dispatcher startDispatchingToTarget:self | 955 [_dispatcher startDispatchingToTarget:self |
955 forProtocol:@protocol(UrlLoader)]; | 956 forProtocol:@protocol(UrlLoader)]; |
956 [_dispatcher startDispatchingToTarget:self | 957 [_dispatcher startDispatchingToTarget:self |
957 forProtocol:@protocol(WebToolbarDelegate)]; | 958 forProtocol:@protocol(WebToolbarDelegate)]; |
958 [_dispatcher startDispatchingToTarget:self | 959 [_dispatcher startDispatchingToTarget:self |
959 forSelector:@selector(chromeExecuteCommand:)]; | 960 forSelector:@selector(chromeExecuteCommand:)]; |
960 | 961 |
| 962 [_dispatcher startDispatchingToTarget:self |
| 963 forProtocol:@protocol(BrowserCommands)]; |
| 964 |
961 _javaScriptDialogPresenter.reset( | 965 _javaScriptDialogPresenter.reset( |
962 new JavaScriptDialogPresenterImpl(_dialogPresenter)); | 966 new JavaScriptDialogPresenterImpl(_dialogPresenter)); |
963 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); | 967 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); |
964 // TODO(leng): Delay this. | 968 // TODO(leng): Delay this. |
965 [[UpgradeCenter sharedInstance] registerClient:self]; | 969 [[UpgradeCenter sharedInstance] registerClient:self]; |
966 _inNewTabAnimation = NO; | 970 _inNewTabAnimation = NO; |
967 if (model && browserState) | 971 if (model && browserState) |
968 [self updateWithTabModel:model browserState:browserState]; | 972 [self updateWithTabModel:model browserState:browserState]; |
969 if ([[NSUserDefaults standardUserDefaults] | 973 if ([[NSUserDefaults standardUserDefaults] |
970 boolForKey:@"fullScreenShowAlert"]) { | 974 boolForKey:@"fullScreenShowAlert"]) { |
(...skipping 20 matching lines...) Expand all Loading... |
991 | 995 |
992 #pragma mark - Accessibility | 996 #pragma mark - Accessibility |
993 | 997 |
994 - (BOOL)accessibilityPerformEscape { | 998 - (BOOL)accessibilityPerformEscape { |
995 [self dismissPopups]; | 999 [self dismissPopups]; |
996 return YES; | 1000 return YES; |
997 } | 1001 } |
998 | 1002 |
999 #pragma mark - Properties | 1003 #pragma mark - Properties |
1000 | 1004 |
| 1005 - (id<BrowserCommands>)browserCommandDispatcher { |
| 1006 return static_cast<id<BrowserCommands>>(_dispatcher); |
| 1007 } |
| 1008 |
1001 - (void)setActive:(BOOL)active { | 1009 - (void)setActive:(BOOL)active { |
1002 if (_active == active) { | 1010 if (_active == active) { |
1003 return; | 1011 return; |
1004 } | 1012 } |
1005 _active = active; | 1013 _active = active; |
1006 | 1014 |
1007 // If not active, display an activity indicator overlay over the view to | 1015 // If not active, display an activity indicator overlay over the view to |
1008 // prevent interaction with the web page. | 1016 // prevent interaction with the web page. |
1009 // TODO(crbug.com/637093): This coordinator should be managed by the | 1017 // TODO(crbug.com/637093): This coordinator should be managed by the |
1010 // coordinator used to present BrowserViewController, when implemented. | 1018 // coordinator used to present BrowserViewController, when implemented. |
(...skipping 1951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 | 2970 |
2963 #pragma mark - OverscrollActionsControllerDelegate methods. | 2971 #pragma mark - OverscrollActionsControllerDelegate methods. |
2964 | 2972 |
2965 - (void)overscrollActionsController:(OverscrollActionsController*)controller | 2973 - (void)overscrollActionsController:(OverscrollActionsController*)controller |
2966 didTriggerAction:(OverscrollAction)action { | 2974 didTriggerAction:(OverscrollAction)action { |
2967 switch (action) { | 2975 switch (action) { |
2968 case OverscrollAction::NEW_TAB: | 2976 case OverscrollAction::NEW_TAB: |
2969 [self newTab:nil]; | 2977 [self newTab:nil]; |
2970 break; | 2978 break; |
2971 case OverscrollAction::CLOSE_TAB: | 2979 case OverscrollAction::CLOSE_TAB: |
2972 [self closeCurrentTab]; | 2980 [self.browserCommandDispatcher closeCurrentTab]; |
2973 break; | 2981 break; |
2974 case OverscrollAction::REFRESH: { | 2982 case OverscrollAction::REFRESH: { |
2975 if ([[[_model currentTab] webController] loadPhase] == | 2983 if ([[[_model currentTab] webController] loadPhase] == |
2976 web::PAGE_LOADING) { | 2984 web::PAGE_LOADING) { |
2977 [_model currentTab].webState->Stop(); | 2985 [_model currentTab].webState->Stop(); |
2978 } | 2986 } |
2979 | 2987 |
2980 web::WebState* webState = [_model currentTab].webState; | 2988 web::WebState* webState = [_model currentTab].webState; |
2981 if (webState) | 2989 if (webState) |
2982 // |check_for_repost| is true because the reload is explicitly initiated | 2990 // |check_for_repost| is true because the reload is explicitly initiated |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3699 [_toolbarController focusOmnibox]; | 3707 [_toolbarController focusOmnibox]; |
3700 } | 3708 } |
3701 | 3709 |
3702 #pragma mark - UIResponder | 3710 #pragma mark - UIResponder |
3703 | 3711 |
3704 - (NSArray*)keyCommands { | 3712 - (NSArray*)keyCommands { |
3705 if (![self shouldRegisterKeyboardCommands]) { | 3713 if (![self shouldRegisterKeyboardCommands]) { |
3706 return nil; | 3714 return nil; |
3707 } | 3715 } |
3708 return [self.keyCommandsProvider | 3716 return [self.keyCommandsProvider |
3709 keyCommandsForConsumer:self | 3717 keyCommandsForConsumer:self |
3710 editingText:![self isFirstResponder]]; | 3718 browserCommandDispatcher:self.browserCommandDispatcher |
| 3719 editingText:![self isFirstResponder]]; |
3711 } | 3720 } |
3712 | 3721 |
3713 #pragma mark - | 3722 #pragma mark - |
3714 | 3723 |
3715 // Induce an intentional crash in the browser process. | 3724 // Induce an intentional crash in the browser process. |
3716 - (void)induceBrowserCrash { | 3725 - (void)induceBrowserCrash { |
3717 CHECK(false); | 3726 CHECK(false); |
3718 // Call another function, so that the above CHECK can't be tail-call | 3727 // Call another function, so that the above CHECK can't be tail-call |
3719 // optimized. This ensures that this method's name will show up in the stack | 3728 // optimized. This ensures that this method's name will show up in the stack |
3720 // for easier identification. | 3729 // for easier identification. |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4017 [[_model currentTab] goBack]; | 4026 [[_model currentTab] goBack]; |
4018 break; | 4027 break; |
4019 case IDC_BOOKMARK_PAGE: | 4028 case IDC_BOOKMARK_PAGE: |
4020 [self initializeBookmarkInteractionController]; | 4029 [self initializeBookmarkInteractionController]; |
4021 [_bookmarkInteractionController | 4030 [_bookmarkInteractionController |
4022 presentBookmarkForTab:[_model currentTab] | 4031 presentBookmarkForTab:[_model currentTab] |
4023 currentlyBookmarked:_toolbarModelIOS->IsCurrentTabBookmarkedByUser() | 4032 currentlyBookmarked:_toolbarModelIOS->IsCurrentTabBookmarkedByUser() |
4024 inView:[_toolbarController bookmarkButtonView] | 4033 inView:[_toolbarController bookmarkButtonView] |
4025 originRect:[_toolbarController bookmarkButtonAnchorRect]]; | 4034 originRect:[_toolbarController bookmarkButtonAnchorRect]]; |
4026 break; | 4035 break; |
4027 case IDC_CLOSE_TAB: | |
4028 [self closeCurrentTab]; | |
4029 break; | |
4030 case IDC_FIND: | 4036 case IDC_FIND: |
4031 [self initFindBarForTab]; | 4037 [self initFindBarForTab]; |
4032 break; | 4038 break; |
4033 case IDC_FIND_NEXT: { | 4039 case IDC_FIND_NEXT: { |
4034 DCHECK(currentTab); | 4040 DCHECK(currentTab); |
4035 // TODO(crbug.com/603524): Reshow find bar if necessary. | 4041 // TODO(crbug.com/603524): Reshow find bar if necessary. |
4036 FindTabHelper::FromWebState(currentTab.webState) | 4042 FindTabHelper::FromWebState(currentTab.webState) |
4037 ->ContinueFinding(FindTabHelper::FORWARD, ^(FindInPageModel* model) { | 4043 ->ContinueFinding(FindTabHelper::FORWARD, ^(FindInPageModel* model) { |
4038 [_findBarController updateResultsCount:model]; | 4044 [_findBarController updateResultsCount:model]; |
4039 }); | 4045 }); |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5221 | 5227 |
5222 - (UIView*)voiceSearchButton { | 5228 - (UIView*)voiceSearchButton { |
5223 return _voiceSearchButton; | 5229 return _voiceSearchButton; |
5224 } | 5230 } |
5225 | 5231 |
5226 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5232 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
5227 return [self currentLogoAnimationControllerOwner]; | 5233 return [self currentLogoAnimationControllerOwner]; |
5228 } | 5234 } |
5229 | 5235 |
5230 @end | 5236 @end |
OLD | NEW |