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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2171813004: mash: Fold ShelfItemDelegateManager into ShelfModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
index a59ff12ccac573ba90adc3b42d91f462d1036350..fc5bda15669a80b6e86d14db2ecd1c11712f784f 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc
@@ -10,7 +10,6 @@
#include "ash/common/ash_switches.h"
#include "ash/common/multi_profile_uma.h"
-#include "ash/common/shelf/shelf_item_delegate_manager.h"
#include "ash/common/shelf/shelf_model.h"
#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/wm_shell.h"
@@ -192,6 +191,7 @@ ChromeLauncherControllerImpl::ChromeLauncherControllerImpl(
Profile* profile,
ash::ShelfModel* model)
: model_(model), profile_(profile) {
+ DCHECK(model_);
if (!profile_) {
// If no profile was passed, we take the currently active profile and use it
// as the owner of the current desktop.
@@ -253,22 +253,11 @@ ChromeLauncherControllerImpl::ChromeLauncherControllerImpl(
// Right now ash::Shell isn't created for tests.
// TODO(mukai): Allows it to observe display change and write tests.
- if (ash::Shell::HasInstance()) {
+ if (ash::Shell::HasInstance())
ash::Shell::GetInstance()->window_tree_host_manager()->AddObserver(this);
- // If it got already set, we remove the observer first again and swap the
- // ItemDelegateManager.
- if (item_delegate_manager_)
- item_delegate_manager_->RemoveObserver(this);
- item_delegate_manager_ =
- ash::Shell::GetInstance()->shelf_item_delegate_manager();
- item_delegate_manager_->AddObserver(this);
- }
}
ChromeLauncherControllerImpl::~ChromeLauncherControllerImpl() {
- if (item_delegate_manager_)
- item_delegate_manager_->RemoveObserver(this);
-
// Reset the BrowserStatusMonitor as it has a weak pointer to this.
browser_status_monitor_.reset();
@@ -435,7 +424,7 @@ bool ChromeLauncherControllerImpl::IsPinnable(ash::ShelfID id) const {
std::string app_id;
return ((type == ash::TYPE_APP_SHORTCUT || type == ash::TYPE_PLATFORM_APP ||
type == ash::TYPE_WINDOWED_APP) &&
- item_delegate_manager_->GetShelfItemDelegate(id)->CanPin());
+ model_->GetShelfItemDelegate(id)->CanPin());
}
void ChromeLauncherControllerImpl::LockV1AppWithID(const std::string& app_id) {
@@ -1027,17 +1016,6 @@ const std::string& ChromeLauncherControllerImpl::GetAppIdFromShelfIdForTest(
return id_to_item_controller_map_[id]->app_id();
}
-void ChromeLauncherControllerImpl::SetShelfItemDelegateManagerForTest(
- ash::ShelfItemDelegateManager* manager) {
- if (item_delegate_manager_)
- item_delegate_manager_->RemoveObserver(this);
-
- item_delegate_manager_ = manager;
-
- if (item_delegate_manager_)
- item_delegate_manager_->AddObserver(this);
-}
-
///////////////////////////////////////////////////////////////////////////////
// ChromeLauncherControllerImpl private:
@@ -1515,8 +1493,7 @@ void ChromeLauncherControllerImpl::SetShelfItemDelegate(
ash::ShelfItemDelegate* item_delegate) {
DCHECK_GT(id, 0);
DCHECK(item_delegate);
- DCHECK(item_delegate_manager_);
- item_delegate_manager_->SetShelfItemDelegate(
+ model_->SetShelfItemDelegate(
id, std::unique_ptr<ash::ShelfItemDelegate>(item_delegate));
}

Powered by Google App Engine
This is Rietveld 408576698