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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 event, WmWindow::Get(static_cast<aura::Window*>(event->target()))); | 51 event, WmWindow::Get(static_cast<aura::Window*>(event->target()))); |
52 } | 52 } |
53 | 53 |
54 private: | 54 private: |
55 ShelfLayoutManager* shelf_layout_manager_; | 55 ShelfLayoutManager* shelf_layout_manager_; |
56 DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler); | 56 DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler); |
57 }; | 57 }; |
58 | 58 |
59 // WmShelf --------------------------------------------------------------------- | 59 // WmShelf --------------------------------------------------------------------- |
60 | 60 |
61 WmShelf::WmShelf() : time_last_auto_hide_change_(base::TimeTicks::Now()) {} | 61 WmShelf::WmShelf() {} |
62 | 62 |
63 WmShelf::~WmShelf() {} | 63 WmShelf::~WmShelf() {} |
64 | 64 |
65 // static | 65 // static |
66 WmShelf* WmShelf::ForWindow(WmWindow* window) { | 66 WmShelf* WmShelf::ForWindow(WmWindow* window) { |
67 return window->GetRootWindowController()->GetShelf(); | 67 return window->GetRootWindowController()->GetShelf(); |
68 } | 68 } |
69 | 69 |
70 // static | 70 // static |
71 bool WmShelf::CanChangeShelfAlignment() { | 71 bool WmShelf::CanChangeShelfAlignment() { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 int WmShelf::PrimaryAxisValue(int horizontal, int vertical) const { | 206 int WmShelf::PrimaryAxisValue(int horizontal, int vertical) const { |
207 return IsHorizontalAlignment() ? horizontal : vertical; | 207 return IsHorizontalAlignment() ? horizontal : vertical; |
208 } | 208 } |
209 | 209 |
210 void WmShelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { | 210 void WmShelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) { |
211 DCHECK(shelf_layout_manager_); | 211 DCHECK(shelf_layout_manager_); |
212 | 212 |
213 if (auto_hide_behavior_ == auto_hide_behavior) | 213 if (auto_hide_behavior_ == auto_hide_behavior) |
214 return; | 214 return; |
215 | 215 |
216 // Force a stack dump when this method is invoked too frequently. | |
217 // This block is here temporary to help investigate http://crbug.com/665093 . | |
218 constexpr int kAutoHideRepeatInterval = 1000; | |
219 constexpr int kMaxAutoHideChanges = 20; | |
220 if ((base::TimeTicks::Now() - time_last_auto_hide_change_).InMilliseconds() < | |
221 kAutoHideRepeatInterval) { | |
222 if (++count_auto_hide_changes_ > kMaxAutoHideChanges) | |
223 CHECK(false); | |
224 } else { | |
225 count_auto_hide_changes_ = 0; | |
226 } | |
227 time_last_auto_hide_change_ = base::TimeTicks::Now(); | |
228 | |
229 auto_hide_behavior_ = auto_hide_behavior; | 216 auto_hide_behavior_ = auto_hide_behavior; |
230 WmShell::Get()->shelf_controller()->NotifyShelfAutoHideBehaviorChanged(this); | 217 WmShell::Get()->shelf_controller()->NotifyShelfAutoHideBehaviorChanged(this); |
231 WmShell::Get()->NotifyShelfAutoHideBehaviorChanged( | 218 WmShell::Get()->NotifyShelfAutoHideBehaviorChanged( |
232 GetWindow()->GetRootWindow()); | 219 GetWindow()->GetRootWindow()); |
233 } | 220 } |
234 | 221 |
235 ShelfAutoHideState WmShelf::GetAutoHideState() const { | 222 ShelfAutoHideState WmShelf::GetAutoHideState() const { |
236 return shelf_layout_manager_->auto_hide_state(); | 223 return shelf_layout_manager_->auto_hide_state(); |
237 } | 224 } |
238 | 225 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 374 |
388 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 375 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
389 BackgroundAnimatorChangeType change_type) { | 376 BackgroundAnimatorChangeType change_type) { |
390 if (background_type == GetBackgroundType()) | 377 if (background_type == GetBackgroundType()) |
391 return; | 378 return; |
392 for (auto& observer : observers_) | 379 for (auto& observer : observers_) |
393 observer.OnBackgroundTypeChanged(background_type, change_type); | 380 observer.OnBackgroundTypeChanged(background_type, change_type); |
394 } | 381 } |
395 | 382 |
396 } // namespace ash | 383 } // namespace ash |
OLD | NEW |