Chromium Code Reviews| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" | 
| 8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" | 
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" | 
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" | 
| 11 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" | 
| 12 #include "ash/shelf/app_list_button.h" | 12 #include "ash/shelf/app_list_button.h" | 
| 13 #include "ash/shelf/shelf.h" | 13 #include "ash/shelf/shelf.h" | 
| 14 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" | 
| 15 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" | 
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" | 
| 17 #include "ash/shell_observer.h" | |
| 17 #include "ash/shell_port.h" | 18 #include "ash/shell_port.h" | 
| 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 
| 19 #include "base/command_line.h" | 20 #include "base/command_line.h" | 
| 20 #include "ui/app_list/app_list_constants.h" | 21 #include "ui/app_list/app_list_constants.h" | 
| 21 #include "ui/app_list/app_list_features.h" | 22 #include "ui/app_list/app_list_features.h" | 
| 22 #include "ui/app_list/app_list_switches.h" | 23 #include "ui/app_list/app_list_switches.h" | 
| 23 #include "ui/app_list/presenter/app_list_presenter_impl.h" | 24 #include "ui/app_list/presenter/app_list_presenter_impl.h" | 
| 24 #include "ui/app_list/presenter/app_list_view_delegate_factory.h" | 25 #include "ui/app_list/presenter/app_list_view_delegate_factory.h" | 
| 25 #include "ui/app_list/views/app_list_view.h" | 26 #include "ui/app_list/views/app_list_view.h" | 
| 26 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" | 
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 | 113 | 
| 113 // By setting us as DnD recipient, the app list knows that we can | 114 // By setting us as DnD recipient, the app list knows that we can | 
| 114 // handle items. | 115 // handle items. | 
| 115 Shelf* shelf = Shelf::ForWindow(root_window); | 116 Shelf* shelf = Shelf::ForWindow(root_window); | 
| 116 view->SetDragAndDropHostOfCurrentAppList( | 117 view->SetDragAndDropHostOfCurrentAppList( | 
| 117 shelf->shelf_widget()->GetDragAndDropHostForAppList()); | 118 shelf->shelf_widget()->GetDragAndDropHostForAppList()); | 
| 118 } | 119 } | 
| 119 | 120 | 
| 120 void AppListPresenterDelegate::OnShown(int64_t display_id) { | 121 void AppListPresenterDelegate::OnShown(int64_t display_id) { | 
| 121 is_visible_ = true; | 122 is_visible_ = true; | 
| 122 // Update applist button status when app list visibility is changed. | |
| 123 aura::Window* root_window = | 123 aura::Window* root_window = | 
| 124 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 124 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 
| 125 AppListButton* app_list_button = | 125 Shell::Get()->NotifyAppListShownOrDismissed(is_visible_, root_window); | 
| 
 
xiyuan
2017/06/06 15:51:04
Think we can remove this code block from Line 123-
 
newcomer
2017/06/06 16:42:29
Done.
 
 | |
| 126 Shelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); | |
| 127 if (app_list_button) | |
| 128 app_list_button->OnAppListShown(); | |
| 129 } | 126 } | 
| 130 | 127 | 
| 131 void AppListPresenterDelegate::OnDismissed() { | 128 void AppListPresenterDelegate::OnDismissed() { | 
| 132 DCHECK(is_visible_); | 129 DCHECK(is_visible_); | 
| 133 DCHECK(view_); | 130 DCHECK(view_); | 
| 134 | |
| 135 is_visible_ = false; | 131 is_visible_ = false; | 
| 136 | 132 | 
| 137 // Update applist button status when app list visibility is changed. | 133 aura::Window* root_window = | 
| 138 Shelf* shelf = Shelf::ForWindow(view_->GetWidget()->GetNativeWindow()); | 134 RootWindowController::ForTargetRootWindow()->GetRootWindow(); | 
| 139 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton(); | 135 Shell::Get()->NotifyAppListShownOrDismissed(is_visible_, root_window); | 
| 140 if (app_list_button) | |
| 141 app_list_button->OnAppListDismissed(); | |
| 142 } | 136 } | 
| 143 | 137 | 
| 144 void AppListPresenterDelegate::UpdateBounds() { | 138 void AppListPresenterDelegate::UpdateBounds() { | 
| 145 if (!view_ || !is_visible_) | 139 if (!view_ || !is_visible_) | 
| 146 return; | 140 return; | 
| 147 | 141 | 
| 148 view_->UpdateBounds(); | 142 view_->UpdateBounds(); | 
| 149 view_->MaybeSetAnchorPoint( | 143 view_->MaybeSetAnchorPoint( | 
| 150 GetCenterOfDisplayForWindow(view_->GetWidget()->GetNativeWindow(), | 144 GetCenterOfDisplayForWindow(view_->GetWidget()->GetNativeWindow(), | 
| 151 GetMinimumBoundsHeightForAppList(view_))); | 145 GetMinimumBoundsHeightForAppList(view_))); | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 void AppListPresenterDelegate::OnKeyboardClosed() {} | 224 void AppListPresenterDelegate::OnKeyboardClosed() {} | 
| 231 | 225 | 
| 232 //////////////////////////////////////////////////////////////////////////////// | 226 //////////////////////////////////////////////////////////////////////////////// | 
| 233 // AppListPresenterDelegate, ShellObserver implementation: | 227 // AppListPresenterDelegate, ShellObserver implementation: | 
| 234 void AppListPresenterDelegate::OnOverviewModeStarting() { | 228 void AppListPresenterDelegate::OnOverviewModeStarting() { | 
| 235 if (is_visible_) | 229 if (is_visible_) | 
| 236 presenter_->Dismiss(); | 230 presenter_->Dismiss(); | 
| 237 } | 231 } | 
| 238 | 232 | 
| 239 } // namespace ash | 233 } // namespace ash | 
| OLD | NEW |