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

Unified Diff: ash/shelf/shelf_widget.cc

Issue 1851883002: Cleanup shelf initialization and observation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check for shelf before setting prefs in ChromeLauncherController. Created 4 years, 8 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
Index: ash/shelf/shelf_widget.cc
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 685a434395aa499a9ca3e0be130a96aaadc4cf89..4cb1649a371eca863d9aee4e9b910b0e1311deeb 100644
--- a/ash/shelf/shelf_widget.cc
+++ b/ash/shelf/shelf_widget.cc
@@ -722,18 +722,17 @@ bool ShelfWidget::ShelfAlignmentAllowed() {
return false;
}
- DCHECK(false);
+ NOTREACHED();
return false;
}
ShelfAlignment ShelfWidget::GetAlignment() const {
- return shelf_layout_manager_->GetAlignment();
+ // TODO(msw): This should not be called before |shelf_| is created.
+ return shelf_ ? shelf_->GetAlignment() : SHELF_ALIGNMENT_BOTTOM;
}
-void ShelfWidget::SetAlignment(ShelfAlignment alignment) {
- if (shelf_)
- shelf_->SetAlignment(alignment);
- status_area_widget_->SetShelfAlignment(alignment);
+void ShelfWidget::OnShelfAlignmentChanged() {
+ status_area_widget_->SetShelfAlignment(GetAlignment());
delegate_view_->SchedulePaint();
}
@@ -755,13 +754,10 @@ void ShelfWidget::CreateShelf() {
return;
Shell* shell = Shell::GetInstance();
- // This needs to be called before shelf_model().
- ShelfDelegate* shelf_delegate = shell->GetShelfDelegate();
- if (!shelf_delegate)
- return; // Not ready to create Shelf.
+ ShelfDelegate* delegate = shell->GetShelfDelegate();
+ shelf_.reset(new Shelf(shell->shelf_model(), delegate, this));
+ delegate->OnShelfCreated(shelf_.get());
- shelf_.reset(
- new Shelf(shell->shelf_model(), shell->GetShelfDelegate(), this));
SetFocusCycler(shell->focus_cycler());
// Inform the root window controller.

Powered by Google App Engine
This is Rietveld 408576698