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

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

Issue 2551243002: Use ChromeLauncherControllerImpl::GetItem; cleanup. (Closed)
Patch Set: Add early return to ShelfModel::Set. Created 4 years 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 | « no previous file | chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.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_model.h" 5 #include "ash/common/shelf/shelf_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/shelf/shelf_item_delegate.h" 9 #include "ash/common/shelf/shelf_item_delegate.h"
10 #include "ash/common/shelf/shelf_model_observer.h" 10 #include "ash/common/shelf/shelf_model_observer.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // TODO: this needs to enforce valid ranges. 84 // TODO: this needs to enforce valid ranges.
85 ShelfItem item(items_[index]); 85 ShelfItem item(items_[index]);
86 items_.erase(items_.begin() + index); 86 items_.erase(items_.begin() + index);
87 items_.insert(items_.begin() + target_index, item); 87 items_.insert(items_.begin() + target_index, item);
88 for (auto& observer : observers_) 88 for (auto& observer : observers_)
89 observer.ShelfItemMoved(index, target_index); 89 observer.ShelfItemMoved(index, target_index);
90 } 90 }
91 91
92 void ShelfModel::Set(int index, const ShelfItem& item) { 92 void ShelfModel::Set(int index, const ShelfItem& item) {
93 DCHECK(index >= 0 && index < item_count()); 93 DCHECK(index >= 0 && index < item_count());
94 if (index < 0 || index >= item_count())
James Cook 2016/12/06 05:54:22 Yeah, this is all that I meant. optional: You cou
msw 2016/12/06 18:02:22 Done.
95 return;
96
94 int new_index = item.type == items_[index].type 97 int new_index = item.type == items_[index].type
95 ? index 98 ? index
96 : ValidateInsertionIndex(item.type, index); 99 : ValidateInsertionIndex(item.type, index);
97 100
98 ShelfItem old_item(items_[index]); 101 ShelfItem old_item(items_[index]);
99 items_[index] = item; 102 items_[index] = item;
100 items_[index].id = old_item.id; 103 items_[index].id = old_item.id;
101 for (auto& observer : observers_) 104 for (auto& observer : observers_)
102 observer.ShelfItemChanged(index, old_item); 105 observer.ShelfItemChanged(index, old_item);
103 106
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 201
199 return index; 202 return index;
200 } 203 }
201 204
202 void ShelfModel::RemoveShelfItemDelegate(ShelfID id) { 205 void ShelfModel::RemoveShelfItemDelegate(ShelfID id) {
203 if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end()) 206 if (id_to_item_delegate_map_.find(id) != id_to_item_delegate_map_.end())
204 id_to_item_delegate_map_.erase(id); 207 id_to_item_delegate_map_.erase(id);
205 } 208 }
206 209
207 } // namespace ash 210 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698