Commit dd01d6ed authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Fix the GetActiveViewController() EG util.

When the UIRefresh TabGrid is enabled, then this utility method takes a separate
codepath that wasn't accounting for the existence of the
BVCContainerViewController. This CL fixes that so that the BVC is properly
returned instead of its container.

BUG=None
TEST=None

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I969ffc62138a189a395d46279dba722670c7ce64
Reviewed-on: https://chromium-review.googlesource.com/1007159Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549912}
parent fb1f6483
......@@ -21,6 +21,7 @@
#import "ios/chrome/browser/metrics/previous_session_info_private.h"
#import "ios/chrome/browser/tabs/tab.h"
#import "ios/chrome/browser/ui/browser_view_controller.h"
#import "ios/chrome/browser/ui/main/bvc_container_view_controller.h"
#import "ios/chrome/browser/ui/main/view_controller_swapping.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#import "ios/chrome/browser/ui/tab_switcher/tab_switcher.h"
......@@ -124,11 +125,22 @@ UIViewController* GetActiveViewController() {
return [static_cast<id<ViewControllerSwapping>>(main_view_controller)
activeViewController];
}
// The active view controller is either the TabGridViewController or its
// presented BVC.
return main_view_controller.presentedViewController
? main_view_controller.presentedViewController
: main_view_controller;
// presented BVC. The BVC is itself contained inside of a
// BVCContainerViewController.
UIViewController* active_view_controller =
main_view_controller.presentedViewController
? main_view_controller.presentedViewController
: main_view_controller;
if ([active_view_controller
isKindOfClass:[BVCContainerViewController class]]) {
active_view_controller =
base::mac::ObjCCastStrict<BVCContainerViewController>(
active_view_controller)
.currentBVC;
}
return active_view_controller;
}
id<ApplicationCommands, BrowserCommands> DispatcherForActiveViewController() {
......
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