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

Side by Side Diff: ash/common/shelf/shelf_item_delegate_manager.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « ash/common/shelf/shelf_item_delegate.h ('k') | ash/common/shelf/shelf_item_types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/shelf/shelf_item_delegate_manager.h" 5 #include "ash/common/shelf/shelf_item_delegate_manager.h"
6 6
7 #include "ash/common/shelf/shelf_item_delegate.h" 7 #include "ash/common/shelf/shelf_item_delegate.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 35
36 void ShelfItemDelegateManager::SetShelfItemDelegate( 36 void ShelfItemDelegateManager::SetShelfItemDelegate(
37 ShelfID id, 37 ShelfID id,
38 std::unique_ptr<ShelfItemDelegate> item_delegate) { 38 std::unique_ptr<ShelfItemDelegate> item_delegate) {
39 // If another ShelfItemDelegate is already registered for |id|, we assume 39 // If another ShelfItemDelegate is already registered for |id|, we assume
40 // that this request is replacing ShelfItemDelegate for |id| with 40 // that this request is replacing ShelfItemDelegate for |id| with
41 // |item_delegate|. 41 // |item_delegate|.
42 RemoveShelfItemDelegate(id); 42 RemoveShelfItemDelegate(id);
43 43
44 FOR_EACH_OBSERVER(ShelfItemDelegateManagerObserver, 44 FOR_EACH_OBSERVER(ShelfItemDelegateManagerObserver, observers_,
45 observers_,
46 OnSetShelfItemDelegate(id, item_delegate.get())); 45 OnSetShelfItemDelegate(id, item_delegate.get()));
47 46
48 id_to_item_delegate_map_[id] = item_delegate.release(); 47 id_to_item_delegate_map_[id] = item_delegate.release();
49 } 48 }
50 49
51 ShelfItemDelegate* ShelfItemDelegateManager::GetShelfItemDelegate(ShelfID id) { 50 ShelfItemDelegate* ShelfItemDelegateManager::GetShelfItemDelegate(ShelfID id) {
52 if (model_->ItemIndexByID(id) != -1) { 51 if (model_->ItemIndexByID(id) != -1) {
53 // Each ShelfItem has to have a ShelfItemDelegate. 52 // Each ShelfItem has to have a ShelfItemDelegate.
54 DCHECK(id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()); 53 DCHECK(id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end());
55 return id_to_item_delegate_map_[id]; 54 return id_to_item_delegate_map_[id];
56 } 55 }
57 return NULL; 56 return NULL;
58 } 57 }
59 58
60 void ShelfItemDelegateManager::ShelfItemAdded(int index) {} 59 void ShelfItemDelegateManager::ShelfItemAdded(int index) {}
61 60
62 void ShelfItemDelegateManager::ShelfItemRemoved(int index, ShelfID id) { 61 void ShelfItemDelegateManager::ShelfItemRemoved(int index, ShelfID id) {
63 RemoveShelfItemDelegate(id); 62 RemoveShelfItemDelegate(id);
64 FOR_EACH_OBSERVER(ShelfItemDelegateManagerObserver, 63 FOR_EACH_OBSERVER(ShelfItemDelegateManagerObserver, observers_,
65 observers_,
66 OnSetShelfItemDelegate(id, nullptr)); 64 OnSetShelfItemDelegate(id, nullptr));
67 } 65 }
68 66
69 void ShelfItemDelegateManager::ShelfItemMoved(int start_index, 67 void ShelfItemDelegateManager::ShelfItemMoved(int start_index,
70 int target_index) {} 68 int target_index) {}
71 69
72 void ShelfItemDelegateManager::ShelfItemChanged(int index, 70 void ShelfItemDelegateManager::ShelfItemChanged(int index,
73 const ShelfItem& old_item) {} 71 const ShelfItem& old_item) {}
74 72
75 void ShelfItemDelegateManager::RemoveShelfItemDelegate(ShelfID id) { 73 void ShelfItemDelegateManager::RemoveShelfItemDelegate(ShelfID id) {
76 if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()) { 74 if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()) {
77 delete id_to_item_delegate_map_[id]; 75 delete id_to_item_delegate_map_[id];
78 id_to_item_delegate_map_.erase(id); 76 id_to_item_delegate_map_.erase(id);
79 } 77 }
80 } 78 }
81 79
82 } // namespace ash 80 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_item_delegate.h ('k') | ash/common/shelf/shelf_item_types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698