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

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

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Address manifest comment; working on test failures/crashes. 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 de85bfb6121d22ef94a3cb5f7e01d46f52f075cb..c34b282ba6ed0f057880c99059aa4627df939211 100644
--- a/ash/common/shelf/wm_shelf.cc
+++ b/ash/common/shelf/wm_shelf.cc
@@ -12,6 +12,7 @@
#include "ash/common/shelf/shelf_widget.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"
@@ -26,6 +27,33 @@ WmShelf* WmShelf::ForWindow(WmWindow* window) {
return window->GetRootWindowController()->GetShelf();
}
+// static
+bool WmShelf::CanChangeShelfAlignment() {
+ 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 =
@@ -62,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 {
@@ -97,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());
}
@@ -142,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