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

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

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Address comments. 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
« no previous file with comments | « ash/common/shelf/wm_shelf.h ('k') | ash/common/wm/panels/panel_layout_manager.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 de85bfb6121d22ef94a3cb5f7e01d46f52f075cb..d1d09c035f76e2bf5deaca46be21aaedfe8fdd08 100644
--- a/ash/common/shelf/wm_shelf.cc
+++ b/ash/common/shelf/wm_shelf.cc
@@ -4,6 +4,7 @@
#include "ash/common/shelf/wm_shelf.h"
+#include "ash/common/shelf/shelf_controller.h"
#include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/shelf/shelf_item_delegate.h"
#include "ash/common/shelf/shelf_layout_manager.h"
@@ -12,6 +13,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 +28,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 +91,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 +124,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 +169,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());
}
« no previous file with comments | « ash/common/shelf/wm_shelf.h ('k') | ash/common/wm/panels/panel_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698