Commit 5ba2cd81 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Simplify public BVC interface.

This CL removes unneeded public API from the BVC, primarily the public
dispatcher property. The NTP perf test and the BVC unit tests were the
remaining places where these dependencies were used.

In addition to the command dispatcher, the public TabModel and
BrowserState properties of the BVC are removed. Some other properties
(FullscreenController, TypingShield) are just moved internally.

The ContentArea property was only used in the BVC unit test, and only
to check that the BVC was attached to the containing view controller.
Since the container is provided to the BVC as well, that can be tested
without using any direct BVC API.

Other minor cleanup:

 - Some BVC includes are pruned.
 - Internally, the protocols that the dispatcher conforms to are
   reduced in number.
 - The internal -shieldWasTapped: method was removed, since
   it just forwarded to the dispatcher.

Change-Id: I2f0ae3382e32867e5aad7a083b8fcbbb384b5c53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135620
Commit-Queue: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757034}
parent b67a50da
...@@ -15,21 +15,9 @@ ...@@ -15,21 +15,9 @@
#import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h" #import "ios/public/provider/chrome/browser/voice/logo_animation_controller.h"
class Browser; class Browser;
class ChromeBrowserState;
class FullscreenController;
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol BrowsingDataCommands;
@class BrowserContainerViewController; @class BrowserContainerViewController;
@class BrowserViewControllerDependencyFactory; @class BrowserViewControllerDependencyFactory;
@protocol FindInPageCommands;
@protocol PasswordBreachCommands;
@protocol PopupMenuCommands;
@protocol FakeboxFocuser;
@protocol SnackbarCommands;
@class TabModel;
@class ToolbarAccessoryPresenter; @class ToolbarAccessoryPresenter;
@protocol ToolbarCommands;
// The top-level view controller for the browser UI. Manages other controllers // The top-level view controller for the browser UI. Manages other controllers
// which implement the interface. // which implement the interface.
...@@ -57,35 +45,9 @@ class FullscreenController; ...@@ -57,35 +45,9 @@ class FullscreenController;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
@property(nonatomic, readonly) id<ApplicationCommands,
BrowserCommands,
BrowsingDataCommands,
FindInPageCommands,
PasswordBreachCommands,
PopupMenuCommands,
FakeboxFocuser,
SnackbarCommands,
ToolbarCommands>
dispatcher;
// The top-level browser container view.
@property(nonatomic, strong, readonly) UIView* contentArea;
// Invisible button used to dismiss the keyboard.
@property(nonatomic, strong) UIButton* typingShield;
// Returns whether or not text to speech is playing. // Returns whether or not text to speech is playing.
@property(nonatomic, assign, readonly, getter=isPlayingTTS) BOOL playingTTS; @property(nonatomic, assign, readonly, getter=isPlayingTTS) BOOL playingTTS;
// The Browser's TabModel.
@property(nonatomic, weak, readonly) TabModel* tabModel;
// The Browser's ChromeBrowserState.
@property(nonatomic, assign, readonly) ChromeBrowserState* browserState;
// The FullscreenController.
@property(nonatomic, assign) FullscreenController* fullscreenController;
// The container used for infobar banner overlays. // The container used for infobar banner overlays.
@property(nonatomic, strong) @property(nonatomic, strong)
UIViewController* infobarBannerOverlayContainerViewController; UIViewController* infobarBannerOverlayContainerViewController;
...@@ -101,9 +63,6 @@ class FullscreenController; ...@@ -101,9 +63,6 @@ class FullscreenController;
// Whether the receiver is currently the primary BVC. // Whether the receiver is currently the primary BVC.
- (void)setPrimary:(BOOL)primary; - (void)setPrimary:(BOOL)primary;
// Called when the typing shield is tapped.
- (void)shieldWasTapped:(id)sender;
// Called when the user explicitly opens the tab switcher. // Called when the user explicitly opens the tab switcher.
- (void)userEnteredTabSwitcher; - (void)userEnteredTabSwitcher;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#import <MessageUI/MessageUI.h> #import <MessageUI/MessageUI.h>
#include "base/base64.h" #include "base/base64.h"
#include "base/ios/ios_util.h"
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
...@@ -17,7 +16,6 @@ ...@@ -17,7 +16,6 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/feature_engagement/public/event_constants.h" #include "components/feature_engagement/public/event_constants.h"
#include "components/feature_engagement/public/tracker.h" #include "components/feature_engagement/public/tracker.h"
#import "components/language/ios/browser/ios_language_detection_tab_helper.h"
#include "components/omnibox/browser/location_bar_model_impl.h" #include "components/omnibox/browser/location_bar_model_impl.h"
#include "components/reading_list/core/reading_list_model.h" #include "components/reading_list/core/reading_list_model.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
...@@ -79,8 +77,8 @@ ...@@ -79,8 +77,8 @@
#import "ios/chrome/browser/ui/browser_view/key_commands_provider.h" #import "ios/chrome/browser/ui/browser_view/key_commands_provider.h"
#import "ios/chrome/browser/ui/bubble/bubble_presenter.h" #import "ios/chrome/browser/ui/bubble/bubble_presenter.h"
#import "ios/chrome/browser/ui/bubble/bubble_presenter_delegate.h" #import "ios/chrome/browser/ui/bubble/bubble_presenter_delegate.h"
#import "ios/chrome/browser/ui/commands/browsing_data_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/help_commands.h"
#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"
...@@ -90,12 +88,10 @@ ...@@ -90,12 +88,10 @@
#import "ios/chrome/browser/ui/dialogs/dialog_features.h" #import "ios/chrome/browser/ui/dialogs/dialog_features.h"
#import "ios/chrome/browser/ui/dialogs/dialog_presenter.h" #import "ios/chrome/browser/ui/dialogs/dialog_presenter.h"
#import "ios/chrome/browser/ui/dialogs/java_script_dialog_presenter_impl.h" #import "ios/chrome/browser/ui/dialogs/java_script_dialog_presenter_impl.h"
#import "ios/chrome/browser/ui/dialogs/overlay_java_script_dialog_presenter.h"
#import "ios/chrome/browser/ui/download/download_manager_coordinator.h" #import "ios/chrome/browser/ui/download/download_manager_coordinator.h"
#import "ios/chrome/browser/ui/elements/activity_overlay_coordinator.h" #import "ios/chrome/browser/ui/elements/activity_overlay_coordinator.h"
#import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h" #import "ios/chrome/browser/ui/first_run/welcome_to_chrome_view_controller.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_animator.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_controller.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_element.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_element.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_updater.h" #import "ios/chrome/browser/ui/fullscreen/fullscreen_ui_updater.h"
...@@ -112,7 +108,6 @@ ...@@ -112,7 +108,6 @@
#import "ios/chrome/browser/ui/ntp/new_tab_page_coordinator.h" #import "ios/chrome/browser/ui/ntp/new_tab_page_coordinator.h"
#import "ios/chrome/browser/ui/ntp/ntp_util.h" #import "ios/chrome/browser/ui/ntp/ntp_util.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_presenter.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_presenter.h"
#import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_coordinator.h"
#import "ios/chrome/browser/ui/presenters/vertical_animation_container.h" #import "ios/chrome/browser/ui/presenters/vertical_animation_container.h"
#import "ios/chrome/browser/ui/sad_tab/sad_tab_coordinator.h" #import "ios/chrome/browser/ui/sad_tab/sad_tab_coordinator.h"
...@@ -126,7 +121,6 @@ ...@@ -126,7 +121,6 @@
#import "ios/chrome/browser/ui/tabs/requirements/tab_strip_presentation.h" #import "ios/chrome/browser/ui/tabs/requirements/tab_strip_presentation.h"
#import "ios/chrome/browser/ui/tabs/switch_to_tab_animation_view.h" #import "ios/chrome/browser/ui/tabs/switch_to_tab_animation_view.h"
#import "ios/chrome/browser/ui/tabs/tab_strip_legacy_coordinator.h" #import "ios/chrome/browser/ui/tabs/tab_strip_legacy_coordinator.h"
#import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_coordinator_delegate.h"
#import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_presenter.h" #import "ios/chrome/browser/ui/toolbar/accessory/toolbar_accessory_presenter.h"
#import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.h" #import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_coordinator.h"
#import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.h" #import "ios/chrome/browser/ui/toolbar/adaptive_toolbar_view_controller.h"
...@@ -140,7 +134,6 @@ ...@@ -140,7 +134,6 @@
#import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_adaptor.h" #import "ios/chrome/browser/ui/toolbar/toolbar_coordinator_adaptor.h"
#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_coordinator.h" #import "ios/chrome/browser/ui/toolbar_container/toolbar_container_coordinator.h"
#import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h" #import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/keyboard_observer_helper.h" #import "ios/chrome/browser/ui/util/keyboard_observer_helper.h"
#import "ios/chrome/browser/ui/util/multi_window_support.h" #import "ios/chrome/browser/ui/util/multi_window_support.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
...@@ -185,10 +178,8 @@ ...@@ -185,10 +178,8 @@
#import "ios/web/public/deprecated/crw_js_injection_receiver.h" #import "ios/web/public/deprecated/crw_js_injection_receiver.h"
#import "ios/web/public/deprecated/crw_web_controller_util.h" #import "ios/web/public/deprecated/crw_web_controller_util.h"
#include "ios/web/public/navigation/navigation_item.h" #include "ios/web/public/navigation/navigation_item.h"
#include "ios/web/public/thread/web_thread.h"
#import "ios/web/public/ui/context_menu_params.h" #import "ios/web/public/ui/context_menu_params.h"
#import "ios/web/public/ui/crw_web_view_proxy.h" #import "ios/web/public/ui/crw_web_view_proxy.h"
#include "ios/web/public/web_client.h"
#import "ios/web/public/web_state_delegate_bridge.h" #import "ios/web/public/web_state_delegate_bridge.h"
#import "ios/web/public/web_state_observer_bridge.h" #import "ios/web/public/web_state_observer_bridge.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -482,6 +473,8 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -482,6 +473,8 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Browser container view controller. // Browser container view controller.
@property(nonatomic, strong) @property(nonatomic, strong)
BrowserContainerViewController* browserContainerViewController; BrowserContainerViewController* browserContainerViewController;
// Invisible button used to dismiss the keyboard.
@property(nonatomic, strong) UIButton* typingShield;
// Command dispatcher. // Command dispatcher.
@property(nonatomic, weak) CommandDispatcher* commandDispatcher; @property(nonatomic, weak) CommandDispatcher* commandDispatcher;
// The browser's side swipe controller. Lazily instantiated on the first call. // The browser's side swipe controller. Lazily instantiated on the first call.
...@@ -551,6 +544,9 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -551,6 +544,9 @@ NSString* const kBrowserViewControllerSnackbarCategory =
// Command handler for omnibox commands // Command handler for omnibox commands
@property(nonatomic, weak) id<OmniboxCommands> omniboxHandler; @property(nonatomic, weak) id<OmniboxCommands> omniboxHandler;
// The FullscreenController.
@property(nonatomic, assign) FullscreenController* fullscreenController;
// Primary toolbar. // Primary toolbar.
@property(nonatomic, strong) @property(nonatomic, strong)
PrimaryToolbarCoordinator* primaryToolbarCoordinator; PrimaryToolbarCoordinator* primaryToolbarCoordinator;
...@@ -789,18 +785,12 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -789,18 +785,12 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (id<ApplicationCommands, - (id<ApplicationCommands,
BrowserCommands, BrowserCommands,
BrowsingDataCommands,
FindInPageCommands, FindInPageCommands,
PasswordBreachCommands, PasswordBreachCommands,
PopupMenuCommands,
FakeboxFocuser,
SnackbarCommands,
ToolbarCommands>)dispatcher { ToolbarCommands>)dispatcher {
return static_cast< return static_cast<
id<ApplicationCommands, BrowserCommands, BrowsingDataCommands, id<ApplicationCommands, BrowserCommands, FindInPageCommands,
FindInPageCommands, PasswordBreachCommands, PopupMenuCommands, PasswordBreachCommands, ToolbarCommands>>(self.commandDispatcher);
FakeboxFocuser, SnackbarCommands, ToolbarCommands>>(
self.commandDispatcher);
} }
- (UIView*)contentArea { - (UIView*)contentArea {
......
...@@ -159,11 +159,10 @@ class BrowserViewControllerTest : public BlockCleanupTest { ...@@ -159,11 +159,10 @@ class BrowserViewControllerTest : public BlockCleanupTest {
chrome_browser_state_.get()); chrome_browser_state_.get());
template_url_service->Load(); template_url_service->Load();
bvc_ = [[BrowserViewController alloc] container_ = [[BrowserContainerViewController alloc] init];
initWithBrowser:browser_.get() bvc_ = [[BrowserViewController alloc] initWithBrowser:browser_.get()
dependencyFactory:factory dependencyFactory:factory
browserContainerViewController:[[BrowserContainerViewController alloc] browserContainerViewController:container_];
init]];
// Force the view to load. // Force the view to load.
UIWindow* window = [[UIWindow alloc] initWithFrame:CGRectZero]; UIWindow* window = [[UIWindow alloc] initWithFrame:CGRectZero];
...@@ -201,28 +200,17 @@ class BrowserViewControllerTest : public BlockCleanupTest { ...@@ -201,28 +200,17 @@ class BrowserViewControllerTest : public BlockCleanupTest {
PKAddPassesViewController* passKitViewController_; PKAddPassesViewController* passKitViewController_;
OCMockObject* dependencyFactory_; OCMockObject* dependencyFactory_;
CommandDispatcher* command_dispatcher_; CommandDispatcher* command_dispatcher_;
BrowserContainerViewController* container_;
BrowserViewController* bvc_; BrowserViewController* bvc_;
UIWindow* window_; UIWindow* window_;
}; };
TEST_F(BrowserViewControllerTest, TestWebStateSelected) { TEST_F(BrowserViewControllerTest, TestWebStateSelected) {
[bvc_ webStateSelected:ActiveWebState() notifyToolbar:YES]; [bvc_ webStateSelected:ActiveWebState() notifyToolbar:YES];
EXPECT_EQ([ActiveWebState()->GetView() superview], [bvc_ contentArea]); EXPECT_EQ(ActiveWebState()->GetView().superview, container_.view);
EXPECT_TRUE(ActiveWebState()->IsVisible()); EXPECT_TRUE(ActiveWebState()->IsVisible());
} }
// TODO(altse): Needs a testing |Profile| that implements AutocompleteClassifier
// before enabling again.
TEST_F(BrowserViewControllerTest, DISABLED_TestShieldWasTapped) {
[HandlerForProtocol(browser_->GetCommandDispatcher(), OmniboxCommands)
focusOmnibox];
EXPECT_TRUE([[bvc_ typingShield] superview] != nil);
EXPECT_FALSE([[bvc_ typingShield] isHidden]);
[bvc_ shieldWasTapped:nil];
EXPECT_TRUE([[bvc_ typingShield] superview] == nil);
EXPECT_TRUE([[bvc_ typingShield] isHidden]);
}
// Verifies that editing the omnimbox while the page is loading will stop the // Verifies that editing the omnimbox while the page is loading will stop the
// load on a handset, but not stop the load on a tablet. // load on a handset, but not stop the load on a tablet.
TEST_F(BrowserViewControllerTest, TEST_F(BrowserViewControllerTest,
......
...@@ -241,8 +241,8 @@ source_set("perf_tests") { ...@@ -241,8 +241,8 @@ source_set("perf_tests") {
sources = [ "new_tab_page_perftest.mm" ] sources = [ "new_tab_page_perftest.mm" ]
deps = [ deps = [
"//base/test:test_support", "//base/test:test_support",
"//ios/chrome/browser/main",
"//ios/chrome/browser/sessions", "//ios/chrome/browser/sessions",
"//ios/chrome/browser/tabs",
"//ios/chrome/browser/test:perf_test_support", "//ios/chrome/browser/test:perf_test_support",
"//ios/chrome/browser/ui/browser_view", "//ios/chrome/browser/ui/browser_view",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
// found in the LICENSE file. // found in the LICENSE file.
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#import "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#include "ios/chrome/browser/test/perf_test_with_bvc_ios.h" #include "ios/chrome/browser/test/perf_test_with_bvc_ios.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller_dependency_factory.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller_dependency_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.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/open_new_tab_command.h" #import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -40,7 +41,9 @@ class NewTabPagePerfTest : public PerfTestWithBVC { ...@@ -40,7 +41,9 @@ class NewTabPagePerfTest : public PerfTestWithBVC {
} }
base::TimeDelta TimedNewTab() { base::TimeDelta TimedNewTab() {
base::Time startTime = base::Time::NowFromSystemTime(); base::Time startTime = base::Time::NowFromSystemTime();
[[bvc_ dispatcher] openURLInNewTab:[OpenNewTabCommand command]]; id<ApplicationCommands> open_url_handler = HandlerForProtocol(
browser_->GetCommandDispatcher(), ApplicationCommands);
[open_url_handler openURLInNewTab:[OpenNewTabCommand command]];
return base::Time::NowFromSystemTime() - startTime; return base::Time::NowFromSystemTime() - startTime;
} }
void SettleUI() { void SettleUI() {
......
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