| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "ui/app_list/presenter/app_list_presenter_impl.h" |    5 #include "ui/app_list/presenter/app_list_presenter_impl.h" | 
|    6  |    6  | 
|    7 #include "base/metrics/user_metrics.h" |    7 #include "base/metrics/user_metrics.h" | 
|    8 #include "ui/app_list/app_list_constants.h" |    8 #include "ui/app_list/app_list_constants.h" | 
|    9 #include "ui/app_list/app_list_switches.h" |    9 #include "ui/app_list/app_list_switches.h" | 
|   10 #include "ui/app_list/pagination_model.h" |   10 #include "ui/app_list/pagination_model.h" | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   52  |   52  | 
|   53 aura::Window* AppListPresenterImpl::GetWindow() { |   53 aura::Window* AppListPresenterImpl::GetWindow() { | 
|   54   return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : nullptr; |   54   return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : nullptr; | 
|   55 } |   55 } | 
|   56  |   56  | 
|   57 void AppListPresenterImpl::Show(int64_t display_id) { |   57 void AppListPresenterImpl::Show(int64_t display_id) { | 
|   58   if (is_visible_) |   58   if (is_visible_) | 
|   59     return; |   59     return; | 
|   60  |   60  | 
|   61   is_visible_ = true; |   61   is_visible_ = true; | 
|   62   if (app_list_) |   62   if (app_list_) { | 
|   63     app_list_->OnTargetVisibilityChanged(GetTargetVisibility()); |   63     app_list_->OnTargetVisibilityChanged(GetTargetVisibility()); | 
 |   64     app_list_->OnVisibilityChanged(GetTargetVisibility(), display_id); | 
 |   65   } | 
|   64  |   66  | 
|   65   if (view_) { |   67   if (view_) { | 
|   66     ScheduleAnimation(); |   68     ScheduleAnimation(); | 
|   67   } else { |   69   } else { | 
|   68     presenter_delegate_ = factory_->GetDelegate(this); |   70     presenter_delegate_ = factory_->GetDelegate(this); | 
|   69     AppListViewDelegate* view_delegate = presenter_delegate_->GetViewDelegate(); |   71     AppListViewDelegate* view_delegate = presenter_delegate_->GetViewDelegate(); | 
|   70     DCHECK(view_delegate); |   72     DCHECK(view_delegate); | 
|   71     // Note the AppListViewDelegate outlives the AppListView. For Ash, the view |   73     // Note the AppListViewDelegate outlives the AppListView. For Ash, the view | 
|   72     // is destroyed when dismissed. |   74     // is destroyed when dismissed. | 
|   73     AppListView* view = new AppListView(view_delegate); |   75     AppListView* view = new AppListView(view_delegate); | 
|   74     presenter_delegate_->Init(view, display_id, current_apps_page_); |   76     presenter_delegate_->Init(view, display_id, current_apps_page_); | 
|   75     SetView(view); |   77     SetView(view); | 
|   76   } |   78   } | 
|   77   presenter_delegate_->OnShown(display_id); |   79   presenter_delegate_->OnShown(display_id); | 
|   78   base::RecordAction(base::UserMetricsAction("Launcher_Show")); |   80   base::RecordAction(base::UserMetricsAction("Launcher_Show")); | 
|   79 } |   81 } | 
|   80  |   82  | 
|   81 void AppListPresenterImpl::Dismiss() { |   83 void AppListPresenterImpl::Dismiss() { | 
|   82   if (!is_visible_) |   84   if (!is_visible_) | 
|   83     return; |   85     return; | 
|   84  |   86  | 
|   85   // If the app list is currently visible, there should be an existing view. |   87   // If the app list is currently visible, there should be an existing view. | 
|   86   DCHECK(view_); |   88   DCHECK(view_); | 
|   87  |   89  | 
|   88   is_visible_ = false; |   90   is_visible_ = false; | 
|   89   if (app_list_) |   91   if (app_list_) { | 
|   90     app_list_->OnTargetVisibilityChanged(GetTargetVisibility()); |   92     app_list_->OnTargetVisibilityChanged(GetTargetVisibility()); | 
|   91  |   93     app_list_->OnVisibilityChanged(GetTargetVisibility(), GetDisplayId()); | 
 |   94   } | 
|   92   // The dismissal may have occurred in response to the app list losing |   95   // The dismissal may have occurred in response to the app list losing | 
|   93   // activation. Otherwise, our widget is currently active. When the animation |   96   // activation. Otherwise, our widget is currently active. When the animation | 
|   94   // completes we'll hide the widget, changing activation. If a menu is shown |   97   // completes we'll hide the widget, changing activation. If a menu is shown | 
|   95   // before the animation completes then the activation change triggers the menu |   98   // before the animation completes then the activation change triggers the menu | 
|   96   // to close. By deactivating now we ensure there is no activation change when |   99   // to close. By deactivating now we ensure there is no activation change when | 
|   97   // the animation completes and any menus stay open. |  100   // the animation completes and any menus stay open. | 
|   98   if (view_->GetWidget()->IsActive()) |  101   if (view_->GetWidget()->IsActive()) | 
|   99     view_->GetWidget()->Deactivate(); |  102     view_->GetWidget()->Deactivate(); | 
|  100  |  103  | 
|  101   presenter_delegate_->OnDismissed(); |  104   presenter_delegate_->OnDismissed(); | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  296   } else if (should_snap_back_) { |  299   } else if (should_snap_back_) { | 
|  297     should_snap_back_ = false; |  300     should_snap_back_ = false; | 
|  298     ui::ScopedLayerAnimationSettings animation(widget_animator); |  301     ui::ScopedLayerAnimationSettings animation(widget_animator); | 
|  299     animation.SetTransitionDuration( |  302     animation.SetTransitionDuration( | 
|  300         base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); |  303         base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); | 
|  301     widget->SetBounds(view_bounds_); |  304     widget->SetBounds(view_bounds_); | 
|  302   } |  305   } | 
|  303 } |  306 } | 
|  304  |  307  | 
|  305 }  // namespace app_list |  308 }  // namespace app_list | 
| OLD | NEW |