Chromium Code Reviews| 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/shelf/wm_shelf.h" | 5 #include "ash/shelf/wm_shelf.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/config.h" | 7 #include "ash/public/cpp/config.h" |
| 8 #include "ash/public/cpp/shelf_item_delegate.h" | 8 #include "ash/public/cpp/shelf_item_delegate.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 event, WmWindow::Get(static_cast<aura::Window*>(event->target()))); | 57 event, WmWindow::Get(static_cast<aura::Window*>(event->target()))); |
| 58 } | 58 } |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 ShelfLayoutManager* shelf_layout_manager_; | 61 ShelfLayoutManager* shelf_layout_manager_; |
| 62 DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler); | 62 DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // WmShelf --------------------------------------------------------------------- | 65 // WmShelf --------------------------------------------------------------------- |
| 66 | 66 |
| 67 WmShelf::WmShelf() {} | 67 WmShelf::WmShelf() |
| 68 : shelf_locking_manager_(base::MakeUnique<ShelfLockingManager>(this)) { | |
|
msw
2017/05/16 22:42:00
This should no longer be a unique_ptr
James Cook
2017/05/17 16:16:13
Done. Sometimes I wish we used unique_ptr<> a bit
| |
| 69 // TODO: ShelfBezelEventHandler needs to work with mus too. | |
| 70 // http://crbug.com/636647 | |
| 71 if (Shell::GetAshConfig() != Config::MASH) | |
| 72 bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this); | |
| 73 } | |
| 68 | 74 |
| 69 WmShelf::~WmShelf() {} | 75 WmShelf::~WmShelf() {} |
| 70 | 76 |
| 71 // static | 77 // static |
| 72 WmShelf* WmShelf::ForWindow(WmWindow* window) { | 78 WmShelf* WmShelf::ForWindow(WmWindow* window) { |
| 73 return window->GetRootWindowController()->GetShelf(); | 79 return window->GetRootWindowController()->GetShelf(); |
| 74 } | 80 } |
| 75 | 81 |
| 76 // static | 82 // static |
| 77 bool WmShelf::CanChangeShelfAlignment() { | 83 bool WmShelf::CanChangeShelfAlignment() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 DCHECK(!shelf_layout_manager_); | 116 DCHECK(!shelf_layout_manager_); |
| 111 shelf_layout_manager_ = shelf_widget_->shelf_layout_manager(); | 117 shelf_layout_manager_ = shelf_widget_->shelf_layout_manager(); |
| 112 shelf_layout_manager_->AddObserver(this); | 118 shelf_layout_manager_->AddObserver(this); |
| 113 | 119 |
| 114 // Must occur after |shelf_widget_| is constructed because the system tray | 120 // Must occur after |shelf_widget_| is constructed because the system tray |
| 115 // constructors call back into WmShelf::shelf_widget(). | 121 // constructors call back into WmShelf::shelf_widget(). |
| 116 DCHECK(!shelf_widget_->status_area_widget()); | 122 DCHECK(!shelf_widget_->status_area_widget()); |
| 117 WmWindow* status_container = | 123 WmWindow* status_container = |
| 118 root->GetChildByShellWindowId(kShellWindowId_StatusContainer); | 124 root->GetChildByShellWindowId(kShellWindowId_StatusContainer); |
| 119 shelf_widget_->CreateStatusAreaWidget(status_container); | 125 shelf_widget_->CreateStatusAreaWidget(status_container); |
| 120 | |
| 121 // TODO: ShelfBezelEventHandler needs to work with mus too. | |
| 122 // http://crbug.com/636647 | |
| 123 if (Shell::GetAshConfig() != Config::MASH) | |
| 124 bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this); | |
|
James Cook
2017/05/16 21:32:35
The timing here doesn't matter so I moved it up.
msw
2017/05/16 22:42:00
Acknowledged.
| |
| 125 } | 126 } |
| 126 | 127 |
| 127 void WmShelf::ShutdownShelfWidget() { | 128 void WmShelf::ShutdownShelfWidget() { |
| 128 if (shelf_widget_) | 129 if (shelf_widget_) |
| 129 shelf_widget_->Shutdown(); | 130 shelf_widget_->Shutdown(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 void WmShelf::DestroyShelfWidget() { | 133 void WmShelf::DestroyShelfWidget() { |
| 133 shelf_widget_.reset(); | 134 shelf_widget_.reset(); |
| 134 } | 135 } |
| 135 | 136 |
| 136 void WmShelf::CreateShelfView() { | 137 void WmShelf::NotifyShelfInitialized() { |
| 137 DCHECK(shelf_layout_manager_); | 138 DCHECK(shelf_layout_manager_); |
| 138 DCHECK(shelf_widget_); | 139 DCHECK(shelf_widget_); |
| 139 DCHECK(!shelf_view_); | 140 Shell::Get()->shelf_controller()->NotifyShelfInitialized(this); |
| 140 shelf_view_ = shelf_widget_->CreateShelfView(); | |
| 141 shelf_locking_manager_.reset(new ShelfLockingManager(this)); | |
| 142 Shell::Get()->shelf_controller()->NotifyShelfCreated(this); | |
| 143 } | |
| 144 | |
| 145 void WmShelf::ShutdownShelf() { | |
| 146 DCHECK(shelf_view_); | |
| 147 shelf_locking_manager_.reset(); | |
| 148 shelf_view_ = nullptr; | |
| 149 } | |
| 150 | |
| 151 bool WmShelf::IsShelfInitialized() const { | |
| 152 return !!shelf_view_; | |
| 153 } | 141 } |
| 154 | 142 |
| 155 WmWindow* WmShelf::GetWindow() { | 143 WmWindow* WmShelf::GetWindow() { |
| 156 return WmWindow::Get(shelf_widget_->GetNativeWindow()); | 144 return WmWindow::Get(shelf_widget_->GetNativeWindow()); |
| 157 } | 145 } |
| 158 | 146 |
| 159 void WmShelf::SetAlignment(ShelfAlignment alignment) { | 147 void WmShelf::SetAlignment(ShelfAlignment alignment) { |
| 160 DCHECK(shelf_layout_manager_); | 148 DCHECK(shelf_layout_manager_); |
| 161 DCHECK(shelf_locking_manager_); | 149 DCHECK(shelf_locking_manager_); |
|
msw
2017/05/16 22:42:00
nit: remove
James Cook
2017/05/17 16:16:13
Done.
| |
| 162 | 150 |
| 163 if (alignment_ == alignment) | 151 if (alignment_ == alignment) |
| 164 return; | 152 return; |
| 165 | 153 |
| 166 if (shelf_locking_manager_->is_locked() && | 154 if (shelf_locking_manager_->is_locked() && |
| 167 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 155 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
| 168 shelf_locking_manager_->set_stored_alignment(alignment); | 156 shelf_locking_manager_->set_stored_alignment(alignment); |
| 169 return; | 157 return; |
| 170 } | 158 } |
| 171 | 159 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 | 318 |
| 331 void WmShelf::SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds) { | 319 void WmShelf::SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds) { |
| 332 shelf_layout_manager_->OnKeyboardBoundsChanging(bounds); | 320 shelf_layout_manager_->OnKeyboardBoundsChanging(bounds); |
| 333 } | 321 } |
| 334 | 322 |
| 335 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { | 323 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { |
| 336 return shelf_locking_manager_.get(); | 324 return shelf_locking_manager_.get(); |
| 337 } | 325 } |
| 338 | 326 |
| 339 ShelfView* WmShelf::GetShelfViewForTesting() { | 327 ShelfView* WmShelf::GetShelfViewForTesting() { |
| 340 return shelf_view_; | 328 return shelf_widget_->shelf_view_for_testing(); |
| 341 } | 329 } |
| 342 | 330 |
| 343 void WmShelf::WillDeleteShelfLayoutManager() { | 331 void WmShelf::WillDeleteShelfLayoutManager() { |
| 344 if (Shell::GetAshConfig() == Config::MASH) { | 332 if (Shell::GetAshConfig() == Config::MASH) { |
| 345 // TODO(sky): this should be removed once Shell is used everywhere. | 333 // TODO(sky): this should be removed once Shell is used everywhere. |
| 346 ShutdownShelfWidget(); | 334 ShutdownShelfWidget(); |
| 347 } | 335 } |
| 348 | 336 |
| 349 // Clear event handlers that might forward events to the destroyed instance. | 337 // Clear event handlers that might forward events to the destroyed instance. |
| 350 auto_hide_event_handler_.reset(); | 338 auto_hide_event_handler_.reset(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 374 | 362 |
| 375 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 363 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 376 AnimationChangeType change_type) { | 364 AnimationChangeType change_type) { |
| 377 if (background_type == GetBackgroundType()) | 365 if (background_type == GetBackgroundType()) |
| 378 return; | 366 return; |
| 379 for (auto& observer : observers_) | 367 for (auto& observer : observers_) |
| 380 observer.OnBackgroundTypeChanged(background_type, change_type); | 368 observer.OnBackgroundTypeChanged(background_type, change_type); |
| 381 } | 369 } |
| 382 | 370 |
| 383 } // namespace ash | 371 } // namespace ash |
| OLD | NEW |