Commit 7136f775 authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix homecher issue with multi profile

Changes:
1. Fix a crash that occurs when signing into a different account in
   multi profile.
2. Fix homecher not shown issue when account is switched.

Bug: 875913
Change-Id: Iddd093aa93aa21247f77c9831fbc3cb8afdac9c6
Reviewed-on: https://chromium-review.googlesource.com/1182449Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585154}
parent f9e9115f
......@@ -13,6 +13,7 @@
#include "ash/app_list/views/app_list_main_view.h"
#include "ash/app_list/views/app_list_view.h"
#include "ash/app_list/views/contents_view.h"
#include "ash/app_list/views/search_box_view.h"
#include "ash/assistant/assistant_controller.h"
#include "ash/assistant/assistant_ui_controller.h"
#include "ash/public/cpp/app_list/answer_card_contents_registry.h"
......@@ -388,6 +389,22 @@ void AppListControllerImpl::OnSessionStateChanged(
app_list::AppListShowSource::kTabletMode, base::TimeTicks());
}
void AppListControllerImpl::OnActiveUserPrefServiceChanged(
PrefService* pref_service) {
if (!IsHomeLauncherEnabledInTabletMode() ||
!display::Display::HasInternalDisplay()) {
DismissAppList();
return;
}
// The app list is not dismissed before switching user, suggestion chips will
// not be shown. So reset app list state and trigger an initial search here to
// update the suggestion results.
DCHECK(presenter_.GetTargetVisibility());
presenter_.GetView()->CloseOpenedPage();
presenter_.GetView()->search_box_view()->ClearSearch();
}
void AppListControllerImpl::OnAppListItemWillBeDeleted(
app_list::AppListItem* item) {
if (client_ && item->is_folder())
......@@ -415,6 +432,13 @@ void AppListControllerImpl::Show(int64_t display_id,
base::TimeTicks event_time_stamp) {
UMA_HISTOGRAM_ENUMERATION(app_list::kAppListToggleMethodHistogram,
show_source, app_list::kMaxAppListToggleMethod);
if (!presenter_.GetTargetVisibility() && IsVisible()) {
// The launcher is running close animation, so close it immediately before
// reshow the launcher in tablet mode.
presenter_.GetView()->GetWidget()->CloseNow();
}
presenter_.Show(display_id, event_time_stamp);
}
......@@ -477,15 +501,9 @@ void AppListControllerImpl::OnOverviewModeEnding() {
}
void AppListControllerImpl::OnTabletModeStarted() {
if (IsVisible()) {
if (!presenter_.is_animating_to_close()) {
presenter_.GetView()->OnTabletModeChanged(true);
return;
}
// The launcher is running close animation, so close it immediately before
// reshow the launcher in tablet mode.
presenter_.GetView()->GetWidget()->CloseNow();
if (presenter_.GetTargetVisibility()) {
DCHECK(IsVisible());
presenter_.GetView()->OnTabletModeChanged(true);
}
if (!is_home_launcher_enabled_ || !display::Display::HasInternalDisplay())
......
......@@ -120,6 +120,7 @@ class ASH_EXPORT AppListControllerImpl
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
void OnActiveUserPrefServiceChanged(PrefService* pref_service) override;
// Methods used in ash:
bool GetTargetVisibility() const;
......
......@@ -120,9 +120,7 @@ void AppListPresenterImpl::Show(int64_t display_id,
is_visible_ = true;
RequestPresentationTime(display_id, event_time_stamp);
if (view_) {
ScheduleAnimation();
} else {
if (!view_) {
// Note |delegate_| outlives the AppListView. For Ash, the view
// is destroyed when dismissed.
AppListView* view = new AppListView(delegate_->GetAppListViewDelegate());
......@@ -329,7 +327,6 @@ void AppListPresenterImpl::ScheduleAnimation() {
gfx::Transform transform;
transform.Translate(-offset.x(), -offset.y());
layer->SetTransform(transform);
is_animating_to_close_ = true;
{
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
......@@ -399,7 +396,6 @@ void AppListPresenterImpl::OnImplicitAnimationsCompleted() {
view_->GetWidget()->Activate();
} else {
view_->GetWidget()->Close();
is_animating_to_close_ = false;
}
}
......
......@@ -85,8 +85,6 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl
// Passes a MouseWheelEvent from the shelf to the AppListView.
void ProcessMouseWheelOffset(int y_scroll_offset);
bool is_animating_to_close() const { return is_animating_to_close_; }
// Schedules animation for app list when overview mode starts or ends.
void ScheduleOverviewModeAnimation(bool start);
......@@ -160,9 +158,6 @@ class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl
bool last_visible_ = false;
int64_t last_display_id_ = display::kInvalidDisplayId;
// True if app list is running close animation.
bool is_animating_to_close_ = false;
// The timer used to delay the start time of an animation.
base::OneShotTimer start_animation_timer_;
......
......@@ -2454,18 +2454,19 @@ void AppsGridView::ButtonPressed(views::Button* sender,
}
void AppsGridView::OnListItemAdded(size_t index, AppListItem* item) {
DCHECK(!item->is_page_break());
EndDrag(true);
AppListItemView* view = CreateViewForItemAtIndex(index);
int model_index = GetTargetModelIndexFromItemIndex(index);
view_model_.Add(view, model_index);
AddChildViewAt(view, GetAppListItemViewIndexOffset() + model_index);
if (!item->is_page_break()) {
AppListItemView* view = CreateViewForItemAtIndex(index);
int model_index = GetTargetModelIndexFromItemIndex(index);
view_model_.Add(view, model_index);
AddChildViewAt(view, GetAppListItemViewIndexOffset() + model_index);
// Ensure that AppListItems that are added to the AppListItemList are not
// shown while in PEEKING. The visibility of the app icons will be updated
// on drag/animation from PEEKING.
view->SetVisible(model_->state_fullscreen() != AppListViewState::PEEKING);
// Ensure that AppListItems that are added to the AppListItemList are not
// shown while in PEEKING. The visibility of the app icons will be updated
// on drag/animation from PEEKING.
view->SetVisible(model_->state_fullscreen() != AppListViewState::PEEKING);
}
if (IsAppsGridGapEnabled())
view_structure_.LoadFromMetadata();
......@@ -2477,10 +2478,10 @@ void AppsGridView::OnListItemAdded(size_t index, AppListItem* item) {
}
void AppsGridView::OnListItemRemoved(size_t index, AppListItem* item) {
DCHECK(!item->is_page_break());
EndDrag(true);
DeleteItemViewAtIndex(GetModelIndexOfItem(item), true /* sanitize */);
if (!item->is_page_break())
DeleteItemViewAtIndex(GetModelIndexOfItem(item), true /* sanitize */);
if (IsAppsGridGapEnabled())
view_structure_.LoadFromMetadata();
......@@ -2494,17 +2495,20 @@ void AppsGridView::OnListItemRemoved(size_t index, AppListItem* item) {
void AppsGridView::OnListItemMoved(size_t from_index,
size_t to_index,
AppListItem* item) {
DCHECK(!item->is_page_break());
EndDrag(true);
// The item is updated in the item list but the view_model is not updated, so
// get current model index by looking up view_model and predict the target
// model index based on its current item index.
int from_model_index = GetModelIndexOfItem(item);
int to_model_index = GetTargetModelIndexFromItemIndex(to_index);
view_model_.Move(from_model_index, to_model_index);
ReorderChildView(view_model_.view_at(to_model_index),
GetAppListItemViewIndexOffset() + to_model_index);
if (item->is_page_break()) {
LOG(ERROR) << "Page break item is moved: " << item->id();
} else {
// The item is updated in the item list but the view_model is not updated,
// so get current model index by looking up view_model and predict the
// target model index based on its current item index.
int from_model_index = GetModelIndexOfItem(item);
int to_model_index = GetTargetModelIndexFromItemIndex(to_index);
view_model_.Move(from_model_index, to_model_index);
ReorderChildView(view_model_.view_at(to_model_index),
GetAppListItemViewIndexOffset() + to_model_index);
}
if (IsAppsGridGapEnabled())
view_structure_.LoadFromMetadata();
......
......@@ -89,7 +89,6 @@ UserSwitchAnimatorChromeOS::UserSwitchAnimatorChromeOS(
animation_step_(ANIMATION_STEP_HIDE_OLD_USER),
screen_cover_(GetScreenCover(NULL)),
windows_by_account_id_() {
ash::Shell::Get()->app_list_controller()->DismissAppList();
BuildUserToWindowsListMap();
AdvanceUserTransitionAnimation();
......
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