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

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

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Sync and rebase. Created 4 years, 2 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/common/shelf/wm_shelf.cc
diff --git a/ash/common/shelf/wm_shelf.cc b/ash/common/shelf/wm_shelf.cc
index c131ac2803999faa30b5baeaa6d28df00e0ca0ab..13e392a1114c30b3d8727dd8f4de9365e9ff20ba 100644
--- a/ash/common/shelf/wm_shelf.cc
+++ b/ash/common/shelf/wm_shelf.cc
@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/common/shelf/wm_shelf.h"
+
#include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/shelf/shelf_item_delegate.h"
#include "ash/common/shelf/shelf_layout_manager.h"
#include "ash/common/shelf/shelf_locking_manager.h"
#include "ash/common/shelf/shelf_model.h"
#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/system/tray/system_tray_delegate.h"
#include "ash/common/wm_lookup.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_shell.h"
@@ -25,6 +27,33 @@ WmShelf* WmShelf::ForWindow(WmWindow* window) {
return window->GetRootWindowController()->GetShelf();
}
+// static
+bool WmShelf::ShelfAlignmentAllowed() {
sky 2016/10/07 16:10:17 optional: rename to CanChangeShelfAlignment().
msw 2016/10/07 22:45:57 Done.
+ if (WmShell::Get()->system_tray_delegate()->IsUserSupervised())
+ return false;
+
+ LoginStatus login_status =
+ WmShell::Get()->system_tray_delegate()->GetUserLoginStatus();
+
+ switch (login_status) {
+ case LoginStatus::LOCKED:
+ // Shelf alignment changes can be requested while being locked, but will
+ // be applied upon unlock.
+ case LoginStatus::USER:
+ case LoginStatus::OWNER:
+ return true;
+ case LoginStatus::PUBLIC:
+ case LoginStatus::SUPERVISED:
+ case LoginStatus::GUEST:
+ case LoginStatus::KIOSK_APP:
+ case LoginStatus::NOT_LOGGED_IN:
+ return false;
+ }
+
+ NOTREACHED();
+ return false;
+}
+
void WmShelf::CreateShelfWidget(WmWindow* root) {
DCHECK(!shelf_widget_);
WmWindow* shelf_container =
@@ -61,15 +90,13 @@ void WmShelf::InitializeShelf() {
// When the shelf is created the alignment is unlocked. Chrome will update the
// alignment later from preferences.
alignment_ = SHELF_ALIGNMENT_BOTTOM;
- // NOTE: The delegate may access WmShelf.
- WmShell::Get()->shelf_delegate()->OnShelfCreated(this);
+ WmShell::Get()->shelf_controller()->NotifyShelfCreated(this);
}
void WmShelf::ShutdownShelf() {
DCHECK(shelf_view_);
shelf_locking_manager_.reset();
shelf_view_ = nullptr;
- WmShell::Get()->shelf_delegate()->OnShelfDestroyed(this);
}
bool WmShelf::IsShelfInitialized() const {
@@ -96,8 +123,8 @@ void WmShelf::SetAlignment(ShelfAlignment alignment) {
alignment_ = alignment;
// The ShelfWidget notifies the ShelfView of the alignment change.
shelf_widget_->OnShelfAlignmentChanged();
- WmShell::Get()->shelf_delegate()->OnShelfAlignmentChanged(this);
shelf_layout_manager_->LayoutShelf();
+ WmShell::Get()->shelf_controller()->NotifyShelfAlignmentChanged(this);
WmShell::Get()->NotifyShelfAlignmentChanged(GetWindow()->GetRootWindow());
}
@@ -141,7 +168,7 @@ void WmShelf::SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide_behavior) {
return;
auto_hide_behavior_ = auto_hide_behavior;
- WmShell::Get()->shelf_delegate()->OnShelfAutoHideBehaviorChanged(this);
+ WmShell::Get()->shelf_controller()->NotifyShelfAutoHideBehaviorChanged(this);
WmShell::Get()->NotifyShelfAutoHideBehaviorChanged(
GetWindow()->GetRootWindow());
}

Powered by Google App Engine
This is Rietveld 408576698