Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2846)

Unified Diff: ash/common/shelf/wm_shelf.cc

Issue 2304443002: ash: Move ShelfWidget ownership to WmShelf and refactor access to it (Closed)
Patch Set: review comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/shelf/wm_shelf.h ('k') | ash/mus/accelerators/accelerator_controller_delegate_mus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/wm_shelf.cc
diff --git a/ash/common/shelf/wm_shelf.cc b/ash/common/shelf/wm_shelf.cc
index f7c6e7a04ebdec344bddca2565913dda3068f941..b2653bb7962f3d0fd526f5499cf9d7fb7dcd529e 100644
--- a/ash/common/shelf/wm_shelf.cc
+++ b/ash/common/shelf/wm_shelf.cc
@@ -10,6 +10,7 @@
#include "ash/common/shelf/shelf_widget.h"
#include "ash/common/shelf/wm_shelf.h"
#include "ash/common/shelf/wm_shelf_observer.h"
+#include "ash/common/shell_window_ids.h"
#include "ash/common/wm_lookup.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
@@ -24,13 +25,31 @@ WmShelf* WmShelf::ForWindow(WmWindow* window) {
return window->GetRootWindowController()->GetShelf();
}
-void WmShelf::SetShelfLayoutManager(ShelfLayoutManager* manager) {
+void WmShelf::CreateShelfWidget(WmWindow* root) {
+ DCHECK(!shelf_widget_);
+ WmWindow* shelf_container =
+ root->GetChildByShellWindowId(kShellWindowId_ShelfContainer);
+ shelf_widget_.reset(new ShelfWidget(shelf_container, this));
+
DCHECK(!shelf_layout_manager_);
- DCHECK(manager);
- shelf_layout_manager_ = manager;
+ shelf_layout_manager_ = shelf_widget_->shelf_layout_manager();
shelf_layout_manager_->AddObserver(this);
- DCHECK(manager->shelf_widget());
- shelf_widget_ = manager->shelf_widget();
+
+ // Must occur after |shelf_widget_| is constructed because the system tray
+ // constructors call back into WmShelf::shelf_widget().
+ DCHECK(!shelf_widget_->status_area_widget());
+ WmWindow* status_container =
+ root->GetChildByShellWindowId(kShellWindowId_StatusContainer);
+ shelf_widget_->CreateStatusAreaWidget(status_container);
+}
+
+void WmShelf::ShutdownShelfWidget() {
+ if (shelf_widget_)
+ shelf_widget_->Shutdown();
+}
+
+void WmShelf::DestroyShelfWidget() {
+ shelf_widget_.reset();
}
void WmShelf::InitializeShelf() {
@@ -58,10 +77,7 @@ bool WmShelf::IsShelfInitialized() const {
}
WmWindow* WmShelf::GetWindow() {
- // Use |shelf_layout_manager_| to access ShelfWidget because it is set before
- // before the Shelf instance is available.
- return WmLookup::Get()->GetWindowForWidget(
- shelf_layout_manager_->shelf_widget());
+ return WmLookup::Get()->GetWindowForWidget(shelf_widget_.get());
}
void WmShelf::SetAlignment(ShelfAlignment alignment) {
@@ -79,7 +95,7 @@ void WmShelf::SetAlignment(ShelfAlignment alignment) {
alignment_ = alignment;
// The ShelfWidget notifies the ShelfView of the alignment change.
- shelf_layout_manager_->shelf_widget()->OnShelfAlignmentChanged();
+ shelf_widget_->OnShelfAlignmentChanged();
WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this);
WmShell::Get()->NotifyShelfAlignmentChanged(GetWindow()->GetRootWindow());
// ShelfLayoutManager will resize the shelf.
@@ -139,7 +155,7 @@ void WmShelf::UpdateAutoHideState() {
}
ShelfBackgroundType WmShelf::GetBackgroundType() const {
- return shelf_layout_manager_->shelf_widget()->GetBackgroundType();
+ return shelf_widget_->GetBackgroundType();
}
WmDimmerView* WmShelf::CreateDimmerView(bool disable_animations_for_test) {
@@ -147,7 +163,7 @@ WmDimmerView* WmShelf::CreateDimmerView(bool disable_animations_for_test) {
}
bool WmShelf::IsDimmed() const {
- return shelf_layout_manager_->shelf_widget()->GetDimsShelf();
+ return shelf_widget_->GetDimsShelf();
}
bool WmShelf::IsVisible() const {
@@ -174,14 +190,13 @@ gfx::Rect WmShelf::GetUserWorkAreaBounds() const {
}
void WmShelf::UpdateIconPositionForPanel(WmWindow* panel) {
- shelf_layout_manager_->shelf_widget()->UpdateIconPositionForPanel(panel);
+ shelf_widget_->UpdateIconPositionForPanel(panel);
}
gfx::Rect WmShelf::GetScreenBoundsOfItemIconForWindow(WmWindow* window) {
- if (!shelf_layout_manager_)
+ if (!shelf_widget_)
return gfx::Rect();
- return shelf_layout_manager_->shelf_widget()
- ->GetScreenBoundsOfItemIconForWindow(window);
+ return shelf_widget_->GetScreenBoundsOfItemIconForWindow(window);
}
// static
@@ -244,7 +259,7 @@ void WmShelf::NotifyShelfIconPositionsChanged() {
}
StatusAreaWidget* WmShelf::GetStatusAreaWidget() const {
- return shelf_layout_manager_->shelf_widget()->status_area_widget();
+ return shelf_widget_->status_area_widget();
}
void WmShelf::SetVirtualKeyboardBoundsForTesting(const gfx::Rect& bounds) {
« no previous file with comments | « ash/common/shelf/wm_shelf.h ('k') | ash/mus/accelerators/accelerator_controller_delegate_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698