| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/aura/wm_shelf_aura.h" | 8 #include "ash/aura/wm_shelf_aura.h" |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/focus_cycler.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 11 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/session/session_state_delegate.h" | 12 #include "ash/common/session/session_state_delegate.h" |
| 12 #include "ash/common/shelf/shelf_constants.h" | 13 #include "ash/common/shelf/shelf_constants.h" |
| 13 #include "ash/common/shelf/shelf_model.h" | 14 #include "ash/common/shelf/shelf_model.h" |
| 14 #include "ash/common/shelf/wm_shelf_util.h" | 15 #include "ash/common/shelf/wm_shelf_util.h" |
| 15 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
| 16 #include "ash/common/system/tray/system_tray_delegate.h" | 17 #include "ash/common/system/tray/system_tray_delegate.h" |
| 17 #include "ash/common/wm_root_window_controller.h" | 18 #include "ash/common/wm_root_window_controller.h" |
| 18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 19 #include "ash/focus_cycler.h" | |
| 20 #include "ash/shelf/shelf_delegate.h" | 20 #include "ash/shelf/shelf_delegate.h" |
| 21 #include "ash/shelf/shelf_layout_manager.h" | 21 #include "ash/shelf/shelf_layout_manager.h" |
| 22 #include "ash/shelf/shelf_navigator.h" | 22 #include "ash/shelf/shelf_navigator.h" |
| 23 #include "ash/shelf/shelf_util.h" | 23 #include "ash/shelf/shelf_util.h" |
| 24 #include "ash/shelf/shelf_view.h" | 24 #include "ash/shelf/shelf_view.h" |
| 25 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 26 #include "ash/wm/status_area_layout_manager.h" | 26 #include "ash/wm/status_area_layout_manager.h" |
| 27 #include "ash/wm/window_properties.h" | 27 #include "ash/wm/window_properties.h" |
| 28 #include "ash/wm/workspace_controller.h" | 28 #include "ash/wm/workspace_controller.h" |
| 29 #include "grit/ash_resources.h" | 29 #include "grit/ash_resources.h" |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 shelf_container->SetLayoutManager(shelf_layout_manager_); | 592 shelf_container->SetLayoutManager(shelf_layout_manager_); |
| 593 shelf_layout_manager_->set_workspace_controller(workspace_controller); | 593 shelf_layout_manager_->set_workspace_controller(workspace_controller); |
| 594 workspace_controller->SetShelf(shelf_layout_manager_); | 594 workspace_controller->SetShelf(shelf_layout_manager_); |
| 595 | 595 |
| 596 status_area_widget_ = new StatusAreaWidget(wm_status_container, this); | 596 status_area_widget_ = new StatusAreaWidget(wm_status_container, this); |
| 597 status_area_widget_->CreateTrayViews(); | 597 status_area_widget_->CreateTrayViews(); |
| 598 if (Shell::GetInstance()->session_state_delegate()-> | 598 if (Shell::GetInstance()->session_state_delegate()-> |
| 599 IsActiveUserSessionStarted()) { | 599 IsActiveUserSessionStarted()) { |
| 600 status_area_widget_->Show(); | 600 status_area_widget_->Show(); |
| 601 } | 601 } |
| 602 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); | 602 WmShell::Get()->focus_cycler()->AddWidget(status_area_widget_); |
| 603 | 603 |
| 604 aura::Window* status_container = | 604 aura::Window* status_container = |
| 605 WmWindowAura::GetAuraWindow(wm_status_container); | 605 WmWindowAura::GetAuraWindow(wm_status_container); |
| 606 status_container->SetLayoutManager( | 606 status_container->SetLayoutManager( |
| 607 new StatusAreaLayoutManager(status_container, this)); | 607 new StatusAreaLayoutManager(status_container, this)); |
| 608 | 608 |
| 609 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 609 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 610 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); | 610 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); |
| 611 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 611 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 612 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); | 612 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); |
| 613 | 613 |
| 614 views::Widget::AddObserver(this); | 614 views::Widget::AddObserver(this); |
| 615 } | 615 } |
| 616 | 616 |
| 617 ShelfWidget::~ShelfWidget() { | 617 ShelfWidget::~ShelfWidget() { |
| 618 // Must call Shutdown() before destruction. | 618 // Must call Shutdown() before destruction. |
| 619 DCHECK(!status_area_widget_); | 619 DCHECK(!status_area_widget_); |
| 620 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); | 620 WmShell::Get()->focus_cycler()->RemoveWidget(this); |
| 621 SetFocusCycler(nullptr); | 621 SetFocusCycler(nullptr); |
| 622 RemoveObserver(this); | 622 RemoveObserver(this); |
| 623 } | 623 } |
| 624 | 624 |
| 625 void ShelfWidget::SetPaintsBackground( | 625 void ShelfWidget::SetPaintsBackground( |
| 626 ShelfBackgroundType background_type, | 626 ShelfBackgroundType background_type, |
| 627 BackgroundAnimatorChangeType change_type) { | 627 BackgroundAnimatorChangeType change_type) { |
| 628 ui::Layer* opaque_background = delegate_view_->opaque_background(); | 628 ui::Layer* opaque_background = delegate_view_->opaque_background(); |
| 629 float target_opacity = | 629 float target_opacity = |
| 630 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; | 630 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 DCHECK(!shelf_); | 728 DCHECK(!shelf_); |
| 729 | 729 |
| 730 Shell* shell = Shell::GetInstance(); | 730 Shell* shell = Shell::GetInstance(); |
| 731 ShelfDelegate* delegate = shell->GetShelfDelegate(); | 731 ShelfDelegate* delegate = shell->GetShelfDelegate(); |
| 732 shelf_.reset(new Shelf(shell->shelf_model(), delegate, wm_shelf_aura, this)); | 732 shelf_.reset(new Shelf(shell->shelf_model(), delegate, wm_shelf_aura, this)); |
| 733 // Must be initialized before the delegate is notified because the delegate | 733 // Must be initialized before the delegate is notified because the delegate |
| 734 // may try to access the WmShelf. | 734 // may try to access the WmShelf. |
| 735 wm_shelf_aura->SetShelf(shelf_.get()); | 735 wm_shelf_aura->SetShelf(shelf_.get()); |
| 736 delegate->OnShelfCreated(shelf_.get()); | 736 delegate->OnShelfCreated(shelf_.get()); |
| 737 | 737 |
| 738 SetFocusCycler(shell->focus_cycler()); | 738 SetFocusCycler(WmShell::Get()->focus_cycler()); |
| 739 } | 739 } |
| 740 | 740 |
| 741 void ShelfWidget::PostCreateShelf() { | 741 void ShelfWidget::PostCreateShelf() { |
| 742 shelf_->SetVisible(Shell::GetInstance() | 742 shelf_->SetVisible(Shell::GetInstance() |
| 743 ->session_state_delegate() | 743 ->session_state_delegate() |
| 744 ->IsActiveUserSessionStarted()); | 744 ->IsActiveUserSessionStarted()); |
| 745 shelf_layout_manager_->LayoutShelf(); | 745 shelf_layout_manager_->LayoutShelf(); |
| 746 shelf_layout_manager_->UpdateAutoHideState(); | 746 shelf_layout_manager_->UpdateAutoHideState(); |
| 747 Show(); | 747 Show(); |
| 748 } | 748 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 768 | 768 |
| 769 void ShelfWidget::Shutdown() { | 769 void ShelfWidget::Shutdown() { |
| 770 // Shutting down the status area widget may cause some widgets (e.g. bubbles) | 770 // Shutting down the status area widget may cause some widgets (e.g. bubbles) |
| 771 // to close, so uninstall the ShelfLayoutManager event filters first. Don't | 771 // to close, so uninstall the ShelfLayoutManager event filters first. Don't |
| 772 // reset the pointer until later because other widgets (e.g. app list) may | 772 // reset the pointer until later because other widgets (e.g. app list) may |
| 773 // access it later in shutdown. | 773 // access it later in shutdown. |
| 774 if (shelf_layout_manager_) | 774 if (shelf_layout_manager_) |
| 775 shelf_layout_manager_->PrepareForShutdown(); | 775 shelf_layout_manager_->PrepareForShutdown(); |
| 776 | 776 |
| 777 if (status_area_widget_) { | 777 if (status_area_widget_) { |
| 778 Shell::GetInstance()->focus_cycler()->RemoveWidget(status_area_widget_); | 778 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); |
| 779 status_area_widget_->Shutdown(); | 779 status_area_widget_->Shutdown(); |
| 780 status_area_widget_ = nullptr; | 780 status_area_widget_ = nullptr; |
| 781 } | 781 } |
| 782 } | 782 } |
| 783 | 783 |
| 784 void ShelfWidget::ForceUndimming(bool force) { | 784 void ShelfWidget::ForceUndimming(bool force) { |
| 785 delegate_view_->ForceUndimming(force); | 785 delegate_view_->ForceUndimming(force); |
| 786 } | 786 } |
| 787 | 787 |
| 788 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, | 788 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); | 822 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); |
| 823 } | 823 } |
| 824 | 824 |
| 825 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { | 825 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { |
| 826 Widget::OnGestureEvent(event); | 826 Widget::OnGestureEvent(event); |
| 827 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) | 827 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) |
| 828 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); | 828 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); |
| 829 } | 829 } |
| 830 | 830 |
| 831 } // namespace ash | 831 } // namespace ash |
| OLD | NEW |