| 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/common/shelf/wm_shelf.h" | 5 #include "ash/common/shelf/wm_shelf.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_controller.h" | 7 #include "ash/common/shelf/shelf_controller.h" |
| 8 #include "ash/common/shelf/shelf_delegate.h" | 8 #include "ash/common/shelf/shelf_delegate.h" |
| 9 #include "ash/common/shelf/shelf_item_delegate.h" | 9 #include "ash/common/shelf/shelf_item_delegate.h" |
| 10 #include "ash/common/shelf/shelf_layout_manager.h" | 10 #include "ash/common/shelf/shelf_layout_manager.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 return bottom; | 159 return bottom; |
| 160 } | 160 } |
| 161 | 161 |
| 162 int WmShelf::PrimaryAxisValue(int horizontal, int vertical) const { | 162 int WmShelf::PrimaryAxisValue(int horizontal, int vertical) const { |
| 163 return IsHorizontalAlignment() ? horizontal : vertical; | 163 return IsHorizontalAlignment() ? horizontal : vertical; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void WmShelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { | 166 void WmShelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { |
| 167 DCHECK(shelf_layout_manager_); | 167 DCHECK(shelf_layout_manager_); |
| 168 | 168 |
| 169 if (auto_hide_behavior_ == auto_hide_behavior) |
| 170 return; |
| 171 |
| 169 // Force a stack dump when this method is invoked too frequently. | 172 // Force a stack dump when this method is invoked too frequently. |
| 170 // This block is here temporary to help investigate http://crbug.com/665093 . | 173 // This block is here temporary to help investigate http://crbug.com/665093 . |
| 171 constexpr int kAutoHideRepeatInterval = 10000; | 174 constexpr int kAutoHideRepeatInterval = 1000; |
| 172 constexpr int kMaxAutoHideChangesIn10Seconds = 100; | 175 constexpr int kMaxAutoHideChanges = 20; |
| 173 if ((base::TimeTicks::Now() - time_last_auto_hide_change_).InMilliseconds() < | 176 if ((base::TimeTicks::Now() - time_last_auto_hide_change_).InMilliseconds() < |
| 174 kAutoHideRepeatInterval) { | 177 kAutoHideRepeatInterval) { |
| 175 if (++count_auto_hide_changes_ > kMaxAutoHideChangesIn10Seconds) | 178 if (++count_auto_hide_changes_ > kMaxAutoHideChanges) |
| 176 CHECK(false); | 179 CHECK(false); |
| 177 } else { | 180 } else { |
| 178 count_auto_hide_changes_ = 0; | 181 count_auto_hide_changes_ = 0; |
| 179 } | 182 } |
| 180 time_last_auto_hide_change_ = base::TimeTicks::Now(); | 183 time_last_auto_hide_change_ = base::TimeTicks::Now(); |
| 181 | 184 |
| 182 if (auto_hide_behavior_ == auto_hide_behavior) | |
| 183 return; | |
| 184 | |
| 185 auto_hide_behavior_ = auto_hide_behavior; | 185 auto_hide_behavior_ = auto_hide_behavior; |
| 186 WmShell::Get()->shelf_controller()->NotifyShelfAutoHideBehaviorChanged(this); | 186 WmShell::Get()->shelf_controller()->NotifyShelfAutoHideBehaviorChanged(this); |
| 187 WmShell::Get()->NotifyShelfAutoHideBehaviorChanged( | 187 WmShell::Get()->NotifyShelfAutoHideBehaviorChanged( |
| 188 GetWindow()->GetRootWindow()); | 188 GetWindow()->GetRootWindow()); |
| 189 } | 189 } |
| 190 | 190 |
| 191 ShelfAutoHideState WmShelf::GetAutoHideState() const { | 191 ShelfAutoHideState WmShelf::GetAutoHideState() const { |
| 192 return shelf_layout_manager_->auto_hide_state(); | 192 return shelf_layout_manager_->auto_hide_state(); |
| 193 } | 193 } |
| 194 | 194 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 302 } |
| 303 | 303 |
| 304 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { | 304 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { |
| 305 return shelf_locking_manager_.get(); | 305 return shelf_locking_manager_.get(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 ShelfView* WmShelf::GetShelfViewForTesting() { | 308 ShelfView* WmShelf::GetShelfViewForTesting() { |
| 309 return shelf_view_; | 309 return shelf_view_; |
| 310 } | 310 } |
| 311 | 311 |
| 312 WmShelf::WmShelf() {} | 312 WmShelf::WmShelf() : time_last_auto_hide_change_(base::TimeTicks::Now()) {} |
| 313 | 313 |
| 314 WmShelf::~WmShelf() {} | 314 WmShelf::~WmShelf() {} |
| 315 | 315 |
| 316 void WmShelf::WillDeleteShelfLayoutManager() { | 316 void WmShelf::WillDeleteShelfLayoutManager() { |
| 317 DCHECK(shelf_layout_manager_); | 317 DCHECK(shelf_layout_manager_); |
| 318 shelf_layout_manager_->RemoveObserver(this); | 318 shelf_layout_manager_->RemoveObserver(this); |
| 319 shelf_layout_manager_ = nullptr; | 319 shelf_layout_manager_ = nullptr; |
| 320 } | 320 } |
| 321 | 321 |
| 322 void WmShelf::WillChangeVisibilityState(ShelfVisibilityState new_state) { | 322 void WmShelf::WillChangeVisibilityState(ShelfVisibilityState new_state) { |
| 323 for (auto& observer : observers_) | 323 for (auto& observer : observers_) |
| 324 observer.WillChangeVisibilityState(new_state); | 324 observer.WillChangeVisibilityState(new_state); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void WmShelf::OnAutoHideStateChanged(ShelfAutoHideState new_state) { | 327 void WmShelf::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
| 328 for (auto& observer : observers_) | 328 for (auto& observer : observers_) |
| 329 observer.OnAutoHideStateChanged(new_state); | 329 observer.OnAutoHideStateChanged(new_state); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 332 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 333 BackgroundAnimatorChangeType change_type) { | 333 BackgroundAnimatorChangeType change_type) { |
| 334 if (background_type == GetBackgroundType()) | 334 if (background_type == GetBackgroundType()) |
| 335 return; | 335 return; |
| 336 for (auto& observer : observers_) | 336 for (auto& observer : observers_) |
| 337 observer.OnBackgroundTypeChanged(background_type, change_type); | 337 observer.OnBackgroundTypeChanged(background_type, change_type); |
| 338 } | 338 } |
| 339 | 339 |
| 340 } // namespace ash | 340 } // namespace ash |
| OLD | NEW |