Commit 2359557a authored by nancy's avatar nancy Committed by Commit Bot

Fix the issue that ARC app can't start from shelf after switch users.

The reason is that OnItemDelegateDiscarded is called, and the
controller is deleted from app_shelf_group_to_controller_map_, even
though the parameter delegate is not the controller saved in
app_shelf_group_to_controller_map_. So adding a checking in
OnItemDelegateDiscarded, only when the parameter delegate is the
controller saved in app_shelf_group_to_controller_map_, delete it,
otherwise, don't delete the controller in
app_shelf_group_to_controller_map_.

BUG=1011235

Change-Id: I300b5fc4a46b9441a063c34bac745a5018aa5b82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1976140
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726710}
parent 74668707
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/public/cpp/app_types.h" #include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/multi_user_window_manager.h" #include "ash/public/cpp/multi_user_window_manager.h"
#include "ash/public/cpp/shelf_item_delegate.h"
#include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/shelf_model.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
...@@ -358,10 +359,13 @@ void AppServiceAppWindowArcTracker::RemoveCandidateWindow( ...@@ -358,10 +359,13 @@ void AppServiceAppWindowArcTracker::RemoveCandidateWindow(
} }
void AppServiceAppWindowArcTracker::OnItemDelegateDiscarded( void AppServiceAppWindowArcTracker::OnItemDelegateDiscarded(
const ash::ShelfID& shelf_id) { const ash::ShelfID& shelf_id,
ash::ShelfItemDelegate* delegate) {
arc::ArcAppShelfId app_shelf_id = arc::ArcAppShelfId app_shelf_id =
arc::ArcAppShelfId::FromString(shelf_id.app_id); arc::ArcAppShelfId::FromString(shelf_id.app_id);
app_shelf_group_to_controller_map_.erase(app_shelf_id); auto it = app_shelf_group_to_controller_map_.find(app_shelf_id);
if (static_cast<ash::ShelfItemDelegate*>(it->second) == delegate)
app_shelf_group_to_controller_map_.erase(app_shelf_id);
} }
ash::ShelfID AppServiceAppWindowArcTracker::GetShelfId(int task_id) const { ash::ShelfID AppServiceAppWindowArcTracker::GetShelfId(int task_id) const {
......
...@@ -20,6 +20,10 @@ namespace arc { ...@@ -20,6 +20,10 @@ namespace arc {
class ArcAppShelfId; class ArcAppShelfId;
} }
namespace ash {
class ShelfItemDelegate;
}
namespace aura { namespace aura {
class window; class window;
} }
...@@ -78,7 +82,8 @@ class AppServiceAppWindowArcTracker : public ArcAppListPrefs::Observer, ...@@ -78,7 +82,8 @@ class AppServiceAppWindowArcTracker : public ArcAppListPrefs::Observer,
void RemoveCandidateWindow(aura::Window* window); void RemoveCandidateWindow(aura::Window* window);
// Removes controller from |app_shelf_group_to_controller_map_|. // Removes controller from |app_shelf_group_to_controller_map_|.
void OnItemDelegateDiscarded(const ash::ShelfID& shelf_id); void OnItemDelegateDiscarded(const ash::ShelfID& shelf_id,
ash::ShelfItemDelegate* delegate);
ash::ShelfID GetShelfId(int task_id) const; ash::ShelfID GetShelfId(int task_id) const;
......
...@@ -498,7 +498,7 @@ void AppServiceAppWindowLauncherController::OnItemDelegateDiscarded( ...@@ -498,7 +498,7 @@ void AppServiceAppWindowLauncherController::OnItemDelegateDiscarded(
continue; continue;
if (arc_tracker_) if (arc_tracker_)
arc_tracker_->OnItemDelegateDiscarded(app_window->shelf_id()); arc_tracker_->OnItemDelegateDiscarded(app_window->shelf_id(), delegate);
if (!app_window || app_window->controller() != delegate) if (!app_window || app_window->controller() != delegate)
continue; continue;
......
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