Commit 9a8d8f4d authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Password-Breach] Update snapshot on new tab command

Previously whenever a new tab was open programmatically the snapshot
wasn't updated, causing inconsistencies in the tab switcher. This CL
amends that by asking for a new snapshot in main controller, before the
action of opening a new tab takes place.

Bug: 1029482
Change-Id: I49c327b3891d91cc6bdf60de28c80770e23e893a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1981717
Auto-Submit: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727455}
parent 3a74cfcc
...@@ -1542,14 +1542,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1542,14 +1542,7 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
// Update the snapshot before switching another application mode. This // Update the snapshot before switching another application mode. This
// ensures that the snapshot is correct when links are opened in a different // ensures that the snapshot is correct when links are opened in a different
// application mode. // application mode.
WebStateList* webStateList = self.currentBVC.tabModel.webStateList; [self updateActiveWebStateSnapshot];
if (webStateList) {
web::WebState* webState = webStateList->GetActiveWebState();
if (webState) {
SnapshotTabHelper::FromWebState(webState)->UpdateSnapshotWithCallback(
nil);
}
}
self.interfaceProvider.currentInterface = newInterface; self.interfaceProvider.currentInterface = newInterface;
...@@ -1919,6 +1912,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -1919,6 +1912,10 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
- (void)openSelectedTabInMode:(ApplicationModeForTabOpening)tabOpeningTargetMode - (void)openSelectedTabInMode:(ApplicationModeForTabOpening)tabOpeningTargetMode
withUrlLoadParams:(const UrlLoadParams&)urlLoadParams withUrlLoadParams:(const UrlLoadParams&)urlLoadParams
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
// Update the snapshot before opening a new tab. This ensures that the
// snapshot is correct when tabs are openned via the dispatcher.
[self updateActiveWebStateSnapshot];
ApplicationMode targetMode; ApplicationMode targetMode;
if (tabOpeningTargetMode == ApplicationModeForTabOpening::CURRENT) { if (tabOpeningTargetMode == ApplicationModeForTabOpening::CURRENT) {
...@@ -2087,6 +2084,19 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData( ...@@ -2087,6 +2084,19 @@ void MainControllerAuthenticationServiceDelegate::ClearBrowsingData(
return result; return result;
} }
// Asks the respective Snapshot helper to update the snapshot for the active
// WebState.
- (void)updateActiveWebStateSnapshot {
WebStateList* webStateList = self.currentBVC.tabModel.webStateList;
if (webStateList) {
web::WebState* webState = webStateList->GetActiveWebState();
if (webState) {
SnapshotTabHelper::FromWebState(webState)->UpdateSnapshotWithCallback(
nil);
}
}
}
- (void)purgeSnapshots { - (void)purgeSnapshots {
NSMutableSet* liveSessions = [self liveSessionsForTabModel:self.mainTabModel]; NSMutableSet* liveSessions = [self liveSessionsForTabModel:self.mainTabModel];
[liveSessions unionSet:[self liveSessionsForTabModel:self.otrTabModel]]; [liveSessions unionSet:[self liveSessionsForTabModel:self.otrTabModel]];
......
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