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

Unified Diff: ash/common/shelf/shelf_item_delegate_manager.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: ash/common/shelf/shelf_item_delegate_manager.cc
diff --git a/ash/common/shelf/shelf_item_delegate_manager.cc b/ash/common/shelf/shelf_item_delegate_manager.cc
deleted file mode 100644
index 29670018f5fb4acb693fba1c39af1518f169797d..0000000000000000000000000000000000000000
--- a/ash/common/shelf/shelf_item_delegate_manager.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/common/shelf/shelf_item_delegate_manager.h"
-
-#include "ash/common/shelf/shelf_item_delegate.h"
-#include "ash/common/shelf/shelf_model.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-
-namespace ash {
-
-ShelfItemDelegateManager::ShelfItemDelegateManager(ShelfModel* model)
- : model_(model) {
- DCHECK(model_);
- model_->AddObserver(this);
-}
-
-ShelfItemDelegateManager::~ShelfItemDelegateManager() {
- model_->RemoveObserver(this);
- STLDeleteContainerPairSecondPointers(id_to_item_delegate_map_.begin(),
- id_to_item_delegate_map_.end());
-}
-
-void ShelfItemDelegateManager::AddObserver(
- ShelfItemDelegateManagerObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void ShelfItemDelegateManager::RemoveObserver(
- ShelfItemDelegateManagerObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void ShelfItemDelegateManager::SetShelfItemDelegate(
- ShelfID id,
- std::unique_ptr<ShelfItemDelegate> item_delegate) {
- // If another ShelfItemDelegate is already registered for |id|, we assume
- // that this request is replacing ShelfItemDelegate for |id| with
- // |item_delegate|.
- RemoveShelfItemDelegate(id);
-
- FOR_EACH_OBSERVER(ShelfItemDelegateManagerObserver, observers_,
- OnSetShelfItemDelegate(id, item_delegate.get()));
-
- id_to_item_delegate_map_[id] = item_delegate.release();
-}
-
-ShelfItemDelegate* ShelfItemDelegateManager::GetShelfItemDelegate(ShelfID id) {
- if (model_->ItemIndexByID(id) != -1) {
- // Each ShelfItem has to have a ShelfItemDelegate.
- DCHECK(id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end());
- return id_to_item_delegate_map_[id];
- }
- return NULL;
-}
-
-void ShelfItemDelegateManager::ShelfItemAdded(int index) {}
-
-void ShelfItemDelegateManager::ShelfItemRemoved(int index, ShelfID id) {
- RemoveShelfItemDelegate(id);
- FOR_EACH_OBSERVER(ShelfItemDelegateManagerObserver, observers_,
- OnSetShelfItemDelegate(id, nullptr));
-}
-
-void ShelfItemDelegateManager::ShelfItemMoved(int start_index,
- int target_index) {}
-
-void ShelfItemDelegateManager::ShelfItemChanged(int index,
- const ShelfItem& old_item) {}
-
-void ShelfItemDelegateManager::RemoveShelfItemDelegate(ShelfID id) {
- if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()) {
- delete id_to_item_delegate_map_[id];
- id_to_item_delegate_map_.erase(id);
- }
-}
-
-} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698