| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/app_list_controller.h" | 5 #include "ash/wm/app_list_controller.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
| 11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
| 12 #include "ash/wm/property_util.h" | 12 #include "ash/wm/property_util.h" |
| 13 #include "ash/wm/shelf_layout_manager.h" | 13 #include "ash/wm/shelf_layout_manager.h" |
| 14 #include "ui/app_list/app_list_view.h" | 14 #include "ui/app_list/app_list_view.h" |
| 15 #include "ui/app_list/icon_cache.h" | |
| 16 #include "ui/app_list/pagination_model.h" | 15 #include "ui/app_list/pagination_model.h" |
| 17 #include "ui/aura/focus_manager.h" | 16 #include "ui/aura/focus_manager.h" |
| 18 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
| 19 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 20 #include "ui/base/events/event.h" | 19 #include "ui/base/events/event.h" |
| 21 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
| 22 #include "ui/compositor/scoped_layer_animation_settings.h" | 21 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 23 #include "ui/gfx/transform_util.h" | 22 #include "ui/gfx/transform_util.h" |
| 24 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 25 | 24 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 79 |
| 81 } // namespace | 80 } // namespace |
| 82 | 81 |
| 83 //////////////////////////////////////////////////////////////////////////////// | 82 //////////////////////////////////////////////////////////////////////////////// |
| 84 // AppListController, public: | 83 // AppListController, public: |
| 85 | 84 |
| 86 AppListController::AppListController() | 85 AppListController::AppListController() |
| 87 : pagination_model_(new app_list::PaginationModel), | 86 : pagination_model_(new app_list::PaginationModel), |
| 88 is_visible_(false), | 87 is_visible_(false), |
| 89 view_(NULL) { | 88 view_(NULL) { |
| 90 app_list::IconCache::CreateInstance(); | |
| 91 Shell::GetInstance()->AddShellObserver(this); | 89 Shell::GetInstance()->AddShellObserver(this); |
| 92 } | 90 } |
| 93 | 91 |
| 94 AppListController::~AppListController() { | 92 AppListController::~AppListController() { |
| 95 // Ensures app list view goes before the controller since pagination model | 93 // Ensures app list view goes before the controller since pagination model |
| 96 // lives in the controller and app list view would access it on destruction. | 94 // lives in the controller and app list view would access it on destruction. |
| 97 if (view_ && view_->GetWidget()) | 95 if (view_ && view_->GetWidget()) |
| 98 view_->GetWidget()->CloseNow(); | 96 view_->GetWidget()->CloseNow(); |
| 99 | 97 |
| 100 app_list::IconCache::DeleteInstance(); | |
| 101 Shell::GetInstance()->RemoveShellObserver(this); | 98 Shell::GetInstance()->RemoveShellObserver(this); |
| 102 } | 99 } |
| 103 | 100 |
| 104 void AppListController::SetVisible(bool visible) { | 101 void AppListController::SetVisible(bool visible) { |
| 105 if (visible == is_visible_) | 102 if (visible == is_visible_) |
| 106 return; | 103 return; |
| 107 | 104 |
| 108 is_visible_ = visible; | 105 is_visible_ = visible; |
| 109 | 106 |
| 110 // App list needs to know the new shelf layout in order to calculate its | 107 // App list needs to know the new shelf layout in order to calculate its |
| (...skipping 25 matching lines...) Expand all Loading... |
| 136 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; | 133 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; |
| 137 } | 134 } |
| 138 | 135 |
| 139 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
| 140 // AppListController, private: | 137 // AppListController, private: |
| 141 | 138 |
| 142 void AppListController::SetView(app_list::AppListView* view) { | 139 void AppListController::SetView(app_list::AppListView* view) { |
| 143 DCHECK(view_ == NULL); | 140 DCHECK(view_ == NULL); |
| 144 | 141 |
| 145 if (is_visible_) { | 142 if (is_visible_) { |
| 146 app_list::IconCache::GetInstance()->MarkAllEntryUnused(); | |
| 147 | |
| 148 view_ = view; | 143 view_ = view; |
| 149 views::Widget* widget = view_->GetWidget(); | 144 views::Widget* widget = view_->GetWidget(); |
| 150 widget->AddObserver(this); | 145 widget->AddObserver(this); |
| 151 Shell::GetInstance()->AddEnvEventFilter(this); | 146 Shell::GetInstance()->AddEnvEventFilter(this); |
| 152 Shell::GetInstance()->launcher()->AddIconObserver(this); | 147 Shell::GetInstance()->launcher()->AddIconObserver(this); |
| 153 widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); | 148 widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); |
| 154 widget->GetNativeView()->GetFocusManager()->AddObserver(this); | 149 widget->GetNativeView()->GetFocusManager()->AddObserver(this); |
| 155 widget->SetOpacity(0); | 150 widget->SetOpacity(0); |
| 156 ScheduleAnimation(); | 151 ScheduleAnimation(); |
| 157 | 152 |
| 158 view_->GetWidget()->Show(); | 153 view_->GetWidget()->Show(); |
| 159 } else { | 154 } else { |
| 160 view->GetWidget()->Close(); | 155 view->GetWidget()->Close(); |
| 161 } | 156 } |
| 162 } | 157 } |
| 163 | 158 |
| 164 void AppListController::ResetView() { | 159 void AppListController::ResetView() { |
| 165 if (!view_) | 160 if (!view_) |
| 166 return; | 161 return; |
| 167 | 162 |
| 168 views::Widget* widget = view_->GetWidget(); | 163 views::Widget* widget = view_->GetWidget(); |
| 169 widget->RemoveObserver(this); | 164 widget->RemoveObserver(this); |
| 170 GetLayer(widget)->GetAnimator()->RemoveObserver(this); | 165 GetLayer(widget)->GetAnimator()->RemoveObserver(this); |
| 171 Shell::GetInstance()->RemoveEnvEventFilter(this); | 166 Shell::GetInstance()->RemoveEnvEventFilter(this); |
| 172 Shell::GetInstance()->launcher()->RemoveIconObserver(this); | 167 Shell::GetInstance()->launcher()->RemoveIconObserver(this); |
| 173 widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this); | 168 widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this); |
| 174 widget->GetNativeView()->GetFocusManager()->RemoveObserver(this); | 169 widget->GetNativeView()->GetFocusManager()->RemoveObserver(this); |
| 175 view_ = NULL; | 170 view_ = NULL; |
| 176 | |
| 177 app_list::IconCache::GetInstance()->PurgeAllUnused(); | |
| 178 } | 171 } |
| 179 | 172 |
| 180 void AppListController::ScheduleAnimation() { | 173 void AppListController::ScheduleAnimation() { |
| 181 // Stop observing previous animation. | 174 // Stop observing previous animation. |
| 182 StopObservingImplicitAnimations(); | 175 StopObservingImplicitAnimations(); |
| 183 | 176 |
| 184 ui::Layer* layer = GetLayer(view_->GetWidget()); | 177 ui::Layer* layer = GetLayer(view_->GetWidget()); |
| 185 layer->GetAnimator()->StopAnimating(); | 178 layer->GetAnimator()->StopAnimating(); |
| 186 | 179 |
| 187 gfx::Rect target_bounds; | 180 gfx::Rect target_bounds; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 300 |
| 308 //////////////////////////////////////////////////////////////////////////////// | 301 //////////////////////////////////////////////////////////////////////////////// |
| 309 // AppListController, LauncherIconObserver implementation: | 302 // AppListController, LauncherIconObserver implementation: |
| 310 | 303 |
| 311 void AppListController::OnLauncherIconPositionsChanged() { | 304 void AppListController::OnLauncherIconPositionsChanged() { |
| 312 UpdateBounds(); | 305 UpdateBounds(); |
| 313 } | 306 } |
| 314 | 307 |
| 315 } // namespace internal | 308 } // namespace internal |
| 316 } // namespace ash | 309 } // namespace ash |
| OLD | NEW |