| 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/app_list/app_list_presenter_delegate.h" | 5 #include "ash/app_list/app_list_presenter_delegate.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/shelf/app_list_button.h" | 8 #include "ash/common/shelf/app_list_button.h" |
| 9 #include "ash/common/shelf/shelf_layout_manager.h" | 9 #include "ash/common/shelf/shelf_layout_manager.h" |
| 10 #include "ash/common/shelf/shelf_widget.h" | 10 #include "ash/common/shelf/shelf_widget.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 13 #include "ash/common/wm/wm_screen_util.h" | 13 #include "ash/common/wm/wm_screen_util.h" |
| 14 #include "ash/common/wm_lookup.h" | |
| 15 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 17 #include "ash/display/window_tree_host_manager.h" | 16 #include "ash/display/window_tree_host_manager.h" |
| 18 #include "ash/public/cpp/shelf_types.h" | 17 #include "ash/public/cpp/shelf_types.h" |
| 19 #include "ash/public/cpp/shell_window_ids.h" | 18 #include "ash/public/cpp/shell_window_ids.h" |
| 20 #include "ash/root_window_controller.h" | 19 #include "ash/root_window_controller.h" |
| 21 #include "ash/screen_util.h" | 20 #include "ash/screen_util.h" |
| 22 #include "ash/shell.h" | 21 #include "ash/shell.h" |
| 23 #include "base/command_line.h" | 22 #include "base/command_line.h" |
| 24 #include "ui/app_list/app_list_constants.h" | 23 #include "ui/app_list/app_list_constants.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 WmShell::Get()->AddShellObserver(this); | 70 WmShell::Get()->AddShellObserver(this); |
| 72 } | 71 } |
| 73 | 72 |
| 74 AppListPresenterDelegate::~AppListPresenterDelegate() { | 73 AppListPresenterDelegate::~AppListPresenterDelegate() { |
| 75 DCHECK(view_); | 74 DCHECK(view_); |
| 76 keyboard::KeyboardController* keyboard_controller = | 75 keyboard::KeyboardController* keyboard_controller = |
| 77 keyboard::KeyboardController::GetInstance(); | 76 keyboard::KeyboardController::GetInstance(); |
| 78 if (keyboard_controller) | 77 if (keyboard_controller) |
| 79 keyboard_controller->RemoveObserver(this); | 78 keyboard_controller->RemoveObserver(this); |
| 80 Shell::GetInstance()->RemovePreTargetHandler(this); | 79 Shell::GetInstance()->RemovePreTargetHandler(this); |
| 81 WmWindow* window = WmLookup::Get()->GetWindowForWidget(view_->GetWidget()); | 80 WmWindow* window = WmWindow::Get(view_->GetWidget()->GetNativeWindow()); |
| 82 window->GetRootWindowController()->GetShelf()->RemoveObserver(this); | 81 window->GetRootWindowController()->GetShelf()->RemoveObserver(this); |
| 83 WmShell::Get()->RemoveShellObserver(this); | 82 WmShell::Get()->RemoveShellObserver(this); |
| 84 } | 83 } |
| 85 | 84 |
| 86 app_list::AppListViewDelegate* AppListPresenterDelegate::GetViewDelegate() { | 85 app_list::AppListViewDelegate* AppListPresenterDelegate::GetViewDelegate() { |
| 87 return view_delegate_factory_->GetDelegate(); | 86 return view_delegate_factory_->GetDelegate(); |
| 88 } | 87 } |
| 89 | 88 |
| 90 void AppListPresenterDelegate::Init(app_list::AppListView* view, | 89 void AppListPresenterDelegate::Init(app_list::AppListView* view, |
| 91 int64_t display_id, | 90 int64_t display_id, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 app_list_button->OnAppListShown(); | 130 app_list_button->OnAppListShown(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void AppListPresenterDelegate::OnDismissed() { | 133 void AppListPresenterDelegate::OnDismissed() { |
| 135 DCHECK(is_visible_); | 134 DCHECK(is_visible_); |
| 136 DCHECK(view_); | 135 DCHECK(view_); |
| 137 | 136 |
| 138 is_visible_ = false; | 137 is_visible_ = false; |
| 139 | 138 |
| 140 // Update applist button status when app list visibility is changed. | 139 // Update applist button status when app list visibility is changed. |
| 141 WmWindow* window = WmLookup::Get()->GetWindowForWidget(view_->GetWidget()); | 140 WmWindow* window = WmWindow::Get(view_->GetWidget()->GetNativeWindow()); |
| 142 AppListButton* app_list_button = | 141 AppListButton* app_list_button = |
| 143 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); | 142 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); |
| 144 if (app_list_button) | 143 if (app_list_button) |
| 145 app_list_button->OnAppListDismissed(); | 144 app_list_button->OnAppListDismissed(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void AppListPresenterDelegate::UpdateBounds() { | 147 void AppListPresenterDelegate::UpdateBounds() { |
| 149 if (!view_ || !is_visible_) | 148 if (!view_ || !is_visible_) |
| 150 return; | 149 return; |
| 151 | 150 |
| 152 view_->UpdateBounds(); | 151 view_->UpdateBounds(); |
| 153 view_->SetAnchorPoint(GetCenterOfDisplayForWindow( | 152 view_->SetAnchorPoint(GetCenterOfDisplayForWindow( |
| 154 WmLookup::Get()->GetWindowForWidget(view_->GetWidget()), | 153 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), |
| 155 GetMinimumBoundsHeightForAppList(view_))); | 154 GetMinimumBoundsHeightForAppList(view_))); |
| 156 } | 155 } |
| 157 | 156 |
| 158 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 157 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
| 159 aura::Window* root_window) { | 158 aura::Window* root_window) { |
| 160 DCHECK(Shell::HasInstance()); | 159 DCHECK(Shell::HasInstance()); |
| 161 | 160 |
| 162 // App list needs to know the new shelf layout in order to calculate its | 161 // App list needs to know the new shelf layout in order to calculate its |
| 163 // UI layout when AppListView visibility changes. | 162 // UI layout when AppListView visibility changes. |
| 164 WmShelf* shelf = WmShelf::ForWindow(WmWindow::Get(root_window)); | 163 WmShelf* shelf = WmShelf::ForWindow(WmWindow::Get(root_window)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 240 } |
| 242 | 241 |
| 243 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
| 244 // AppListPresenterDelegate, WmShelfObserver implementation: | 243 // AppListPresenterDelegate, WmShelfObserver implementation: |
| 245 | 244 |
| 246 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 245 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
| 247 UpdateBounds(); | 246 UpdateBounds(); |
| 248 } | 247 } |
| 249 | 248 |
| 250 } // namespace ash | 249 } // namespace ash |
| OLD | NEW |