Commit c50d5f0a authored by Marina Ciocea's avatar Marina Ciocea Committed by Commit Bot

Don't process TabStripModelChange::kRemove changes in TabSharingUIViews.

The logic for kRemove tab strip model changes is covered in
OnInfobarRemoved.

Drive-by reset tab capture indicator on StopSharing. This wasn't a
bug, the indicator would get destroyed in dtor, but it's more logical to
remove it on StopSharing and it makes testing easier.

Bug: 996722
Change-Id: I49943226dcc4fc7eab8a4776f45aaa7c9fd98d5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855738Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Marina Ciocea <marinaciocea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705032}
parent db752d0b
...@@ -168,6 +168,7 @@ void TabSharingUIViews::StopSharing() { ...@@ -168,6 +168,7 @@ void TabSharingUIViews::StopSharing() {
std::move(stop_callback_).Run(); std::move(stop_callback_).Run();
RemoveInfobarsForAllTabs(); RemoveInfobarsForAllTabs();
SetContentsBorderVisible(shared_tab_, false); SetContentsBorderVisible(shared_tab_, false);
tab_capture_indicator_ui_.reset();
shared_tab_ = nullptr; shared_tab_ = nullptr;
} }
...@@ -180,7 +181,6 @@ void TabSharingUIViews::OnBrowserRemoved(Browser* browser) { ...@@ -180,7 +181,6 @@ void TabSharingUIViews::OnBrowserRemoved(Browser* browser) {
BrowserList* browser_list = BrowserList::GetInstance(); BrowserList* browser_list = BrowserList::GetInstance();
if (browser_list->empty()) if (browser_list->empty())
browser_list->RemoveObserver(this); browser_list->RemoveObserver(this);
browser->tab_strip_model()->RemoveObserver(this); browser->tab_strip_model()->RemoveObserver(this);
} }
...@@ -193,17 +193,6 @@ void TabSharingUIViews::OnTabStripModelChanged( ...@@ -193,17 +193,6 @@ void TabSharingUIViews::OnTabStripModelChanged(
if (infobars_.find(contents.contents) == infobars_.end()) if (infobars_.find(contents.contents) == infobars_.end())
CreateInfobarForWebContents(contents.contents); CreateInfobarForWebContents(contents.contents);
} }
} else if (change.type() == TabStripModelChange::kRemoved) {
auto* remove = change.GetRemove();
if (remove->will_be_deleted) {
bool remove_shared_tab = false;
for (const auto& contents : remove->contents) {
remove_shared_tab |= contents.contents == shared_tab_;
infobars_.erase(contents.contents);
}
if (remove_shared_tab)
StopSharing();
}
} }
if (selection.active_tab_changed()) { if (selection.active_tab_changed()) {
...@@ -227,18 +216,18 @@ void TabSharingUIViews::TabChangedAt(content::WebContents* contents, ...@@ -227,18 +216,18 @@ void TabSharingUIViews::TabChangedAt(content::WebContents* contents,
CreateInfobarForWebContents(contents); CreateInfobarForWebContents(contents);
} }
void TabSharingUIViews::OnInfoBarRemoved(infobars::InfoBar* info_bar, void TabSharingUIViews::OnInfoBarRemoved(infobars::InfoBar* infobar,
bool animate) { bool animate) {
auto infobars_entry = std::find_if(infobars_.begin(), infobars_.end(), auto infobars_entry = std::find_if(infobars_.begin(), infobars_.end(),
[info_bar](const auto& infobars_entry) { [infobar](const auto& infobars_entry) {
return infobars_entry.second == info_bar; return infobars_entry.second == infobar;
}); });
if (infobars_entry == infobars_.end()) if (infobars_entry == infobars_.end())
return; return;
info_bar->owner()->RemoveObserver(this); infobar->owner()->RemoveObserver(this);
infobars_.erase(infobars_entry); infobars_.erase(infobars_entry);
if (infobars_entry->first == shared_tab_) if (InfoBarService::WebContentsFromInfoBar(infobar) == shared_tab_)
StopSharing(); StopSharing();
} }
......
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