| 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/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 case user::LOGGED_IN_OWNER: | 715 case user::LOGGED_IN_OWNER: |
| 716 return true; | 716 return true; |
| 717 case user::LOGGED_IN_PUBLIC: | 717 case user::LOGGED_IN_PUBLIC: |
| 718 case user::LOGGED_IN_SUPERVISED: | 718 case user::LOGGED_IN_SUPERVISED: |
| 719 case user::LOGGED_IN_GUEST: | 719 case user::LOGGED_IN_GUEST: |
| 720 case user::LOGGED_IN_KIOSK_APP: | 720 case user::LOGGED_IN_KIOSK_APP: |
| 721 case user::LOGGED_IN_NONE: | 721 case user::LOGGED_IN_NONE: |
| 722 return false; | 722 return false; |
| 723 } | 723 } |
| 724 | 724 |
| 725 DCHECK(false); | 725 NOTREACHED(); |
| 726 return false; | 726 return false; |
| 727 } | 727 } |
| 728 | 728 |
| 729 ShelfAlignment ShelfWidget::GetAlignment() const { | 729 ShelfAlignment ShelfWidget::GetAlignment() const { |
| 730 return shelf_layout_manager_->GetAlignment(); | 730 // TODO(msw): This should not be called before |shelf_| is created. |
| 731 return shelf_ ? shelf_->GetAlignment() : SHELF_ALIGNMENT_BOTTOM; |
| 731 } | 732 } |
| 732 | 733 |
| 733 void ShelfWidget::SetAlignment(ShelfAlignment alignment) { | 734 void ShelfWidget::OnShelfAlignmentChanged() { |
| 734 if (shelf_) | 735 status_area_widget_->SetShelfAlignment(GetAlignment()); |
| 735 shelf_->SetAlignment(alignment); | |
| 736 status_area_widget_->SetShelfAlignment(alignment); | |
| 737 delegate_view_->SchedulePaint(); | 736 delegate_view_->SchedulePaint(); |
| 738 } | 737 } |
| 739 | 738 |
| 740 void ShelfWidget::SetDimsShelf(bool dimming) { | 739 void ShelfWidget::SetDimsShelf(bool dimming) { |
| 741 delegate_view_->SetDimmed(dimming); | 740 delegate_view_->SetDimmed(dimming); |
| 742 // Repaint all children, allowing updates to reflect dimmed state eg: | 741 // Repaint all children, allowing updates to reflect dimmed state eg: |
| 743 // status area background, app list button and overflow button. | 742 // status area background, app list button and overflow button. |
| 744 if (shelf_) | 743 if (shelf_) |
| 745 shelf_->SchedulePaint(); | 744 shelf_->SchedulePaint(); |
| 746 status_area_widget_->SchedulePaint(); | 745 status_area_widget_->SchedulePaint(); |
| 747 } | 746 } |
| 748 | 747 |
| 749 bool ShelfWidget::GetDimsShelf() const { | 748 bool ShelfWidget::GetDimsShelf() const { |
| 750 return delegate_view_->GetDimmed(); | 749 return delegate_view_->GetDimmed(); |
| 751 } | 750 } |
| 752 | 751 |
| 753 void ShelfWidget::CreateShelf() { | 752 void ShelfWidget::CreateShelf() { |
| 754 if (shelf_) | 753 if (shelf_) |
| 755 return; | 754 return; |
| 756 | 755 |
| 757 Shell* shell = Shell::GetInstance(); | 756 Shell* shell = Shell::GetInstance(); |
| 758 // This needs to be called before shelf_model(). | 757 ShelfDelegate* delegate = shell->GetShelfDelegate(); |
| 759 ShelfDelegate* shelf_delegate = shell->GetShelfDelegate(); | 758 shelf_.reset(new Shelf(shell->shelf_model(), delegate, this)); |
| 760 if (!shelf_delegate) | 759 delegate->OnShelfCreated(shelf_.get()); |
| 761 return; // Not ready to create Shelf. | |
| 762 | 760 |
| 763 shelf_.reset( | |
| 764 new Shelf(shell->shelf_model(), shell->GetShelfDelegate(), this)); | |
| 765 SetFocusCycler(shell->focus_cycler()); | 761 SetFocusCycler(shell->focus_cycler()); |
| 766 | 762 |
| 767 // Inform the root window controller. | 763 // Inform the root window controller. |
| 768 RootWindowController::ForWindow(window_container_)->OnShelfCreated(); | 764 RootWindowController::ForWindow(window_container_)->OnShelfCreated(); |
| 769 | 765 |
| 770 shelf_->SetVisible( | 766 shelf_->SetVisible( |
| 771 shell->session_state_delegate()->IsActiveUserSessionStarted()); | 767 shell->session_state_delegate()->IsActiveUserSessionStarted()); |
| 772 shelf_layout_manager_->LayoutShelf(); | 768 shelf_layout_manager_->LayoutShelf(); |
| 773 shelf_layout_manager_->UpdateAutoHideState(); | 769 shelf_layout_manager_->UpdateAutoHideState(); |
| 774 Show(); | 770 Show(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 DCHECK(delegate_view_); | 826 DCHECK(delegate_view_); |
| 831 return delegate_view_->disable_dimming_animations_for_test(); | 827 return delegate_view_->disable_dimming_animations_for_test(); |
| 832 } | 828 } |
| 833 | 829 |
| 834 void ShelfWidget::WillDeleteShelf() { | 830 void ShelfWidget::WillDeleteShelf() { |
| 835 shelf_layout_manager_->RemoveObserver(this); | 831 shelf_layout_manager_->RemoveObserver(this); |
| 836 shelf_layout_manager_ = NULL; | 832 shelf_layout_manager_ = NULL; |
| 837 } | 833 } |
| 838 | 834 |
| 839 } // namespace ash | 835 } // namespace ash |
| OLD | NEW |