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

Unified Diff: ash/shelf/shelf.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
« no previous file with comments | « ash/shelf/shelf.h ('k') | ash/shelf/shelf_alignment_menu.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf.cc
diff --git a/ash/shelf/shelf.cc b/ash/shelf/shelf.cc
index 538510e540fc370d75f48badf0214642774cc19b..8d96506970a50dff103120bce9c370741bd1a1d3 100644
--- a/ash/shelf/shelf.cc
+++ b/ash/shelf/shelf.cc
@@ -42,15 +42,15 @@ const char Shelf::kNativeViewName[] = "ShelfView";
Shelf::Shelf(ShelfModel* shelf_model,
ShelfDelegate* shelf_delegate,
ShelfWidget* shelf_widget)
- : shelf_view_(NULL),
- alignment_(shelf_widget->GetAlignment()),
+ : shelf_view_(nullptr),
+ alignment_(SHELF_ALIGNMENT_BOTTOM),
+ auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER),
delegate_(shelf_delegate),
shelf_widget_(shelf_widget) {
shelf_view_ = new ShelfView(shelf_model, delegate_, this);
shelf_view_->Init();
shelf_widget_->GetContentsView()->AddChildView(shelf_view_);
shelf_widget_->GetNativeView()->SetName(kNativeViewName);
- delegate_->OnShelfCreated(this);
}
Shelf::~Shelf() {
@@ -65,25 +65,44 @@ Shelf* Shelf::ForPrimaryDisplay() {
// static
Shelf* Shelf::ForWindow(const aura::Window* window) {
ShelfWidget* shelf_widget = RootWindowController::ForWindow(window)->shelf();
- return shelf_widget ? shelf_widget->shelf() : NULL;
+ return shelf_widget ? shelf_widget->shelf() : nullptr;
}
void Shelf::SetAlignment(ShelfAlignment alignment) {
+ if (alignment_ == alignment)
+ return;
+
alignment_ = alignment;
shelf_view_->OnShelfAlignmentChanged();
+ shelf_widget_->OnShelfAlignmentChanged();
+ delegate_->OnShelfAlignmentChanged(this);
+ Shell::GetInstance()->OnShelfAlignmentChanged(
+ shelf_widget_->GetNativeWindow()->GetRootWindow());
// ShelfLayoutManager will resize the shelf.
}
+ShelfAlignment Shelf::GetAlignment() const {
+ // Bottom alignment is forced when the screen is locked or a user gets added.
+ bool locked = shelf_widget_->shelf_layout_manager()->IsAlignmentLocked();
+ return locked ? SHELF_ALIGNMENT_BOTTOM : alignment_;
sky 2016/04/04 22:44:32 Seems unusual to force an alignment like this. Cou
+}
+
bool Shelf::IsHorizontalAlignment() const {
return alignment_ == SHELF_ALIGNMENT_BOTTOM;
}
-void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) {
- shelf_widget_->shelf_layout_manager()->SetAutoHideBehavior(behavior);
+void Shelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) {
+ if (auto_hide_behavior_ == auto_hide_behavior)
+ return;
+
+ auto_hide_behavior_ = auto_hide_behavior;
+ delegate_->OnShelfAutoHideBehaviorChanged(this);
+ Shell::GetInstance()->OnShelfAutoHideBehaviorChanged(
+ shelf_widget_->GetNativeWindow()->GetRootWindow());
}
ShelfAutoHideBehavior Shelf::GetAutoHideBehavior() const {
- return shelf_widget_->shelf_layout_manager()->auto_hide_behavior();
+ return auto_hide_behavior_;
}
gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(
« no previous file with comments | « ash/shelf/shelf.h ('k') | ash/shelf/shelf_alignment_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698