Commit cf231896 authored by Nancy Wang's avatar Nancy Wang Committed by Commit Bot

When the window is destroyed, remove windows from the related variables.

There are a few crash issues which could be related with reuse the
destroyed window. The crash issues are hard to reproduce.

This CL modifies the OnWindowDestroying function. Even if the app id is
empty, still check the related structure, e.g.
aura_window_to_app_window_, arc_tracker_, to remove the window from all
related variables to remove the window.

BUG=1128491
BUG=1126493

Change-Id: I842a79f3994b00af08b01c4095b890525655ea87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2496102Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820987}
parent c20bb989
......@@ -269,33 +269,31 @@ void AppServiceAppWindowLauncherController::OnWindowDestroying(
// InstanceRegistry, we should still destroy it from InstanceRegistry and
// remove the app window from the shelf
app_id = app_service_instance_helper_->GetAppId(window);
if (app_id.empty())
return;
}
if (app_service_instance_helper_->IsOpenedInBrowser(GetAppId(app_id),
window) ||
app_id == extension_misc::kChromeAppId) {
return;
if (!app_id.empty() &&
!app_service_instance_helper_->IsOpenedInBrowser(GetAppId(app_id),
window) &&
app_id != extension_misc::kChromeAppId) {
// Delete the instance from InstanceRegistry.
app_service_instance_helper_->OnInstances(GetAppId(app_id), window,
std::string(),
apps::InstanceState::kDestroyed);
}
// Delete the instance from InstanceRegistry.
app_service_instance_helper_->OnInstances(
GetAppId(app_id), window, std::string(), apps::InstanceState::kDestroyed);
auto app_window_it = aura_window_to_app_window_.find(window);
if (app_window_it == aura_window_to_app_window_.end())
return;
// Note, for ARC apps, window may be recreated in some cases, so do not close
// controller on window destroying. Controller will be closed onTaskDestroyed
// event which is generated when actual task is destroyed.
if (arc_tracker_ && arc::GetWindowTaskId(window) != arc::kNoTaskId) {
arc_tracker_->OnWindowDestroying(window);
aura_window_to_app_window_.erase(app_window_it);
aura_window_to_app_window_.erase(window);
return;
}
auto app_window_it = aura_window_to_app_window_.find(window);
if (app_window_it == aura_window_to_app_window_.end())
return;
RemoveAppWindowFromShelf(app_window_it->second.get());
aura_window_to_app_window_.erase(app_window_it);
......
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