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" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 aura::Window* AppListController::GetWindow() { | 147 aura::Window* AppListController::GetWindow() { |
148 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; | 148 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; |
149 } | 149 } |
150 | 150 |
151 //////////////////////////////////////////////////////////////////////////////// | 151 //////////////////////////////////////////////////////////////////////////////// |
152 // AppListController, private: | 152 // AppListController, private: |
153 | 153 |
154 void AppListController::SetView(app_list::AppListView* view) { | 154 void AppListController::SetView(app_list::AppListView* view) { |
155 DCHECK(view_ == NULL); | 155 DCHECK(view_ == NULL); |
| 156 DCHECK(is_visible_); |
156 | 157 |
157 if (is_visible_) { | 158 view_ = view; |
158 view_ = view; | 159 views::Widget* widget = view_->GetWidget(); |
159 views::Widget* widget = view_->GetWidget(); | 160 widget->AddObserver(this); |
160 widget->AddObserver(this); | 161 Shell::GetInstance()->AddPreTargetHandler(this); |
161 Shell::GetInstance()->AddPreTargetHandler(this); | 162 Launcher::ForWindow(GetWindow())->AddIconObserver(this); |
162 Launcher::ForWindow(GetWindow())->AddIconObserver(this); | 163 widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); |
163 widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); | 164 aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this); |
164 aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this); | |
165 widget->SetOpacity(0); | |
166 ScheduleAnimation(); | |
167 | 165 |
168 view_->GetWidget()->Show(); | 166 view_->ShowWhenReady(); |
169 } else { | |
170 view->GetWidget()->Close(); | |
171 } | |
172 } | 167 } |
173 | 168 |
174 void AppListController::ResetView() { | 169 void AppListController::ResetView() { |
175 if (!view_) | 170 if (!view_) |
176 return; | 171 return; |
177 | 172 |
178 views::Widget* widget = view_->GetWidget(); | 173 views::Widget* widget = view_->GetWidget(); |
179 widget->RemoveObserver(this); | 174 widget->RemoveObserver(this); |
180 GetLayer(widget)->GetAnimator()->RemoveObserver(this); | 175 GetLayer(widget)->GetAnimator()->RemoveObserver(this); |
181 Shell::GetInstance()->RemovePreTargetHandler(this); | 176 Shell::GetInstance()->RemovePreTargetHandler(this); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 should_snap_back_ = false; | 351 should_snap_back_ = false; |
357 ui::ScopedLayerAnimationSettings animation(widget_animator); | 352 ui::ScopedLayerAnimationSettings animation(widget_animator); |
358 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 353 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
359 app_list::kOverscrollPageTransitionDurationMs)); | 354 app_list::kOverscrollPageTransitionDurationMs)); |
360 widget->SetBounds(view_bounds_); | 355 widget->SetBounds(view_bounds_); |
361 } | 356 } |
362 } | 357 } |
363 | 358 |
364 } // namespace internal | 359 } // namespace internal |
365 } // namespace ash | 360 } // namespace ash |
OLD | NEW |