Commit d0d3a891 authored by Mohammad Refaat's avatar Mohammad Refaat Committed by Commit Bot

Use Browser in TabSwitcher/Delegate Protocol instead of TabModel

Also update users to call the new methods.

Bug: 1042277, 783777
Change-Id: Ie318b3828f9a1e00c86e5e731c9ff758a9283931
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008071
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734092}
parent e6d6f2ef
...@@ -1208,9 +1208,9 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1208,9 +1208,9 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
_tabSwitcher = self.mainCoordinator.tabSwitcher; _tabSwitcher = self.mainCoordinator.tabSwitcher;
// Call -restoreInternalState so that the grid shows the correct panel. // Call -restoreInternalState so that the grid shows the correct panel.
[_tabSwitcher restoreInternalStateWithMainTabModel:self.mainTabModel [_tabSwitcher restoreInternalStateWithMainBrowser:self.mainBrowser
otrTabModel:self.otrTabModel otrBrowser:self.otrBrowser
activeTabModel:self.currentTabModel]; activeBrowser:self.currentBrowser];
// Decide if the First Run UI needs to run. // Decide if the First Run UI needs to run.
BOOL firstRun = (FirstRun::IsChromeFirstRun() || BOOL firstRun = (FirstRun::IsChromeFirstRun() ||
...@@ -1444,6 +1444,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1444,6 +1444,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return self.currentBVC.tabModel; return self.currentBVC.tabModel;
} }
- (Browser*)currentBrowser {
return self.interfaceProvider.currentInterface.browser;
}
- (ios::ChromeBrowserState*)currentBrowserState { - (ios::ChromeBrowserState*)currentBrowserState {
return self.currentBVC.browserState; return self.currentBVC.browserState;
} }
......
...@@ -619,9 +619,9 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -619,9 +619,9 @@ enum class EnterTabSwitcherSnapshotResult {
#pragma mark - TabSwitcherDelegate #pragma mark - TabSwitcherDelegate
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher - (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
shouldFinishWithActiveModel:(TabModel*)tabModel shouldFinishWithBrowser:(Browser*)browser
focusOmnibox:(BOOL)focusOmnibox { focusOmnibox:(BOOL)focusOmnibox {
[self beginDismissingTabSwitcherWithCurrentModel:tabModel [self beginDismissingTabSwitcherWithCurrentModel:browser->GetTabModel()
focusOmnibox:focusOmnibox]; focusOmnibox:focusOmnibox];
} }
...@@ -1282,9 +1282,9 @@ enum class EnterTabSwitcherSnapshotResult { ...@@ -1282,9 +1282,9 @@ enum class EnterTabSwitcherSnapshotResult {
// Tab switcher implementations may need to rebuild state before being // Tab switcher implementations may need to rebuild state before being
// displayed. // displayed.
[self.mainController.tabSwitcher [self.mainController.tabSwitcher
restoreInternalStateWithMainTabModel:self.mainInterface.tabModel restoreInternalStateWithMainBrowser:self.mainInterface.browser
otrTabModel:self.incognitoInterface.tabModel otrBrowser:self.incognitoInterface.browser
activeTabModel:self.currentTabModel]; activeBrowser:self.currentInterface.browser];
self.mainController.tabSwitcherIsActive = YES; self.mainController.tabSwitcherIsActive = YES;
[self.mainController.tabSwitcher setDelegate:self]; [self.mainController.tabSwitcher setDelegate:self];
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/logging.h" #include "base/logging.h"
#import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/main/browser.h"
#include "ios/chrome/browser/main/browser.h" #include "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_paging.h" #import "ios/chrome/browser/ui/tab_grid/tab_grid_paging.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" #import "ios/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
#import "ios/chrome/browser/ui/tab_grid/view_controller_swapping.h" #import "ios/chrome/browser/ui/tab_grid/view_controller_swapping.h"
...@@ -26,12 +25,12 @@ ...@@ -26,12 +25,12 @@
#pragma mark - TabSwitcher #pragma mark - TabSwitcher
- (void)restoreInternalStateWithMainTabModel:(TabModel*)mainModel - (void)restoreInternalStateWithMainBrowser:(Browser*)mainBrowser
otrTabModel:(TabModel*)otrModel otrBrowser:(Browser*)otrBrowser
activeTabModel:(TabModel*)activeModel { activeBrowser:(Browser*)activeBrowser {
// The only action here is to signal to the tab grid which panel should be // The only action here is to signal to the tab grid which panel should be
// active. // active.
if (activeModel == otrModel) { if (activeBrowser == otrBrowser) {
self.tabGridViewController.activePage = TabGridPageIncognitoTabs; self.tabGridViewController.activePage = TabGridPageIncognitoTabs;
} else { } else {
self.tabGridViewController.activePage = TabGridPageRegularTabs; self.tabGridViewController.activePage = TabGridPageRegularTabs;
...@@ -53,8 +52,8 @@ ...@@ -53,8 +52,8 @@
// Tell the delegate to display the tab. // Tell the delegate to display the tab.
DCHECK(self.delegate); DCHECK(self.delegate);
[self.delegate tabSwitcher:self [self.delegate tabSwitcher:self
shouldFinishWithActiveModel:browser->GetTabModel() shouldFinishWithBrowser:browser
focusOmnibox:NO]; focusOmnibox:NO];
} }
- (void)setOtrBrowser:(Browser*)browser { - (void)setOtrBrowser:(Browser*)browser {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "ios/chrome/browser/chrome_url_constants.h" #include "ios/chrome/browser/chrome_url_constants.h"
#include "ios/chrome/browser/main/browser.h" #include "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"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/browsing_data_commands.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"
...@@ -361,15 +360,15 @@ ...@@ -361,15 +360,15 @@
- (void)showActiveTabInPage:(TabGridPage)page focusOmnibox:(BOOL)focusOmnibox { - (void)showActiveTabInPage:(TabGridPage)page focusOmnibox:(BOOL)focusOmnibox {
DCHECK(self.regularBrowser && self.incognitoBrowser); DCHECK(self.regularBrowser && self.incognitoBrowser);
TabModel* activeTabModel; Browser* activeBrowser = nullptr;
switch (page) { switch (page) {
case TabGridPageIncognitoTabs: case TabGridPageIncognitoTabs:
DCHECK_GT(self.incognitoBrowser->GetWebStateList()->count(), 0); DCHECK_GT(self.incognitoBrowser->GetWebStateList()->count(), 0);
activeTabModel = self.incognitoBrowser->GetTabModel(); activeBrowser = self.incognitoBrowser;
break; break;
case TabGridPageRegularTabs: case TabGridPageRegularTabs:
DCHECK_GT(self.regularBrowser->GetWebStateList()->count(), 0); DCHECK_GT(self.regularBrowser->GetWebStateList()->count(), 0);
activeTabModel = self.regularBrowser->GetTabModel(); activeBrowser = self.regularBrowser;
break; break;
case TabGridPageRemoteTabs: case TabGridPageRemoteTabs:
NOTREACHED() << "It is invalid to have an active tab in remote tabs."; NOTREACHED() << "It is invalid to have an active tab in remote tabs.";
...@@ -378,7 +377,7 @@ ...@@ -378,7 +377,7 @@
// Trigger the transition through the TabSwitcher delegate. This will in turn // Trigger the transition through the TabSwitcher delegate. This will in turn
// call back into this coordinator via the ViewControllerSwapping protocol. // call back into this coordinator via the ViewControllerSwapping protocol.
[self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher [self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher
shouldFinishWithActiveModel:activeTabModel shouldFinishWithBrowser:activeBrowser
focusOmnibox:focusOmnibox]; focusOmnibox:focusOmnibox];
} }
...@@ -407,7 +406,7 @@ ...@@ -407,7 +406,7 @@
- (void)showActiveRegularTabFromRecentTabs { - (void)showActiveRegularTabFromRecentTabs {
[self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher [self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher
shouldFinishWithActiveModel:self.regularBrowser->GetTabModel() shouldFinishWithBrowser:self.regularBrowser
focusOmnibox:NO]; focusOmnibox:NO];
} }
...@@ -415,13 +414,13 @@ ...@@ -415,13 +414,13 @@
- (void)showActiveRegularTabFromHistory { - (void)showActiveRegularTabFromHistory {
[self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher [self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher
shouldFinishWithActiveModel:self.regularBrowser->GetTabModel() shouldFinishWithBrowser:self.regularBrowser
focusOmnibox:NO]; focusOmnibox:NO];
} }
- (void)showActiveIncognitoTabFromHistory { - (void)showActiveIncognitoTabFromHistory {
[self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher [self.tabSwitcher.delegate tabSwitcher:self.tabSwitcher
shouldFinishWithActiveModel:self.incognitoBrowser->GetTabModel() shouldFinishWithBrowser:self.incognitoBrowser
focusOmnibox:NO]; focusOmnibox:NO];
} }
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
@implementation TestTabSwitcherDelegate @implementation TestTabSwitcherDelegate
@synthesize didEndCalled = _didEndCalled; @synthesize didEndCalled = _didEndCalled;
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher - (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
shouldFinishWithActiveModel:(TabModel*)tabModel shouldFinishWithBrowser:(Browser*)browser
focusOmnibox:(BOOL)focusOmnibox { focusOmnibox:(BOOL)focusOmnibox {
// No-op. // No-op.
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "url/gurl.h" #include "url/gurl.h"
class Browser; class Browser;
@class TabModel;
@protocol TabSwitcher; @protocol TabSwitcher;
struct UrlLoadParams; struct UrlLoadParams;
...@@ -22,10 +21,10 @@ struct UrlLoadParams; ...@@ -22,10 +21,10 @@ struct UrlLoadParams;
@protocol TabSwitcherDelegate <NSObject> @protocol TabSwitcherDelegate <NSObject>
// Informs the delegate the tab switcher should be dismissed with the given // Informs the delegate the tab switcher should be dismissed with the given
// active model. // active browser.
- (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher - (void)tabSwitcher:(id<TabSwitcher>)tabSwitcher
shouldFinishWithActiveModel:(TabModel*)tabModel shouldFinishWithBrowser:(Browser*)browser
focusOmnibox:(BOOL)focusOmnibox; focusOmnibox:(BOOL)focusOmnibox;
// Informs the delegate that the tab switcher is done and should be // Informs the delegate that the tab switcher is done and should be
// dismissed. // dismissed.
...@@ -42,22 +41,22 @@ struct UrlLoadParams; ...@@ -42,22 +41,22 @@ struct UrlLoadParams;
// switcher. // switcher.
@property(nonatomic, weak) id<TabSwitcherDelegate> delegate; @property(nonatomic, weak) id<TabSwitcherDelegate> delegate;
// Restores the internal state of the tab switcher with the given tab models, // Restores the internal state of the tab switcher with the given browser,
// which must not be nil. |activeTabModel| is the model which starts active, // which must not be nil. |activeBrowser| is the browser which starts active,
// and must be one of the other two models. Should only be called when the // and must be one of the other two browsers. Should only be called when the
// object is not being shown. // object is not being shown.
- (void)restoreInternalStateWithMainTabModel:(TabModel*)mainModel - (void)restoreInternalStateWithMainBrowser:(Browser*)mainBrowser
otrTabModel:(TabModel*)otrModel otrBrowser:(Browser*)otrBrowser
activeTabModel:(TabModel*)activeModel; activeBrowser:(Browser*)activeBrowser;
// Returns the view controller that displays the tab switcher. // Returns the view controller that displays the tab switcher.
- (UIViewController*)viewController; - (UIViewController*)viewController;
// Create a new tab in |targetModel|. Implementors are expected to also perform // Create a new tab in |browser|. Implementors are expected to also perform an
// an animation from the selected tab in the tab switcher to the newly created // animation from the selected tab in the tab switcher to the newly created tab
// tab in the content area. Objects adopting this protocol should call the // in the content area. Objects adopting this protocol should call the following
// following delegate methods: // delegate methods:
// |-tabSwitcher:shouldFinishWithActiveModel:| // |-tabSwitcher:shouldFinishWithBrowser:|
// |-tabSwitcherDismissTransitionDidEnd:| // |-tabSwitcherDismissTransitionDidEnd:|
// to inform the delegate when this animation begins and ends. // to inform the delegate when this animation begins and ends.
- (void)dismissWithNewTabAnimationToBrowser:(Browser*)browser - (void)dismissWithNewTabAnimationToBrowser:(Browser*)browser
...@@ -66,8 +65,8 @@ struct UrlLoadParams; ...@@ -66,8 +65,8 @@ struct UrlLoadParams;
// Updates the OTR (Off The Record) browser. Should only be called when both // Updates the OTR (Off The Record) browser. Should only be called when both
// the current OTR browser and the new OTR browser are either nil or contain no // the current OTR browser and the new OTR browser are either nil or contain no
// tabs. This must be called after the otr tab model has been deleted because // tabs. This must be called after the otr browser has been deleted because the
// the incognito browser state is deleted. // incognito browser state is deleted.
- (void)setOtrBrowser:(Browser*)otrBrowser; - (void)setOtrBrowser:(Browser*)otrBrowser;
@end @end
......
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