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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 108 } |
109 | 109 |
110 void AppListController::SetVisible(bool visible) { | 110 void AppListController::SetVisible(bool visible) { |
111 if (visible == is_visible_) | 111 if (visible == is_visible_) |
112 return; | 112 return; |
113 | 113 |
114 is_visible_ = visible; | 114 is_visible_ = visible; |
115 | 115 |
116 // App list needs to know the new shelf layout in order to calculate its | 116 // App list needs to know the new shelf layout in order to calculate its |
117 // UI layout when AppListView visibility changes. | 117 // UI layout when AppListView visibility changes. |
118 Shell::GetInstance()->shelf()->UpdateAutoHideState(); | 118 Shell::GetPrimaryRootWindowController()->shelf()->UpdateAutoHideState(); |
119 | 119 |
120 if (view_) { | 120 if (view_) { |
121 ScheduleAnimation(); | 121 ScheduleAnimation(); |
122 } else if (is_visible_) { | 122 } else if (is_visible_) { |
123 // AppListModel and AppListViewDelegate are owned by AppListView. They | 123 // AppListModel and AppListViewDelegate are owned by AppListView. They |
124 // will be released with AppListView on close. | 124 // will be released with AppListView on close. |
125 app_list::AppListView* view = new app_list::AppListView( | 125 app_list::AppListView* view = new app_list::AppListView( |
126 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); | 126 Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); |
127 view->InitAsBubble( | 127 view->InitAsBubble( |
128 Shell::GetPrimaryRootWindowController()->GetContainer( | 128 Shell::GetPrimaryRootWindowController()->GetContainer( |
129 kShellWindowId_AppListContainer), | 129 kShellWindowId_AppListContainer), |
130 pagination_model_.get(), | 130 pagination_model_.get(), |
131 Shell::GetInstance()->launcher()->GetAppListButtonView(), | 131 Launcher::ForWindow(GetWindow())->GetAppListButtonView(), |
132 gfx::Point(), | 132 gfx::Point(), |
133 GetBubbleArrowLocation()); | 133 GetBubbleArrowLocation()); |
134 SetView(view); | 134 SetView(view); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 bool AppListController::IsVisible() const { | 138 bool AppListController::IsVisible() const { |
139 return view_ && view_->GetWidget()->IsVisible(); | 139 return view_ && view_->GetWidget()->IsVisible(); |
140 } | 140 } |
141 | 141 |
142 aura::Window* AppListController::GetWindow() { | 142 aura::Window* AppListController::GetWindow() { |
143 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; | 143 return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; |
144 } | 144 } |
145 | 145 |
146 //////////////////////////////////////////////////////////////////////////////// | 146 //////////////////////////////////////////////////////////////////////////////// |
147 // AppListController, private: | 147 // AppListController, private: |
148 | 148 |
149 void AppListController::SetView(app_list::AppListView* view) { | 149 void AppListController::SetView(app_list::AppListView* view) { |
150 DCHECK(view_ == NULL); | 150 DCHECK(view_ == NULL); |
151 | 151 |
152 if (is_visible_) { | 152 if (is_visible_) { |
153 view_ = view; | 153 view_ = view; |
154 views::Widget* widget = view_->GetWidget(); | 154 views::Widget* widget = view_->GetWidget(); |
155 widget->AddObserver(this); | 155 widget->AddObserver(this); |
156 Shell::GetInstance()->AddEnvEventFilter(this); | 156 Shell::GetInstance()->AddEnvEventFilter(this); |
157 Shell::GetInstance()->launcher()->AddIconObserver(this); | 157 Launcher::ForWindow(GetWindow())->AddIconObserver(this); |
158 widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); | 158 widget->GetNativeView()->GetRootWindow()->AddRootWindowObserver(this); |
159 widget->GetNativeView()->GetFocusManager()->AddObserver(this); | 159 widget->GetNativeView()->GetFocusManager()->AddObserver(this); |
160 widget->SetOpacity(0); | 160 widget->SetOpacity(0); |
161 ScheduleAnimation(); | 161 ScheduleAnimation(); |
162 | 162 |
163 view_->GetWidget()->Show(); | 163 view_->GetWidget()->Show(); |
164 } else { | 164 } else { |
165 view->GetWidget()->Close(); | 165 view->GetWidget()->Close(); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 void AppListController::ResetView() { | 169 void AppListController::ResetView() { |
170 if (!view_) | 170 if (!view_) |
171 return; | 171 return; |
172 | 172 |
173 views::Widget* widget = view_->GetWidget(); | 173 views::Widget* widget = view_->GetWidget(); |
174 widget->RemoveObserver(this); | 174 widget->RemoveObserver(this); |
175 GetLayer(widget)->GetAnimator()->RemoveObserver(this); | 175 GetLayer(widget)->GetAnimator()->RemoveObserver(this); |
176 Shell::GetInstance()->RemoveEnvEventFilter(this); | 176 Shell::GetInstance()->RemoveEnvEventFilter(this); |
177 Shell::GetInstance()->launcher()->RemoveIconObserver(this); | 177 Launcher::ForWindow(GetWindow())->RemoveIconObserver(this); |
178 widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this); | 178 widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this); |
179 widget->GetNativeView()->GetFocusManager()->RemoveObserver(this); | 179 widget->GetNativeView()->GetFocusManager()->RemoveObserver(this); |
180 view_ = NULL; | 180 view_ = NULL; |
181 } | 181 } |
182 | 182 |
183 void AppListController::ScheduleAnimation() { | 183 void AppListController::ScheduleAnimation() { |
184 // Stop observing previous animation. | 184 // Stop observing previous animation. |
185 StopObservingImplicitAnimations(); | 185 StopObservingImplicitAnimations(); |
186 | 186 |
187 views::Widget* widget = view_->GetWidget(); | 187 views::Widget* widget = view_->GetWidget(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 should_snap_back_ = false; | 356 should_snap_back_ = false; |
357 ui::ScopedLayerAnimationSettings animation(GetLayer(widget)->GetAnimator()); | 357 ui::ScopedLayerAnimationSettings animation(GetLayer(widget)->GetAnimator()); |
358 animation.SetTransitionDuration( | 358 animation.SetTransitionDuration( |
359 base::TimeDelta::FromMilliseconds(kSnapBackAnimationDurationMs)); | 359 base::TimeDelta::FromMilliseconds(kSnapBackAnimationDurationMs)); |
360 widget->SetBounds(view_bounds_); | 360 widget->SetBounds(view_bounds_); |
361 } | 361 } |
362 } | 362 } |
363 | 363 |
364 } // namespace internal | 364 } // namespace internal |
365 } // namespace ash | 365 } // namespace ash |
OLD | NEW |