Commit 670c2fd8 authored by nancy's avatar nancy Committed by Commit Bot

Reorder the remove process to resolve the crash issue when switch user.

BUG=1011235

Change-Id: I322a6924aff0f77b4a030f534b36f251987c8992
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975376Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726470}
parent 34799188
......@@ -421,6 +421,19 @@ void AppServiceAppWindowLauncherController::RegisterWindow(
if (arc_tracker_ && arc::GetWindowTaskId(window) != arc::kNoTaskId) {
arc_tracker_->AttachControllerToWindow(window);
} else {
// The window for ARC Play Store is a special window, which is created by
// both Extensions and ARC. If Extensions's window is generated after
// ARC window, calls OnItemDelegateDiscarded to remove the ARC apps
// window.
if (shelf_id.app_id == arc::kPlayStoreAppId) {
AppWindowLauncherItemController* item_controller =
owner()->shelf_model()->GetAppWindowLauncherItemController(shelf_id);
if (item_controller != nullptr &&
shelf_id.app_id == arc::kPlayStoreAppId && arc_tracker_) {
OnItemDelegateDiscarded(item_controller);
}
}
AddWindowToShelf(window, shelf_id);
}
}
......@@ -455,13 +468,6 @@ void AppServiceAppWindowLauncherController::AddAppWindowToShelf(
std::move(controller));
owner()->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
}
} else {
// The window for ARC Play Store is is a special window, which is created by
// both Extensions and ARC. If Extensions's window is generated after
// ARC window, calls OnItemDelegateDiscarded to remove the ARC apps
// window.
if (shelf_id.app_id == arc::kPlayStoreAppId)
OnItemDelegateDiscarded(item_controller);
}
item_controller->AddWindow(app_window);
......@@ -488,15 +494,18 @@ void AppServiceAppWindowLauncherController::OnItemDelegateDiscarded(
ash::ShelfItemDelegate* delegate) {
for (auto& it : aura_window_to_app_window_) {
AppWindowBase* app_window = it.second.get();
if (!app_window)
continue;
if (arc_tracker_)
arc_tracker_->OnItemDelegateDiscarded(app_window->shelf_id());
if (!app_window || app_window->controller() != delegate)
continue;
VLOG(1) << "Item controller was released externally for the app "
<< delegate->shelf_id().app_id << ".";
if (arc_tracker_)
arc_tracker_->OnItemDelegateDiscarded(app_window->shelf_id());
UnregisterAppWindow(it.second.get());
}
}
......
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