| 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/dimmer_view.h" | 10 #include "ash/shelf/dimmer_view.h" |
| 11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_bezel_event_handler.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 13 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 15 | 16 |
| 16 namespace ash { | 17 namespace ash { |
| 17 | 18 |
| 18 // WmShelfAura::AutoHideEventHandler ------------------------------------------- | 19 // WmShelfAura::AutoHideEventHandler ------------------------------------------- |
| 19 | 20 |
| 20 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. | 21 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. |
| 21 // TODO(mash): Add similar event handling support for mash. | 22 // TODO(mash): Add similar event handling support for mash. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 WmShelfAura::WmShelfAura() {} | 50 WmShelfAura::WmShelfAura() {} |
| 50 | 51 |
| 51 WmShelfAura::~WmShelfAura() {} | 52 WmShelfAura::~WmShelfAura() {} |
| 52 | 53 |
| 53 void WmShelfAura::SetShelfLayoutManager( | 54 void WmShelfAura::SetShelfLayoutManager( |
| 54 ShelfLayoutManager* shelf_layout_manager) { | 55 ShelfLayoutManager* shelf_layout_manager) { |
| 55 DCHECK(!shelf_layout_manager_); | 56 DCHECK(!shelf_layout_manager_); |
| 56 shelf_layout_manager_ = shelf_layout_manager; | 57 shelf_layout_manager_ = shelf_layout_manager; |
| 57 shelf_layout_manager_->AddObserver(this); | 58 shelf_layout_manager_->AddObserver(this); |
| 59 bezel_event_handler_.reset(new ShelfBezelEventHandler(this)); |
| 58 } | 60 } |
| 59 | 61 |
| 60 void WmShelfAura::SetShelf(Shelf* shelf) { | 62 void WmShelfAura::SetShelf(Shelf* shelf) { |
| 61 DCHECK(!shelf_); | 63 DCHECK(!shelf_); |
| 62 shelf_ = shelf; | 64 shelf_ = shelf; |
| 63 shelf_->AddIconObserver(this); | 65 shelf_->AddIconObserver(this); |
| 64 } | 66 } |
| 65 | 67 |
| 66 void WmShelfAura::Shutdown() { | 68 void WmShelfAura::Shutdown() { |
| 67 if (shelf_) { | 69 if (shelf_) { |
| 68 shelf_->RemoveIconObserver(this); | 70 shelf_->RemoveIconObserver(this); |
| 69 shelf_ = nullptr; | 71 shelf_ = nullptr; |
| 70 } | 72 } |
| 71 | 73 |
| 72 ResetShelfLayoutManager(); | 74 ResetShelfLayoutManager(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 // static | 77 // static |
| 76 Shelf* WmShelfAura::GetShelf(WmShelf* shelf) { | 78 Shelf* WmShelfAura::GetShelf(WmShelf* shelf) { |
| 77 return static_cast<WmShelfAura*>(shelf)->shelf_; | 79 return static_cast<WmShelfAura*>(shelf)->shelf_; |
| 78 } | 80 } |
| 79 | 81 |
| 80 void WmShelfAura::ResetShelfLayoutManager() { | 82 void WmShelfAura::ResetShelfLayoutManager() { |
| 81 if (!shelf_layout_manager_) | 83 if (!shelf_layout_manager_) |
| 82 return; | 84 return; |
| 85 // Clear event handlers that might otherwise forward events during shutdown. |
| 83 auto_hide_event_handler_.reset(); | 86 auto_hide_event_handler_.reset(); |
| 87 bezel_event_handler_.reset(); |
| 84 shelf_layout_manager_->RemoveObserver(this); | 88 shelf_layout_manager_->RemoveObserver(this); |
| 85 shelf_layout_manager_ = nullptr; | 89 shelf_layout_manager_ = nullptr; |
| 86 } | 90 } |
| 87 | 91 |
| 88 WmWindow* WmShelfAura::GetWindow() { | 92 WmWindow* WmShelfAura::GetWindow() { |
| 89 // Use |shelf_layout_manager_| to access ShelfWidget because it is set | 93 // Use |shelf_layout_manager_| to access ShelfWidget because it is set |
| 90 // before |shelf_| is available. | 94 // before |shelf_| is available. |
| 91 return WmWindowAura::Get( | 95 return WmWindowAura::Get( |
| 92 shelf_layout_manager_->shelf_widget()->GetNativeView()); | 96 shelf_layout_manager_->shelf_widget()->GetNativeView()); |
| 93 } | 97 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 void WmShelfAura::OnAutoHideStateChanged(ShelfAutoHideState new_state) { | 229 void WmShelfAura::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
| 226 FOR_EACH_OBSERVER(WmShelfObserver, observers_, | 230 FOR_EACH_OBSERVER(WmShelfObserver, observers_, |
| 227 OnAutoHideStateChanged(new_state)); | 231 OnAutoHideStateChanged(new_state)); |
| 228 } | 232 } |
| 229 | 233 |
| 230 void WmShelfAura::OnShelfIconPositionsChanged() { | 234 void WmShelfAura::OnShelfIconPositionsChanged() { |
| 231 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); | 235 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); |
| 232 } | 236 } |
| 233 | 237 |
| 234 } // namespace ash | 238 } // namespace ash |
| OLD | NEW |