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

Unified Diff: ash/common/wm_shell.cc

Issue 2177663002: mash: Move ownership of ShelfDelegate to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix wallpaper tests again Created 4 years, 5 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/wm_shell.h ('k') | ash/metrics/user_metrics_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/wm_shell.cc
diff --git a/ash/common/wm_shell.cc b/ash/common/wm_shell.cc
index f0ed84ed71194a1548ca50c8f78008d0f1fda893..9af808d98e79e5aa93628501062be7e98a6d8ad1 100644
--- a/ash/common/wm_shell.cc
+++ b/ash/common/wm_shell.cc
@@ -10,7 +10,9 @@
#include "ash/common/accessibility_delegate.h"
#include "ash/common/focus_cycler.h"
#include "ash/common/keyboard/keyboard_ui.h"
+#include "ash/common/session/session_state_delegate.h"
#include "ash/common/shelf/app_list_shelf_item_delegate.h"
+#include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/shelf/shelf_model.h"
#include "ash/common/shell_delegate.h"
#include "ash/common/shell_window_ids.h"
@@ -67,6 +69,8 @@ void WmShell::Shutdown() {
// ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC
// shelf items in Chrome) so explicitly shutdown early.
shelf_model_->DestroyItemDelegates();
+ // Must be destroyed before FocusClient.
+ shelf_delegate_.reset();
}
void WmShell::OnMaximizeModeStarted() {
@@ -108,6 +112,11 @@ void WmShell::RemoveLockStateObserver(LockStateObserver* observer) {
lock_state_observers_.RemoveObserver(observer);
}
+void WmShell::SetShelfDelegateForTesting(
+ std::unique_ptr<ShelfDelegate> test_delegate) {
+ shelf_delegate_ = std::move(test_delegate);
+}
+
WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate)
: delegate_(std::move(shell_delegate)),
focus_cycler_(new FocusCycler),
@@ -195,6 +204,18 @@ void WmShell::DeleteSystemTrayDelegate() {
system_tray_delegate_.reset();
}
+void WmShell::CreateShelfDelegate() {
+ // May be called multiple times as shelves are created and destroyed.
+ if (shelf_delegate_)
+ return;
+ // Must occur after SessionStateDelegate creation and user login because
+ // Chrome's implementation of ShelfDelegate assumes it can get information
+ // about multi-profile login state.
+ DCHECK(GetSessionStateDelegate());
+ DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0);
+ shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get()));
+}
+
void WmShell::DeleteWindowCycleController() {
window_cycle_controller_.reset();
}
« no previous file with comments | « ash/common/wm_shell.h ('k') | ash/metrics/user_metrics_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698