Commit 5e55f551 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Remove StartVoiceSearchCommand.

The origin view location is now communicated via NamedGuides.

This is patch 1 of a 3-way patch.

Bug: 805123
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I44c595341907b27f81a58b02895746c6cf284250
Reviewed-on: https://chromium-review.googlesource.com/981777
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547766}
parent 148c09b8
......@@ -114,7 +114,6 @@
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/commands/open_url_command.h"
#import "ios/chrome/browser/ui/commands/show_signin_command.h"
#import "ios/chrome/browser/ui/commands/start_voice_search_command.h"
#import "ios/chrome/browser/ui/download/legacy_download_manager_controller.h"
#import "ios/chrome/browser/ui/external_file_remover_factory.h"
#import "ios/chrome/browser/ui/external_file_remover_impl.h"
......@@ -420,7 +419,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// Shows the tab switcher UI.
- (void)showTabSwitcher;
// Starts a voice search on the current BVC.
- (void)startVoiceSearchInCurrentBVCWithOriginView:(UIView*)originView;
- (void)startVoiceSearchInCurrentBVC;
// Dismisses the tab switcher UI without animation into the given model.
- (void)dismissTabSwitcherWithoutAnimationInModel:(TabModel*)tabModel;
// Dismisses |signinInteractionCoordinator|.
......@@ -1414,9 +1413,9 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[self.currentBVC.dispatcher openNewTab:command];
}
- (void)startVoiceSearch:(StartVoiceSearchCommand*)command {
- (void)startVoiceSearch {
if (!_isProcessingTabSwitcherCommand) {
[self startVoiceSearchInCurrentBVCWithOriginView:command.originView];
[self startVoiceSearchInCurrentBVC];
_isProcessingVoiceSearchCommand = YES;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
kExpectedTransitionDurationInNanoSeconds),
......@@ -1426,6 +1425,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
}
}
- (void)startVoiceSearch:(StartVoiceSearchCommand*)command {
[self startVoiceSearch];
}
- (void)showHistory {
if (experimental_flags::IsCollectionsUIRebootEnabled()) {
// New History UIReboot coordinator.
......@@ -1674,15 +1677,15 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
[self closeSettingsAnimated:YES completion:completion];
}
- (void)startVoiceSearchInCurrentBVCWithOriginView:(UIView*)originView {
- (void)startVoiceSearchInCurrentBVC {
// If the background (non-current) BVC is playing TTS audio, call
// -startVoiceSearch on it to stop the TTS.
BrowserViewController* backgroundBVC =
self.mainBVC == self.currentBVC ? self.otrBVC : self.mainBVC;
if (backgroundBVC.playingTTS)
[backgroundBVC startVoiceSearchWithOriginView:originView];
[backgroundBVC startVoiceSearch];
else
[self.currentBVC startVoiceSearchWithOriginView:originView];
[self.currentBVC startVoiceSearch];
}
#pragma mark - Preferences Management
......@@ -2185,7 +2188,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
case START_VOICE_SEARCH:
if (@available(iOS 11, *)) {
return ^{
[self startVoiceSearchInCurrentBVCWithOriginView:nil];
[self startVoiceSearchInCurrentBVC];
};
} else {
return ^{
......@@ -2201,8 +2204,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// TODO(crbug.com/766951): remove this workaround.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 100 * NSEC_PER_MSEC),
dispatch_get_main_queue(), ^{
[self
startVoiceSearchInCurrentBVCWithOriginView:nil];
[self startVoiceSearchInCurrentBVC];
});
};
......
......@@ -137,9 +137,8 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint
// related to showing the previously selected tab.
- (void)expectNewForegroundTab;
// Shows the voice search UI. |originView|'s center is used for the presentation
// and dismissal animations of the Voice Search UI. |originView| can be nil.
- (void)startVoiceSearchWithOriginView:(UIView*)originView;
// Shows the voice search UI.
- (void)startVoiceSearch;
// Dismisses all presented views, excluding the omnibox if |dismissOmnibox| is
// NO, then calls |completion|.
......
......@@ -136,7 +136,6 @@
#import "ios/chrome/browser/ui/commands/reading_list_add_command.h"
#import "ios/chrome/browser/ui/commands/show_signin_command.h"
#import "ios/chrome/browser/ui/commands/snackbar_commands.h"
#import "ios/chrome/browser/ui/commands/start_voice_search_command.h"
#import "ios/chrome/browser/ui/commands/toolbar_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h"
......@@ -558,9 +557,6 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Notifies the toolbar menu of reading list changes.
ReadingListMenuNotifier* _readingListMenuNotifier;
// The view used by the voice search presentation animation.
__weak UIView* _voiceSearchButton;
// Coordinator for the share menu (Activity Services).
ActivityServiceLegacyCoordinator* _activityServiceCoordinator;
......@@ -1453,8 +1449,7 @@ applicationCommandEndpoint:(id<ApplicationCommands>)applicationCommandEndpoint {
_expectingForegroundTab = YES;
}
- (void)startVoiceSearchWithOriginView:(UIView*)originView {
_voiceSearchButton = originView;
- (void)startVoiceSearch {
// Delay Voice Search until new tab animations have finished.
if (self.inNewTabAnimation) {
_startVoiceSearchAfterNewTabAnimation = YES;
......@@ -4974,7 +4969,7 @@ bubblePresenterForFeature:(const base::Feature&)feature
ProceduralBlock startVoiceSearchIfNecessaryBlock = ^void() {
if (_startVoiceSearchAfterNewTabAnimation) {
_startVoiceSearchAfterNewTabAnimation = NO;
[self startVoiceSearchWithOriginView:nil];
[self startVoiceSearch];
}
};
......@@ -5426,10 +5421,6 @@ bubblePresenterForFeature:(const base::Feature&)feature
#pragma mark - VoiceSearchPresenter (Public)
- (UIView*)voiceSearchButton {
return _voiceSearchButton;
}
- (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
return [self currentLogoAnimationControllerOwner];
}
......
......@@ -64,6 +64,9 @@
- (void)switchModesAndOpenNewTab:(OpenNewTabCommand*)newTabCommand;
// Starts a voice search on the current BVC.
- (void)startVoiceSearch;
// Deprecated |-startVoiceSearchCommand|.
// TODO(crbug.com/805123): Remove this command.
- (void)startVoiceSearch:(StartVoiceSearchCommand*)command;
// Shows the History UI.
......
......@@ -11,7 +11,6 @@
#import "ios/chrome/browser/ui/UIView+SizeClassSupport.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#include "ios/chrome/browser/ui/commands/start_voice_search_command.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_synchronizing.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h"
......@@ -366,9 +365,7 @@ const UIEdgeInsets kSearchBoxStretchInsets = {3, 3, 3, 3};
UIView* voiceSearchButton = base::mac::ObjCCastStrict<UIView>(sender);
[NamedGuide guideWithName:kVoiceSearchButtonGuide view:voiceSearchButton]
.constrainedView = voiceSearchButton;
StartVoiceSearchCommand* command =
[[StartVoiceSearchCommand alloc] initWithOriginView:voiceSearchButton];
[self.dispatcher startVoiceSearch:command];
[self.dispatcher startVoiceSearch];
}
- (void)preloadVoiceSearch:(id)sender {
......
......@@ -7,7 +7,6 @@
#include "base/logging.h"
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#include "ios/chrome/browser/ui/commands/start_voice_search_command.h"
#import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h"
#include "ios/chrome/browser/ui/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
......@@ -203,10 +202,7 @@ keyCommandsForConsumer:(id<KeyCommandsPlumbing>)consumer
[[NamedGuide guideWithName:kVoiceSearchButtonGuide
view:baseView]
resetConstraints];
StartVoiceSearchCommand* command =
[[StartVoiceSearchCommand alloc]
initWithOriginView:nil];
[weakDispatcher startVoiceSearch:command];
[weakDispatcher startVoiceSearch];
}],
]];
}
......
......@@ -10,7 +10,6 @@
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/history_popup_commands.h"
#import "ios/chrome/browser/ui/commands/start_voice_search_command.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_foreground_animator.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_scroll_end_animator.h"
......@@ -658,9 +657,7 @@ const CGFloat kScrollFadeDistance = 30;
UIView* view = base::mac::ObjCCastStrict<UIView>(sender);
[NamedGuide guideWithName:kVoiceSearchButtonGuide view:view].constrainedView =
view;
StartVoiceSearchCommand* command =
[[StartVoiceSearchCommand alloc] initWithOriginView:view];
[self.dispatcher startVoiceSearch:command];
[self.dispatcher startVoiceSearch];
}
// Sets all Toolbar Buttons opacity to |alpha|.
......
......@@ -9,7 +9,6 @@
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/external_search_commands.h"
#import "ios/chrome/browser/ui/commands/start_voice_search_command.h"
#import "ios/chrome/browser/ui/location_bar/location_bar_constants.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h"
#import "ios/chrome/browser/ui/util/named_guide.h"
......@@ -56,9 +55,7 @@
CGRectGetHeight(frame);
self.voiceSearchButtonGuide.constrainedFrame = frame;
}
StartVoiceSearchCommand* command =
[[StartVoiceSearchCommand alloc] initWithOriginView:view];
[self.dispatcher startVoiceSearch:command];
[self.dispatcher startVoiceSearch];
}
}
......
......@@ -10,11 +10,7 @@
#import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h"
// Protocol used by UIViewControllers that present VoiceSearch.
@protocol VoiceSearchPresenter<LogoAnimationControllerOwnerOwner, NSObject>
// The button that was tapped in order to trigger VoiceSearch.
@property(nonatomic, readonly) UIView* voiceSearchButton;
@protocol VoiceSearchPresenter<LogoAnimationControllerOwnerOwner>
@end
#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_VOICE_VOICE_SEARCH_PRESENTER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment