Commit 9065a2a2 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Create separate text zoom command protocol

This separate protocol is in preparation for moving the text zoom
coordinator usage code from BVC to BrowserCoordinator. Once there's a
separate protocol, the BrowserCoordinator can implement it instead of
the BVC.

Bug: 1052818
Change-Id: I5215864219a8419e4bb170bff3a89b31f3a80c41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062997
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742601}
parent c6993a03
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#import "ios/chrome/browser/ui/commands/reading_list_add_command.h" #import "ios/chrome/browser/ui/commands/reading_list_add_command.h"
#import "ios/chrome/browser/ui/commands/send_tab_to_self_command.h" #import "ios/chrome/browser/ui/commands/send_tab_to_self_command.h"
#import "ios/chrome/browser/ui/commands/show_signin_command.h" #import "ios/chrome/browser/ui/commands/show_signin_command.h"
#import "ios/chrome/browser/ui/commands/text_zoom_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h" #import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" #import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h"
#import "ios/chrome/browser/ui/dialogs/dialog_features.h" #import "ios/chrome/browser/ui/dialogs/dialog_features.h"
...@@ -747,6 +748,9 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -747,6 +748,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
[self.commandDispatcher [self.commandDispatcher
startDispatchingToTarget:self startDispatchingToTarget:self
forProtocol:@protocol(FindInPageCommands)]; forProtocol:@protocol(FindInPageCommands)];
[self.commandDispatcher
startDispatchingToTarget:self
forProtocol:@protocol(TextZoomCommands)];
[self.commandDispatcher [self.commandDispatcher
startDispatchingToTarget:applicationCommandEndpoint startDispatchingToTarget:applicationCommandEndpoint
forProtocol:@protocol(ApplicationCommands)]; forProtocol:@protocol(ApplicationCommands)];
......
...@@ -30,6 +30,7 @@ source_set("commands") { ...@@ -30,6 +30,7 @@ source_set("commands") {
"show_signin_command.h", "show_signin_command.h",
"show_signin_command.mm", "show_signin_command.mm",
"snackbar_commands.h", "snackbar_commands.h",
"text_zoom_commands.h",
"toolbar_commands.h", "toolbar_commands.h",
] ]
......
...@@ -100,12 +100,6 @@ class GURL; ...@@ -100,12 +100,6 @@ class GURL;
// prevent interaction with the web page. // prevent interaction with the web page.
- (void)showActivityOverlay:(BOOL)show; - (void)showActivityOverlay:(BOOL)show;
// Shows the Text Zoom UI.
- (void)showTextZoom;
// Dismisses the Text Zoom UI.
- (void)hideTextZoom;
@end @end
#endif // IOS_CHROME_BROWSER_UI_COMMANDS_BROWSER_COMMANDS_H_ #endif // IOS_CHROME_BROWSER_UI_COMMANDS_BROWSER_COMMANDS_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_COMMANDS_TEXT_ZOOM_COMMANDS_H_
#define IOS_CHROME_BROWSER_UI_COMMANDS_TEXT_ZOOM_COMMANDS_H_
@protocol TextZoomCommands <NSObject>
// Shows the Text Zoom UI.
- (void)showTextZoom;
// Dismisses the Text Zoom UI.
- (void)hideTextZoom;
@end
#endif // IOS_CHROME_BROWSER_UI_COMMANDS_TEXT_ZOOM_COMMANDS_H_
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
@property(nonatomic, strong) FindBarMediator* mediator; @property(nonatomic, strong) FindBarMediator* mediator;
// Allows simplified access to the FindInPageCommands handler.
@property(nonatomic, readonly) id<FindInPageCommands> findInPageCommandHandler;
@end @end
@implementation FindBarCoordinator @implementation FindBarCoordinator
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
@protocol FindInPageCommands; @protocol FindInPageCommands;
@protocol LoadQueryCommands; @protocol LoadQueryCommands;
@protocol PopupMenuActionHandlerCommands; @protocol PopupMenuActionHandlerCommands;
@protocol TextZoomCommands;
// Handles user interactions with the popup menu. // Handles user interactions with the popup menu.
@interface PopupMenuActionHandler @interface PopupMenuActionHandler
...@@ -29,7 +30,8 @@ ...@@ -29,7 +30,8 @@
@property(nonatomic, weak) id<ApplicationCommands, @property(nonatomic, weak) id<ApplicationCommands,
BrowserCommands, BrowserCommands,
FindInPageCommands, FindInPageCommands,
LoadQueryCommands> LoadQueryCommands,
TextZoomCommands>
dispatcher; dispatcher;
@end @end
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "ios/chrome/browser/ui/commands/find_in_page_commands.h" #import "ios/chrome/browser/ui/commands/find_in_page_commands.h"
#import "ios/chrome/browser/ui/commands/load_query_commands.h" #import "ios/chrome/browser/ui/commands/load_query_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h" #import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/commands/text_zoom_commands.h"
#import "ios/chrome/browser/ui/page_info/features.h" #import "ios/chrome/browser/ui/page_info/features.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_commands.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_commands.h"
#import "ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h" #import "ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h"
......
...@@ -251,7 +251,8 @@ PopupMenuCommandType CommandTypeFromPopupType(PopupMenuType type) { ...@@ -251,7 +251,8 @@ PopupMenuCommandType CommandTypeFromPopupType(PopupMenuType type) {
self.actionHandler.baseViewController = self.baseViewController; self.actionHandler.baseViewController = self.baseViewController;
self.actionHandler.dispatcher = self.actionHandler.dispatcher =
static_cast<id<ApplicationCommands, BrowserCommands, FindInPageCommands, static_cast<id<ApplicationCommands, BrowserCommands, FindInPageCommands,
LoadQueryCommands>>(self.browser->GetCommandDispatcher()); LoadQueryCommands, TextZoomCommands>>(
self.browser->GetCommandDispatcher());
self.actionHandler.commandHandler = self.mediator; self.actionHandler.commandHandler = self.mediator;
tableViewController.delegate = self.actionHandler; tableViewController.delegate = self.actionHandler;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h" #import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/commands/text_zoom_commands.h"
#include "ios/chrome/browser/ui/presenters/contained_presenter_delegate.h" #include "ios/chrome/browser/ui/presenters/contained_presenter_delegate.h"
#import "ios/chrome/browser/ui/text_zoom/text_zoom_mediator.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_mediator.h"
#import "ios/chrome/browser/ui/text_zoom/text_zoom_view_controller.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_view_controller.h"
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
@property(nonatomic, strong) TextZoomMediator* mediator; @property(nonatomic, strong) TextZoomMediator* mediator;
// Allows simplified access to the TextZoomCommands handler.
@property(nonatomic, readonly) id<TextZoomCommands> textZoomCommandHandler;
@end @end
@implementation TextZoomCoordinator @implementation TextZoomCoordinator
...@@ -41,14 +44,11 @@ ...@@ -41,14 +44,11 @@
self.mediator = [[TextZoomMediator alloc] self.mediator = [[TextZoomMediator alloc]
initWithWebStateList:self.browser->GetWebStateList() initWithWebStateList:self.browser->GetWebStateList()
commandHandler:HandlerForProtocol( commandHandler:self.textZoomCommandHandler];
self.browser->GetCommandDispatcher(),
BrowserCommands)];
self.textZoomViewController = [[TextZoomViewController alloc] self.textZoomViewController = [[TextZoomViewController alloc]
initWithDarkAppearance:self.browserState->IsOffTheRecord()]; initWithDarkAppearance:self.browserState->IsOffTheRecord()];
self.textZoomViewController.commandHandler = self.textZoomViewController.commandHandler = self.textZoomCommandHandler;
HandlerForProtocol(self.browser->GetCommandDispatcher(), BrowserCommands);
self.textZoomViewController.zoomHandler = self.mediator; self.textZoomViewController.zoomHandler = self.mediator;
self.mediator.consumer = self.textZoomViewController; self.mediator.consumer = self.textZoomViewController;
...@@ -77,4 +77,11 @@ ...@@ -77,4 +77,11 @@
[self.delegate toolbarAccessoryCoordinatorDidDismissUI:self]; [self.delegate toolbarAccessoryCoordinatorDidDismissUI:self];
} }
#pragma mark - Private
- (id<TextZoomCommands>)textZoomCommandHandler {
return HandlerForProtocol(self.browser->GetCommandDispatcher(),
TextZoomCommands);
}
@end @end
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "ios/chrome/browser/ui/text_zoom/text_zoom_view_controller.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_view_controller.h"
@protocol TextZoomCommands;
@protocol TextZoomConsumer; @protocol TextZoomConsumer;
class WebStateList; class WebStateList;
...@@ -17,7 +18,7 @@ class WebStateList; ...@@ -17,7 +18,7 @@ class WebStateList;
@property(nonatomic, weak) id<TextZoomConsumer> consumer; @property(nonatomic, weak) id<TextZoomConsumer> consumer;
- (instancetype)initWithWebStateList:(WebStateList*)webStateList - (instancetype)initWithWebStateList:(WebStateList*)webStateList
commandHandler:(id<BrowserCommands>)commandHandler commandHandler:(id<TextZoomCommands>)commandHandler
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#import "ios/chrome/browser/ui/text_zoom/text_zoom_mediator.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_mediator.h"
#import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/text_zoom_commands.h"
#import "ios/chrome/browser/ui/text_zoom/text_zoom_consumer.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_consumer.h"
#import "ios/chrome/browser/web/font_size_tab_helper.h" #import "ios/chrome/browser/web/font_size_tab_helper.h"
#import "ios/chrome/browser/web_state_list/active_web_state_observation_forwarder.h" #import "ios/chrome/browser/web_state_list/active_web_state_observation_forwarder.h"
...@@ -31,15 +31,15 @@ ...@@ -31,15 +31,15 @@
// The active WebState's font size tab helper. // The active WebState's font size tab helper.
@property(nonatomic, readonly) FontSizeTabHelper* fontSizeTabHelper; @property(nonatomic, readonly) FontSizeTabHelper* fontSizeTabHelper;
// Handler for any BrowserCommands. // Handler for any TextZoomCommands.
@property(nonatomic, weak) id<BrowserCommands> commandHandler; @property(nonatomic, weak) id<TextZoomCommands> commandHandler;
@end @end
@implementation TextZoomMediator @implementation TextZoomMediator
- (instancetype)initWithWebStateList:(WebStateList*)webStateList - (instancetype)initWithWebStateList:(WebStateList*)webStateList
commandHandler:(id<BrowserCommands>)commandHandler { commandHandler:(id<TextZoomCommands>)commandHandler {
self = [super init]; self = [super init];
if (self) { if (self) {
_commandHandler = commandHandler; _commandHandler = commandHandler;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "ios/chrome/browser/ui/text_zoom/text_zoom_consumer.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_consumer.h"
@protocol BrowserCommands; @protocol TextZoomCommands;
@class TextZoomViewController; @class TextZoomViewController;
@protocol TextZoomHandler <NSObject> @protocol TextZoomHandler <NSObject>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE; bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE; - (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE;
@property(nonatomic, weak) id<BrowserCommands> commandHandler; @property(nonatomic, weak) id<TextZoomCommands> commandHandler;
@property(nonatomic, weak) id<TextZoomHandler> zoomHandler; @property(nonatomic, weak) id<TextZoomHandler> zoomHandler;
@end @end
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/text_zoom_commands.h"
#import "ios/chrome/browser/ui/text_zoom/text_zoom_constants.h" #import "ios/chrome/browser/ui/text_zoom/text_zoom_constants.h"
#import "ios/chrome/common/colors/dynamic_color_util.h" #import "ios/chrome/common/colors/dynamic_color_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h" #import "ios/chrome/common/colors/semantic_color_names.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