Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: ash/shell.cc

Issue 2169533002: mash: Migrate shelf app list button to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shell.h ('k') | ash/shell/app_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/accelerators/accelerator_controller.h" 11 #include "ash/accelerators/accelerator_controller.h"
12 #include "ash/accelerators/accelerator_controller_delegate_aura.h" 12 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
13 #include "ash/accelerators/accelerator_delegate.h" 13 #include "ash/accelerators/accelerator_delegate.h"
14 #include "ash/accelerators/focus_manager_factory.h" 14 #include "ash/accelerators/focus_manager_factory.h"
15 #include "ash/aura/wm_shell_aura.h" 15 #include "ash/aura/wm_shell_aura.h"
16 #include "ash/aura/wm_window_aura.h" 16 #include "ash/aura/wm_window_aura.h"
17 #include "ash/autoclick/autoclick_controller.h" 17 #include "ash/autoclick/autoclick_controller.h"
18 #include "ash/common/ash_switches.h" 18 #include "ash/common/ash_switches.h"
19 #include "ash/common/gpu_support.h" 19 #include "ash/common/gpu_support.h"
20 #include "ash/common/keyboard/keyboard_ui.h" 20 #include "ash/common/keyboard/keyboard_ui.h"
21 #include "ash/common/login_status.h" 21 #include "ash/common/login_status.h"
22 #include "ash/common/pointer_down_watcher_delegate.h" 22 #include "ash/common/pointer_down_watcher_delegate.h"
23 #include "ash/common/session/session_state_delegate.h" 23 #include "ash/common/session/session_state_delegate.h"
24 #include "ash/common/shelf/app_list_shelf_item_delegate.h"
24 #include "ash/common/shelf/shelf_item_delegate.h" 25 #include "ash/common/shelf/shelf_item_delegate.h"
25 #include "ash/common/shelf/shelf_item_delegate_manager.h" 26 #include "ash/common/shelf/shelf_item_delegate_manager.h"
26 #include "ash/common/shelf/shelf_model.h" 27 #include "ash/common/shelf/shelf_model.h"
27 #include "ash/common/shell_delegate.h" 28 #include "ash/common/shell_delegate.h"
28 #include "ash/common/shell_window_ids.h" 29 #include "ash/common/shell_window_ids.h"
29 #include "ash/common/system/locale/locale_notification_controller.h" 30 #include "ash/common/system/locale/locale_notification_controller.h"
30 #include "ash/common/system/status_area_widget.h" 31 #include "ash/common/system/status_area_widget.h"
31 #include "ash/common/system/toast/toast_manager.h" 32 #include "ash/common/system/toast/toast_manager.h"
32 #include "ash/common/system/tray/system_tray_delegate.h" 33 #include "ash/common/system/tray/system_tray_delegate.h"
33 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 34 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
(...skipping 16 matching lines...) Expand all
50 #include "ash/first_run/first_run_helper_impl.h" 51 #include "ash/first_run/first_run_helper_impl.h"
51 #include "ash/frame/custom_frame_view_ash.h" 52 #include "ash/frame/custom_frame_view_ash.h"
52 #include "ash/high_contrast/high_contrast_controller.h" 53 #include "ash/high_contrast/high_contrast_controller.h"
53 #include "ash/host/ash_window_tree_host_init_params.h" 54 #include "ash/host/ash_window_tree_host_init_params.h"
54 #include "ash/ime/input_method_event_handler.h" 55 #include "ash/ime/input_method_event_handler.h"
55 #include "ash/keyboard_uma_event_filter.h" 56 #include "ash/keyboard_uma_event_filter.h"
56 #include "ash/magnifier/magnification_controller.h" 57 #include "ash/magnifier/magnification_controller.h"
57 #include "ash/magnifier/partial_magnification_controller.h" 58 #include "ash/magnifier/partial_magnification_controller.h"
58 #include "ash/new_window_delegate.h" 59 #include "ash/new_window_delegate.h"
59 #include "ash/root_window_controller.h" 60 #include "ash/root_window_controller.h"
60 #include "ash/shelf/app_list_shelf_item_delegate.h"
61 #include "ash/shelf/shelf.h" 61 #include "ash/shelf/shelf.h"
62 #include "ash/shelf/shelf_delegate.h" 62 #include "ash/shelf/shelf_delegate.h"
63 #include "ash/shelf/shelf_widget.h" 63 #include "ash/shelf/shelf_widget.h"
64 #include "ash/shelf/shelf_window_watcher.h" 64 #include "ash/shelf/shelf_window_watcher.h"
65 #include "ash/shell_factory.h" 65 #include "ash/shell_factory.h"
66 #include "ash/shell_init_params.h" 66 #include "ash/shell_init_params.h"
67 #include "ash/utility/screenshot_controller.h" 67 #include "ash/utility/screenshot_controller.h"
68 #include "ash/wm/ash_focus_rules.h" 68 #include "ash/wm/ash_focus_rules.h"
69 #include "ash/wm/ash_native_cursor_manager.h" 69 #include "ash/wm/ash_native_cursor_manager.h"
70 #include "ash/wm/event_client_impl.h" 70 #include "ash/wm/event_client_impl.h"
71 #include "ash/wm/lock_state_controller.h" 71 #include "ash/wm/lock_state_controller.h"
72 #include "ash/wm/overlay_event_filter.h" 72 #include "ash/wm/overlay_event_filter.h"
73 #include "ash/wm/overview/scoped_overview_animation_settings_factory_aura.h" 73 #include "ash/wm/overview/scoped_overview_animation_settings_factory_aura.h"
74 #include "ash/wm/power_button_controller.h" 74 #include "ash/wm/power_button_controller.h"
75 #include "ash/wm/resize_shadow_controller.h" 75 #include "ash/wm/resize_shadow_controller.h"
76 #include "ash/wm/screen_pinning_controller.h" 76 #include "ash/wm/screen_pinning_controller.h"
77 #include "ash/wm/system_gesture_event_filter.h" 77 #include "ash/wm/system_gesture_event_filter.h"
78 #include "ash/wm/system_modal_container_event_filter.h" 78 #include "ash/wm/system_modal_container_event_filter.h"
79 #include "ash/wm/system_modal_container_layout_manager.h" 79 #include "ash/wm/system_modal_container_layout_manager.h"
80 #include "ash/wm/toplevel_window_event_handler.h" 80 #include "ash/wm/toplevel_window_event_handler.h"
81 #include "ash/wm/video_detector.h" 81 #include "ash/wm/video_detector.h"
82 #include "ash/wm/window_animations.h" 82 #include "ash/wm/window_animations.h"
83 #include "ash/wm/window_properties.h" 83 #include "ash/wm/window_properties.h"
84 #include "ash/wm/window_util.h" 84 #include "ash/wm/window_util.h"
85 #include "ash/wm/workspace_controller.h" 85 #include "ash/wm/workspace_controller.h"
86 #include "base/bind.h" 86 #include "base/bind.h"
87 #include "base/memory/ptr_util.h" 87 #include "base/memory/ptr_util.h"
88 #include "base/trace_event/trace_event.h" 88 #include "base/trace_event/trace_event.h"
89 #include "ui/app_list/presenter/app_list_presenter.h"
90 #include "ui/aura/client/aura_constants.h" 89 #include "ui/aura/client/aura_constants.h"
91 #include "ui/aura/env.h" 90 #include "ui/aura/env.h"
92 #include "ui/aura/layout_manager.h" 91 #include "ui/aura/layout_manager.h"
93 #include "ui/aura/window.h" 92 #include "ui/aura/window.h"
94 #include "ui/aura/window_event_dispatcher.h" 93 #include "ui/aura/window_event_dispatcher.h"
95 #include "ui/base/ui_base_switches.h" 94 #include "ui/base/ui_base_switches.h"
96 #include "ui/base/user_activity/user_activity_detector.h" 95 #include "ui/base/user_activity/user_activity_detector.h"
97 #include "ui/compositor/layer.h" 96 #include "ui/compositor/layer.h"
98 #include "ui/compositor/layer_animator.h" 97 #include "ui/compositor/layer_animator.h"
99 #include "ui/display/display.h" 98 #include "ui/display/display.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 #endif 153 #endif
155 #endif // defined(OS_CHROMEOS) 154 #endif // defined(OS_CHROMEOS)
156 155
157 namespace ash { 156 namespace ash {
158 157
159 namespace { 158 namespace {
160 159
161 using aura::Window; 160 using aura::Window;
162 using views::Widget; 161 using views::Widget;
163 162
164 // Returns the display id corresponding to window, or |GetTargetDisplayId()|
165 // if |window| is null.
166 int64_t GetDisplayIdForWindow(aura::Window* window) {
167 if (!window)
168 return Shell::GetTargetDisplayId();
169 return display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
170 }
171
172 // A Corewm VisibilityController subclass that calls the Ash animation routine 163 // A Corewm VisibilityController subclass that calls the Ash animation routine
173 // so we can pick up our extended animations. See ash/wm/window_animations.h. 164 // so we can pick up our extended animations. See ash/wm/window_animations.h.
174 class AshVisibilityController : public ::wm::VisibilityController { 165 class AshVisibilityController : public ::wm::VisibilityController {
175 public: 166 public:
176 AshVisibilityController() {} 167 AshVisibilityController() {}
177 ~AshVisibilityController() override {} 168 ~AshVisibilityController() override {}
178 169
179 private: 170 private:
180 // Overridden from ::wm::VisibilityController: 171 // Overridden from ::wm::VisibilityController:
181 bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window, 172 bool CallAnimateOnChildWindowVisibilityChanged(aura::Window* window,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // No context menus when screen is locked. 300 // No context menus when screen is locked.
310 if (session_state_delegate_->IsScreenLocked()) 301 if (session_state_delegate_->IsScreenLocked())
311 return; 302 return;
312 303
313 aura::Window* root = WmWindowAura::GetAuraWindow( 304 aura::Window* root = WmWindowAura::GetAuraWindow(
314 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size()))); 305 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())));
315 GetRootWindowController(root)->ShowContextMenu(location_in_screen, 306 GetRootWindowController(root)->ShowContextMenu(location_in_screen,
316 source_type); 307 source_type);
317 } 308 }
318 309
319 void Shell::ShowAppList(aura::Window* window) {
320 // If the context window is not given, show it on the target root window.
321 wm_shell_->delegate()->GetAppListPresenter()->Show(
322 GetDisplayIdForWindow(window));
323 }
324
325 void Shell::DismissAppList() {
326 wm_shell_->delegate()->GetAppListPresenter()->Dismiss();
327 }
328
329 void Shell::ToggleAppList(aura::Window* window) {
330 // If the context window is not given, show it on the target root window.
331 wm_shell_->delegate()->GetAppListPresenter()->ToggleAppList(
332 GetDisplayIdForWindow(window));
333 }
334
335 bool Shell::IsApplistVisible() const {
336 return wm_shell_->delegate()->GetAppListPresenter()->IsVisible();
337 }
338
339 bool Shell::GetAppListTargetVisibility() const {
340 return wm_shell_->delegate()->GetAppListPresenter()->GetTargetVisibility();
341 }
342
343 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( 310 views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView(
344 views::Widget* widget) { 311 views::Widget* widget) {
345 // Use translucent-style window frames for dialogs. 312 // Use translucent-style window frames for dialogs.
346 return new CustomFrameViewAsh(widget); 313 return new CustomFrameViewAsh(widget);
347 } 314 }
348 315
349 void Shell::SetDisplayWorkAreaInsets(Window* contains, 316 void Shell::SetDisplayWorkAreaInsets(Window* contains,
350 const gfx::Insets& insets) { 317 const gfx::Insets& insets) {
351 if (!window_tree_host_manager_->UpdateWorkAreaOfDisplayNearestWindow( 318 if (!window_tree_host_manager_->UpdateWorkAreaOfDisplayNearestWindow(
352 contains, insets)) { 319 contains, insets)) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf_widget(); 500 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf_widget();
534 return shelf && shelf->status_area_widget(); 501 return shelf && shelf->status_area_widget();
535 } 502 }
536 503
537 SystemTray* Shell::GetPrimarySystemTray() { 504 SystemTray* Shell::GetPrimarySystemTray() {
538 return GetPrimaryRootWindowController()->GetSystemTray(); 505 return GetPrimaryRootWindowController()->GetSystemTray();
539 } 506 }
540 507
541 ShelfDelegate* Shell::GetShelfDelegate() { 508 ShelfDelegate* Shell::GetShelfDelegate() {
542 if (!shelf_delegate_) { 509 if (!shelf_delegate_) {
510 ShelfModel* shelf_model = wm_shell_->shelf_model();
543 // Creates ShelfItemDelegateManager before ShelfDelegate. 511 // Creates ShelfItemDelegateManager before ShelfDelegate.
512 // TODO(jamescook): Move this into WmShell.
544 shelf_item_delegate_manager_.reset( 513 shelf_item_delegate_manager_.reset(
545 new ShelfItemDelegateManager(shelf_model_.get())); 514 new ShelfItemDelegateManager(shelf_model));
546 515
547 shelf_delegate_.reset( 516 shelf_delegate_.reset(
548 wm_shell_->delegate()->CreateShelfDelegate(shelf_model_.get())); 517 wm_shell_->delegate()->CreateShelfDelegate(shelf_model));
549 std::unique_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate); 518 std::unique_ptr<ShelfItemDelegate> controller(new AppListShelfItemDelegate);
550 519
551 // Finding the shelf model's location of the app list and setting its 520 // Finding the shelf model's location of the app list and setting its
552 // ShelfItemDelegate. 521 // ShelfItemDelegate.
553 int app_list_index = shelf_model_->GetItemIndexForType(TYPE_APP_LIST); 522 int app_list_index = shelf_model->GetItemIndexForType(TYPE_APP_LIST);
554 DCHECK_GE(app_list_index, 0); 523 DCHECK_GE(app_list_index, 0);
555 ShelfID app_list_id = shelf_model_->items()[app_list_index].id; 524 ShelfID app_list_id = shelf_model->items()[app_list_index].id;
556 DCHECK(app_list_id); 525 DCHECK(app_list_id);
557 shelf_item_delegate_manager_->SetShelfItemDelegate(app_list_id, 526 shelf_item_delegate_manager_->SetShelfItemDelegate(app_list_id,
558 std::move(controller)); 527 std::move(controller));
559 shelf_window_watcher_.reset(new ShelfWindowWatcher( 528 shelf_window_watcher_.reset(new ShelfWindowWatcher(
560 shelf_model_.get(), shelf_item_delegate_manager_.get())); 529 shelf_model, shelf_item_delegate_manager_.get()));
561 } 530 }
562 return shelf_delegate_.get(); 531 return shelf_delegate_.get();
563 } 532 }
564 533
565 void Shell::SetTouchHudProjectionEnabled(bool enabled) { 534 void Shell::SetTouchHudProjectionEnabled(bool enabled) {
566 if (is_touch_hud_projection_enabled_ == enabled) 535 if (is_touch_hud_projection_enabled_ == enabled)
567 return; 536 return;
568 537
569 is_touch_hud_projection_enabled_ = enabled; 538 is_touch_hud_projection_enabled_ = enabled;
570 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(), 539 FOR_EACH_OBSERVER(ShellObserver, *wm_shell_->shell_observers(),
(...skipping 18 matching lines...) Expand all
589 ->DoInitialAnimation(); 558 ->DoInitialAnimation();
590 } 559 }
591 560
592 //////////////////////////////////////////////////////////////////////////////// 561 ////////////////////////////////////////////////////////////////////////////////
593 // Shell, private: 562 // Shell, private:
594 563
595 Shell::Shell(ShellDelegate* delegate, base::SequencedWorkerPool* blocking_pool) 564 Shell::Shell(ShellDelegate* delegate, base::SequencedWorkerPool* blocking_pool)
596 : wm_shell_(new WmShellAura(base::WrapUnique(delegate))), 565 : wm_shell_(new WmShellAura(base::WrapUnique(delegate))),
597 target_root_window_(nullptr), 566 target_root_window_(nullptr),
598 scoped_target_root_window_(nullptr), 567 scoped_target_root_window_(nullptr),
599 shelf_model_(new ShelfModel),
600 link_handler_model_factory_(nullptr), 568 link_handler_model_factory_(nullptr),
601 activation_client_(nullptr), 569 activation_client_(nullptr),
602 #if defined(OS_CHROMEOS) 570 #if defined(OS_CHROMEOS)
603 display_configurator_(new ui::DisplayConfigurator()), 571 display_configurator_(new ui::DisplayConfigurator()),
604 #endif // defined(OS_CHROMEOS) 572 #endif // defined(OS_CHROMEOS)
605 native_cursor_manager_(nullptr), 573 native_cursor_manager_(nullptr),
606 simulate_modal_window_open_for_testing_(false), 574 simulate_modal_window_open_for_testing_(false),
607 is_touch_hud_projection_enabled_(false), 575 is_touch_hud_projection_enabled_(false),
608 blocking_pool_(blocking_pool) { 576 blocking_pool_(blocking_pool) {
609 DCHECK(aura::Env::GetInstanceDontCreate()); 577 DCHECK(aura::Env::GetInstanceDontCreate());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 video_detector_.reset(); 668 video_detector_.reset();
701 high_contrast_controller_.reset(); 669 high_contrast_controller_.reset();
702 670
703 shadow_controller_.reset(); 671 shadow_controller_.reset();
704 resize_shadow_controller_.reset(); 672 resize_shadow_controller_.reset();
705 673
706 // Has to happen before ~MruWindowTracker. 674 // Has to happen before ~MruWindowTracker.
707 wm_shell_->DeleteWindowCycleController(); 675 wm_shell_->DeleteWindowCycleController();
708 wm_shell_->DeleteWindowSelectorController(); 676 wm_shell_->DeleteWindowSelectorController();
709 677
710 // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| 678 // |shelf_window_watcher_| has a weak pointer to the shelf model and has
711 // and has window observers. 679 // window observers.
712 shelf_window_watcher_.reset(); 680 shelf_window_watcher_.reset();
713 681
714 // Destroy all child windows including widgets. 682 // Destroy all child windows including widgets.
715 window_tree_host_manager_->CloseChildWindows(); 683 window_tree_host_manager_->CloseChildWindows();
716 // MruWindowTracker must be destroyed after all windows have been deleted to 684 // MruWindowTracker must be destroyed after all windows have been deleted to
717 // avoid a possible crash when Shell is destroyed from a non-normal shutdown 685 // avoid a possible crash when Shell is destroyed from a non-normal shutdown
718 // path. (crbug.com/485438). 686 // path. (crbug.com/485438).
719 wm_shell_->DeleteMruWindowTracker(); 687 wm_shell_->DeleteMruWindowTracker();
720 688
721 // Chrome implementation of shelf delegate depends on FocusClient, 689 // Chrome implementation of shelf delegate depends on FocusClient,
722 // so must be deleted before |focus_client_| (below). 690 // so must be deleted before |focus_client_| (below).
723 shelf_delegate_.reset(); 691 shelf_delegate_.reset();
724 692
725 // These need a valid Shell instance to clean up properly, so explicitly 693 // These need a valid Shell instance to clean up properly, so explicitly
726 // delete them before invalidating the instance. 694 // delete them before invalidating the instance.
727 // Alphabetical. TODO(oshima): sort. 695 // Alphabetical. TODO(oshima): sort.
728 magnification_controller_.reset(); 696 magnification_controller_.reset();
729 partial_magnification_controller_.reset(); 697 partial_magnification_controller_.reset();
730 tooltip_controller_.reset(); 698 tooltip_controller_.reset();
731 event_client_.reset(); 699 event_client_.reset();
732 toplevel_window_event_handler_.reset(); 700 toplevel_window_event_handler_.reset();
733 visibility_controller_.reset(); 701 visibility_controller_.reset();
734 // |shelf_item_delegate_manager_| observes |shelf_model_|. It must be 702 // |shelf_item_delegate_manager_| observes the shelf model.
735 // destroyed before |shelf_model_| is destroyed.
736 shelf_item_delegate_manager_.reset(); 703 shelf_item_delegate_manager_.reset();
737 shelf_model_.reset();
738 704
739 power_button_controller_.reset(); 705 power_button_controller_.reset();
740 lock_state_controller_.reset(); 706 lock_state_controller_.reset();
741 707
742 screen_pinning_controller_.reset(); 708 screen_pinning_controller_.reset();
743 709
744 #if defined(OS_CHROMEOS) 710 #if defined(OS_CHROMEOS)
745 resolution_notification_controller_.reset(); 711 resolution_notification_controller_.reset();
746 #endif 712 #endif
747 desktop_background_controller_.reset(); 713 desktop_background_controller_.reset();
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1131
1166 void Shell::OnWindowActivated( 1132 void Shell::OnWindowActivated(
1167 aura::client::ActivationChangeObserver::ActivationReason reason, 1133 aura::client::ActivationChangeObserver::ActivationReason reason,
1168 aura::Window* gained_active, 1134 aura::Window* gained_active,
1169 aura::Window* lost_active) { 1135 aura::Window* lost_active) {
1170 if (gained_active) 1136 if (gained_active)
1171 target_root_window_ = gained_active->GetRootWindow(); 1137 target_root_window_ = gained_active->GetRootWindow();
1172 } 1138 }
1173 1139
1174 } // namespace ash 1140 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.h ('k') | ash/shell/app_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698