| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/aura/wm_shelf_aura.h" | 5 #include "ash/aura/wm_shelf_aura.h" |
| 6 | 6 |
| 7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/shelf/wm_shelf_observer.h" | 8 #include "ash/common/shelf/wm_shelf_observer.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 | 46 |
| 47 void WmShelfAura::ResetShelfLayoutManager() { | 47 void WmShelfAura::ResetShelfLayoutManager() { |
| 48 if (!shelf_layout_manager_) | 48 if (!shelf_layout_manager_) |
| 49 return; | 49 return; |
| 50 shelf_layout_manager_->RemoveObserver(this); | 50 shelf_layout_manager_->RemoveObserver(this); |
| 51 shelf_layout_manager_ = nullptr; | 51 shelf_layout_manager_ = nullptr; |
| 52 } | 52 } |
| 53 | 53 |
| 54 WmWindow* WmShelfAura::GetWindow() { | 54 WmWindow* WmShelfAura::GetWindow() { |
| 55 return WmWindowAura::Get(shelf_->shelf_widget()->GetNativeView()); | 55 // Use |shelf_layout_manager_| to access ShelfWidget because it is set |
| 56 // before |shelf_| is available. |
| 57 return WmWindowAura::Get( |
| 58 shelf_layout_manager_->shelf_widget()->GetNativeView()); |
| 56 } | 59 } |
| 57 | 60 |
| 58 ShelfAlignment WmShelfAura::GetAlignment() const { | 61 ShelfAlignment WmShelfAura::GetAlignment() const { |
| 59 return shelf_->alignment(); | 62 // Can be called before |shelf_| is set when initializing a secondary monitor. |
| 63 return shelf_ ? shelf_->alignment() : SHELF_ALIGNMENT_BOTTOM_LOCKED; |
| 60 } | 64 } |
| 61 | 65 |
| 62 void WmShelfAura::SetAlignment(ShelfAlignment alignment) { | 66 void WmShelfAura::SetAlignment(ShelfAlignment alignment) { |
| 63 shelf_->SetAlignment(alignment); | 67 shelf_->SetAlignment(alignment); |
| 64 } | 68 } |
| 65 | 69 |
| 66 ShelfAutoHideBehavior WmShelfAura::GetAutoHideBehavior() const { | 70 ShelfAutoHideBehavior WmShelfAura::GetAutoHideBehavior() const { |
| 67 return shelf_->auto_hide_behavior(); | 71 return shelf_->auto_hide_behavior(); |
| 68 } | 72 } |
| 69 | 73 |
| 70 void WmShelfAura::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { | 74 void WmShelfAura::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
| 71 shelf_->SetAutoHideBehavior(behavior); | 75 shelf_->SetAutoHideBehavior(behavior); |
| 72 } | 76 } |
| 73 | 77 |
| 78 ShelfAutoHideState WmShelfAura::GetAutoHideState() const { |
| 79 return shelf_layout_manager_->auto_hide_state(); |
| 80 } |
| 81 |
| 74 ShelfBackgroundType WmShelfAura::GetBackgroundType() const { | 82 ShelfBackgroundType WmShelfAura::GetBackgroundType() const { |
| 75 return shelf_->shelf_widget()->GetBackgroundType(); | 83 return shelf_layout_manager_->shelf_widget()->GetBackgroundType(); |
| 76 } | 84 } |
| 77 | 85 |
| 78 void WmShelfAura::UpdateVisibilityState() { | 86 void WmShelfAura::UpdateVisibilityState() { |
| 79 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | 87 shelf_layout_manager_->UpdateVisibilityState(); |
| 80 } | 88 } |
| 81 | 89 |
| 82 ShelfVisibilityState WmShelfAura::GetVisibilityState() const { | 90 ShelfVisibilityState WmShelfAura::GetVisibilityState() const { |
| 83 return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state() | 91 return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state() |
| 84 : SHELF_HIDDEN; | 92 : SHELF_HIDDEN; |
| 85 } | 93 } |
| 86 | 94 |
| 95 gfx::Rect WmShelfAura::GetUserWorkAreaBounds() const { |
| 96 return shelf_layout_manager_ ? shelf_layout_manager_->user_work_area_bounds() |
| 97 : gfx::Rect(); |
| 98 } |
| 99 |
| 87 void WmShelfAura::UpdateIconPositionForWindow(WmWindow* window) { | 100 void WmShelfAura::UpdateIconPositionForWindow(WmWindow* window) { |
| 88 shelf_->UpdateIconPositionForWindow(WmWindowAura::GetAuraWindow(window)); | 101 shelf_->UpdateIconPositionForWindow(WmWindowAura::GetAuraWindow(window)); |
| 89 } | 102 } |
| 90 | 103 |
| 91 gfx::Rect WmShelfAura::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { | 104 gfx::Rect WmShelfAura::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { |
| 92 return shelf_->GetScreenBoundsOfItemIconForWindow( | 105 return shelf_->GetScreenBoundsOfItemIconForWindow( |
| 93 WmWindowAura::GetAuraWindow(window)); | 106 WmWindowAura::GetAuraWindow(window)); |
| 94 } | 107 } |
| 95 | 108 |
| 96 void WmShelfAura::AddObserver(WmShelfObserver* observer) { | 109 void WmShelfAura::AddObserver(WmShelfObserver* observer) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 110 BackgroundAnimatorChangeType change_type) { | 123 BackgroundAnimatorChangeType change_type) { |
| 111 FOR_EACH_OBSERVER(WmShelfObserver, observers_, | 124 FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| 112 OnBackgroundUpdated(background_type, change_type)); | 125 OnBackgroundUpdated(background_type, change_type)); |
| 113 } | 126 } |
| 114 | 127 |
| 115 void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) { | 128 void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) { |
| 116 FOR_EACH_OBSERVER(WmShelfObserver, observers_, | 129 FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| 117 WillChangeVisibilityState(new_state)); | 130 WillChangeVisibilityState(new_state)); |
| 118 } | 131 } |
| 119 | 132 |
| 133 void WmShelfAura::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
| 134 FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| 135 OnAutoHideStateChanged(new_state)); |
| 136 } |
| 137 |
| 120 void WmShelfAura::OnShelfIconPositionsChanged() { | 138 void WmShelfAura::OnShelfIconPositionsChanged() { |
| 121 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); | 139 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); |
| 122 } | 140 } |
| 123 | 141 |
| 124 } // namespace ash | 142 } // namespace ash |
| OLD | NEW |