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

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

Issue 1811203002: Remove unused ShelfModelObserver::ShelfStatusChanged() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make SetStatus a simple setter, set_status. Created 4 years, 9 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/shelf/shelf_model.h ('k') | ash/shelf/shelf_model_observer.h » ('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/shelf/shelf_model.h" 5 #include "ash/shelf/shelf_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/shelf/shelf_model_observer.h" 10 #include "ash/shelf/shelf_model_observer.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 CompareByWeight) - items_.begin(); 143 CompareByWeight) - items_.begin();
144 } 144 }
145 145
146 int ShelfModel::FirstPanelIndex() const { 146 int ShelfModel::FirstPanelIndex() const {
147 ShelfItem weight_dummy; 147 ShelfItem weight_dummy;
148 weight_dummy.type = TYPE_APP_PANEL; 148 weight_dummy.type = TYPE_APP_PANEL;
149 return std::lower_bound(items_.begin(), items_.end(), weight_dummy, 149 return std::lower_bound(items_.begin(), items_.end(), weight_dummy,
150 CompareByWeight) - items_.begin(); 150 CompareByWeight) - items_.begin();
151 } 151 }
152 152
153 void ShelfModel::SetStatus(Status status) {
154 if (status_ == status)
155 return;
156
157 status_ = status;
158 FOR_EACH_OBSERVER(ShelfModelObserver, observers_, ShelfStatusChanged());
159 }
160
161 void ShelfModel::AddObserver(ShelfModelObserver* observer) { 153 void ShelfModel::AddObserver(ShelfModelObserver* observer) {
162 observers_.AddObserver(observer); 154 observers_.AddObserver(observer);
163 } 155 }
164 156
165 void ShelfModel::RemoveObserver(ShelfModelObserver* observer) { 157 void ShelfModel::RemoveObserver(ShelfModelObserver* observer) {
166 observers_.RemoveObserver(observer); 158 observers_.RemoveObserver(observer);
167 } 159 }
168 160
169 int ShelfModel::ValidateInsertionIndex(ShelfItemType type, int index) const { 161 int ShelfModel::ValidateInsertionIndex(ShelfItemType type, int index) const {
170 DCHECK(index >= 0 && index <= item_count() + 1); 162 DCHECK(index >= 0 && index <= item_count() + 1);
171 163
172 // Clamp |index| to the allowed range for the type as determined by |weight|. 164 // Clamp |index| to the allowed range for the type as determined by |weight|.
173 ShelfItem weight_dummy; 165 ShelfItem weight_dummy;
174 weight_dummy.type = type; 166 weight_dummy.type = type;
175 index = std::max(std::lower_bound(items_.begin(), items_.end(), weight_dummy, 167 index = std::max(std::lower_bound(items_.begin(), items_.end(), weight_dummy,
176 CompareByWeight) - items_.begin(), 168 CompareByWeight) - items_.begin(),
177 static_cast<ShelfItems::difference_type>(index)); 169 static_cast<ShelfItems::difference_type>(index));
178 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, 170 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy,
179 CompareByWeight) - items_.begin(), 171 CompareByWeight) - items_.begin(),
180 static_cast<ShelfItems::difference_type>(index)); 172 static_cast<ShelfItems::difference_type>(index));
181 173
182 return index; 174 return index;
183 } 175 }
184 176
185 } // namespace ash 177 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_model.h ('k') | ash/shelf/shelf_model_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698