Commit 589a5703 authored by nancylingwang@google.com's avatar nancylingwang@google.com Committed by Commit Bot

Fix the crash issue when the browser is removed.

Sometimes the browser is removed first, and the tab close callback
OnTabClosing is not called (e.g. launch media apps in browser, then
shutdown), so the tab windows are not removed from
browser_window_to_tab_window_.

Modify that code, when the browser is removed, go through the list of
browser_window_to_tab_window_ to remove the tab windows in the browser.

BUG=1090615

Change-Id: I83346b648110fd4f831661cfd168a69676cb39e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228018Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarNancy Wang <nancylingwang@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774675}
parent 1c410263
......@@ -171,9 +171,17 @@ void AppServiceInstanceRegistryHelper::OnBrowserRemoved() {
auto windows = GetWindows(extension_misc::kChromeAppId);
for (auto* window : windows) {
if (!chrome::FindBrowserWithWindow(window)) {
// The tabs in the browser should be closed, and tab windows have been
// removed from |browser_window_to_tab_window_|.
DCHECK(!base::Contains(browser_window_to_tab_window_, window));
// Remove windows from |browser_window_to_tab_window_| and
// |tab_window_to_browser_window_|, because OnTabClosing could be not
// called for tabs in the browser, when the browser is removed.
if (base::Contains(browser_window_to_tab_window_, window)) {
for (auto* w : browser_window_to_tab_window_[window]) {
tab_window_to_browser_window_.erase(w);
OnInstances(GetAppId(w), w, std::string(),
apps::InstanceState::kDestroyed);
}
browser_window_to_tab_window_.erase(window);
}
// The browser is removed if the window can't be found, so update the
// Chrome window instance as destroyed.
......
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