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 4025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4036 - (void)reload { | 4036 - (void)reload { |
4037 web::WebState* webState = [_model currentTab].webState; | 4037 web::WebState* webState = [_model currentTab].webState; |
4038 if (webState) { | 4038 if (webState) { |
4039 // |check_for_repost| is true because the reload is explicitly initiated | 4039 // |check_for_repost| is true because the reload is explicitly initiated |
4040 // by the user. | 4040 // by the user. |
4041 webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL, | 4041 webState->GetNavigationManager()->Reload(web::ReloadType::NORMAL, |
4042 true /* check_for_repost */); | 4042 true /* check_for_repost */); |
4043 } | 4043 } |
4044 } | 4044 } |
4045 | 4045 |
| 4046 - (void)sharePage { |
| 4047 ShareToData* data = activity_services::ShareToDataForTab([_model currentTab]); |
| 4048 if (data) |
| 4049 [self sharePageWithData:data]; |
| 4050 } |
| 4051 |
| 4052 - (void)bookmarkPage { |
| 4053 [self initializeBookmarkInteractionController]; |
| 4054 [_bookmarkInteractionController |
| 4055 presentBookmarkForTab:[_model currentTab] |
| 4056 currentlyBookmarked:_toolbarModelIOS->IsCurrentTabBookmarkedByUser() |
| 4057 inView:[_toolbarController bookmarkButtonView] |
| 4058 originRect:[_toolbarController bookmarkButtonAnchorRect]]; |
| 4059 } |
| 4060 |
4046 #pragma mark - Command Handling | 4061 #pragma mark - Command Handling |
4047 | 4062 |
4048 - (IBAction)chromeExecuteCommand:(id)sender { | 4063 - (IBAction)chromeExecuteCommand:(id)sender { |
4049 NSInteger command = [sender tag]; | 4064 NSInteger command = [sender tag]; |
4050 | 4065 |
4051 if (!_model || !_browserState) | 4066 if (!_model || !_browserState) |
4052 return; | 4067 return; |
4053 Tab* currentTab = [_model currentTab]; | 4068 Tab* currentTab = [_model currentTab]; |
4054 | 4069 |
4055 switch (command) { | 4070 switch (command) { |
4056 case IDC_BOOKMARK_PAGE: | |
4057 [self initializeBookmarkInteractionController]; | |
4058 [_bookmarkInteractionController | |
4059 presentBookmarkForTab:[_model currentTab] | |
4060 currentlyBookmarked:_toolbarModelIOS->IsCurrentTabBookmarkedByUser() | |
4061 inView:[_toolbarController bookmarkButtonView] | |
4062 originRect:[_toolbarController bookmarkButtonAnchorRect]]; | |
4063 break; | |
4064 case IDC_FIND: | 4071 case IDC_FIND: |
4065 [self initFindBarForTab]; | 4072 [self initFindBarForTab]; |
4066 break; | 4073 break; |
4067 case IDC_FIND_NEXT: { | 4074 case IDC_FIND_NEXT: { |
4068 DCHECK(currentTab); | 4075 DCHECK(currentTab); |
4069 // TODO(crbug.com/603524): Reshow find bar if necessary. | 4076 // TODO(crbug.com/603524): Reshow find bar if necessary. |
4070 FindTabHelper::FromWebState(currentTab.webState) | 4077 FindTabHelper::FromWebState(currentTab.webState) |
4071 ->ContinueFinding(FindTabHelper::FORWARD, ^(FindInPageModel* model) { | 4078 ->ContinueFinding(FindTabHelper::FORWARD, ^(FindInPageModel* model) { |
4072 [_findBarController updateResultsCount:model]; | 4079 [_findBarController updateResultsCount:model]; |
4073 }); | 4080 }); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4109 _voiceSearchController->PrepareToAppear(); | 4116 _voiceSearchController->PrepareToAppear(); |
4110 break; | 4117 break; |
4111 case IDC_NEW_INCOGNITO_TAB: | 4118 case IDC_NEW_INCOGNITO_TAB: |
4112 if (_isOffTheRecord) { | 4119 if (_isOffTheRecord) { |
4113 [self newTab:sender]; | 4120 [self newTab:sender]; |
4114 } else { | 4121 } else { |
4115 // Not for this browser state, send it on its way. | 4122 // Not for this browser state, send it on its way. |
4116 [super chromeExecuteCommand:sender]; | 4123 [super chromeExecuteCommand:sender]; |
4117 } | 4124 } |
4118 break; | 4125 break; |
| 4126 |
4119 case IDC_RELOAD: { | 4127 case IDC_RELOAD: { |
4120 // Route to dispatcher until downstream code is migrated. | 4128 // Route to dispatcher until downstream code is migrated. |
4121 [self.browserCommandDispatcher reload]; | 4129 [self.browserCommandDispatcher reload]; |
4122 break; | 4130 break; |
4123 } | 4131 } |
4124 case IDC_SHARE_PAGE: | |
4125 [self sharePage]; | |
4126 break; | |
4127 case IDC_SHOW_MAIL_COMPOSER: | 4132 case IDC_SHOW_MAIL_COMPOSER: |
4128 [self showMailComposer:sender]; | 4133 [self showMailComposer:sender]; |
4129 break; | 4134 break; |
4130 case IDC_READER_MODE: | 4135 case IDC_READER_MODE: |
4131 [[_model currentTab] switchToReaderMode]; | 4136 [[_model currentTab] switchToReaderMode]; |
4132 break; | 4137 break; |
4133 case IDC_REQUEST_DESKTOP_SITE: | 4138 case IDC_REQUEST_DESKTOP_SITE: |
4134 [[_model currentTab] reloadWithUserAgentType:web::UserAgentType::DESKTOP]; | 4139 [[_model currentTab] reloadWithUserAgentType:web::UserAgentType::DESKTOP]; |
4135 break; | 4140 break; |
4136 case IDC_REQUEST_MOBILE_SITE: | 4141 case IDC_REQUEST_MOBILE_SITE: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4240 // Do not animate close in iPad. | 4245 // Do not animate close in iPad. |
4241 if (!IsIPadIdiom()) { | 4246 if (!IsIPadIdiom()) { |
4242 [_contentArea addSubview:exitingPage]; | 4247 [_contentArea addSubview:exitingPage]; |
4243 ios_internal::page_animation_util::AnimateOutWithCompletion( | 4248 ios_internal::page_animation_util::AnimateOutWithCompletion( |
4244 exitingPage, 0, YES, IsPortrait(), ^{ | 4249 exitingPage, 0, YES, IsPortrait(), ^{ |
4245 [exitingPage removeFromSuperview]; | 4250 [exitingPage removeFromSuperview]; |
4246 }); | 4251 }); |
4247 } | 4252 } |
4248 } | 4253 } |
4249 | 4254 |
4250 - (void)sharePage { | |
4251 ShareToData* data = activity_services::ShareToDataForTab([_model currentTab]); | |
4252 if (data) | |
4253 [self sharePageWithData:data]; | |
4254 } | |
4255 | 4255 |
4256 - (void)sharePageWithData:(ShareToData*)data { | 4256 - (void)sharePageWithData:(ShareToData*)data { |
4257 id<ShareProtocol> controller = [_dependencyFactory shareControllerInstance]; | 4257 id<ShareProtocol> controller = [_dependencyFactory shareControllerInstance]; |
4258 if ([controller isActive]) | 4258 if ([controller isActive]) |
4259 return; | 4259 return; |
4260 CGRect fromRect = [_toolbarController shareButtonAnchorRect]; | 4260 CGRect fromRect = [_toolbarController shareButtonAnchorRect]; |
4261 UIView* inView = [_toolbarController shareButtonView]; | 4261 UIView* inView = [_toolbarController shareButtonView]; |
4262 [controller shareWithData:data | 4262 [controller shareWithData:data |
4263 controller:self | 4263 controller:self |
4264 browserState:_browserState | 4264 browserState:_browserState |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5245 | 5245 |
5246 - (UIView*)voiceSearchButton { | 5246 - (UIView*)voiceSearchButton { |
5247 return _voiceSearchButton; | 5247 return _voiceSearchButton; |
5248 } | 5248 } |
5249 | 5249 |
5250 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5250 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
5251 return [self currentLogoAnimationControllerOwner]; | 5251 return [self currentLogoAnimationControllerOwner]; |
5252 } | 5252 } |
5253 | 5253 |
5254 @end | 5254 @end |
OLD | NEW |