| 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   } |  | 
|   66  |   64  | 
|   67   if (view_) { |   65   if (view_) { | 
|   68     ScheduleAnimation(); |   66     ScheduleAnimation(); | 
|   69   } else { |   67   } else { | 
|   70     presenter_delegate_ = factory_->GetDelegate(this); |   68     presenter_delegate_ = factory_->GetDelegate(this); | 
|   71     AppListViewDelegate* view_delegate = presenter_delegate_->GetViewDelegate(); |   69     AppListViewDelegate* view_delegate = presenter_delegate_->GetViewDelegate(); | 
|   72     DCHECK(view_delegate); |   70     DCHECK(view_delegate); | 
|   73     // Note the AppListViewDelegate outlives the AppListView. For Ash, the view |   71     // Note the AppListViewDelegate outlives the AppListView. For Ash, the view | 
|   74     // is destroyed when dismissed. |   72     // is destroyed when dismissed. | 
|   75     AppListView* view = new AppListView(view_delegate); |   73     AppListView* view = new AppListView(view_delegate); | 
|   76     presenter_delegate_->Init(view, display_id, current_apps_page_); |   74     presenter_delegate_->Init(view, display_id, current_apps_page_); | 
|   77     SetView(view); |   75     SetView(view); | 
|   78   } |   76   } | 
|   79   presenter_delegate_->OnShown(display_id); |   77   presenter_delegate_->OnShown(display_id); | 
|   80   base::RecordAction(base::UserMetricsAction("Launcher_Show")); |   78   base::RecordAction(base::UserMetricsAction("Launcher_Show")); | 
|   81 } |   79 } | 
|   82  |   80  | 
|   83 void AppListPresenterImpl::Dismiss() { |   81 void AppListPresenterImpl::Dismiss() { | 
|   84   if (!is_visible_) |   82   if (!is_visible_) | 
|   85     return; |   83     return; | 
|   86  |   84  | 
|   87   // If the app list is currently visible, there should be an existing view. |   85   // If the app list is currently visible, there should be an existing view. | 
|   88   DCHECK(view_); |   86   DCHECK(view_); | 
|   89  |   87  | 
|   90   is_visible_ = false; |   88   is_visible_ = false; | 
|   91   if (app_list_) { |   89   if (app_list_) | 
|   92     app_list_->OnTargetVisibilityChanged(GetTargetVisibility()); |   90     app_list_->OnTargetVisibilityChanged(GetTargetVisibility()); | 
|   93     app_list_->OnVisibilityChanged(GetTargetVisibility(), GetDisplayId()); |   91  | 
|   94   } |  | 
|   95   // The dismissal may have occurred in response to the app list losing |   92   // The dismissal may have occurred in response to the app list losing | 
|   96   // activation. Otherwise, our widget is currently active. When the animation |   93   // activation. Otherwise, our widget is currently active. When the animation | 
|   97   // completes we'll hide the widget, changing activation. If a menu is shown |   94   // completes we'll hide the widget, changing activation. If a menu is shown | 
|   98   // before the animation completes then the activation change triggers the menu |   95   // before the animation completes then the activation change triggers the menu | 
|   99   // to close. By deactivating now we ensure there is no activation change when |   96   // to close. By deactivating now we ensure there is no activation change when | 
|  100   // the animation completes and any menus stay open. |   97   // the animation completes and any menus stay open. | 
|  101   if (view_->GetWidget()->IsActive()) |   98   if (view_->GetWidget()->IsActive()) | 
|  102     view_->GetWidget()->Deactivate(); |   99     view_->GetWidget()->Deactivate(); | 
|  103  |  100  | 
|  104   presenter_delegate_->OnDismissed(); |  101   presenter_delegate_->OnDismissed(); | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  299   } else if (should_snap_back_) { |  296   } else if (should_snap_back_) { | 
|  300     should_snap_back_ = false; |  297     should_snap_back_ = false; | 
|  301     ui::ScopedLayerAnimationSettings animation(widget_animator); |  298     ui::ScopedLayerAnimationSettings animation(widget_animator); | 
|  302     animation.SetTransitionDuration( |  299     animation.SetTransitionDuration( | 
|  303         base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); |  300         base::TimeDelta::FromMilliseconds(kOverscrollPageTransitionDurationMs)); | 
|  304     widget->SetBounds(view_bounds_); |  301     widget->SetBounds(view_bounds_); | 
|  305   } |  302   } | 
|  306 } |  303 } | 
|  307  |  304  | 
|  308 }  // namespace app_list |  305 }  // namespace app_list | 
| OLD | NEW |