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

Side by Side Diff: ash/launcher/launcher_model.cc

Issue 11299272: Revert 170406 - Align panel icons on the right / end. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher_model.h ('k') | ash/launcher/launcher_model_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/launcher/launcher_model.h" 5 #include "ash/launcher/launcher_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/launcher/launcher_model_observer.h" 9 #include "ash/launcher/launcher_model_observer.h"
10 10
11 namespace ash { 11 namespace ash {
12 12
13 namespace { 13 namespace {
14 14
15 int LauncherItemTypeToWeight(LauncherItemType type) { 15 int LauncherItemTypeToWeight(LauncherItemType type) {
16 switch (type) { 16 switch (type) {
17 case TYPE_BROWSER_SHORTCUT: 17 case TYPE_BROWSER_SHORTCUT:
18 return 0; 18 return 0;
19 case TYPE_APP_SHORTCUT: 19 case TYPE_APP_SHORTCUT:
20 return 1; 20 return 1;
21 case TYPE_TABBED: 21 case TYPE_TABBED:
22 case TYPE_APP_PANEL:
22 case TYPE_PLATFORM_APP: 23 case TYPE_PLATFORM_APP:
23 return 2; 24 return 2;
24 case TYPE_APP_LIST: 25 case TYPE_APP_LIST:
25 return 3; 26 return 3;
26 case TYPE_APP_PANEL:
27 return 4;
28 } 27 }
29 28
30 NOTREACHED() << "Invalid type " << type; 29 NOTREACHED() << "Invalid type " << type;
31 return 2; 30 return 2;
32 } 31 }
33 32
34 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { 33 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) {
35 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type); 34 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type);
36 } 35 }
37 36
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 110
112 LauncherItems::const_iterator LauncherModel::ItemByID(int id) const { 111 LauncherItems::const_iterator LauncherModel::ItemByID(int id) const {
113 for (LauncherItems::const_iterator i = items_.begin(); 112 for (LauncherItems::const_iterator i = items_.begin();
114 i != items_.end(); ++i) { 113 i != items_.end(); ++i) {
115 if (i->id == id) 114 if (i->id == id)
116 return i; 115 return i;
117 } 116 }
118 return items_.end(); 117 return items_.end();
119 } 118 }
120 119
121 int LauncherModel::FirstPanelIndex() const {
122 LauncherItem weight_dummy;
123 weight_dummy.type = TYPE_APP_PANEL;
124 return std::lower_bound(items_.begin(), items_.end(), weight_dummy,
125 CompareByWeight) - items_.begin();
126 }
127
128 void LauncherModel::SetStatus(Status status) { 120 void LauncherModel::SetStatus(Status status) {
129 if (status_ == status) 121 if (status_ == status)
130 return; 122 return;
131 123
132 status_ = status; 124 status_ = status;
133 FOR_EACH_OBSERVER(LauncherModelObserver, observers_, 125 FOR_EACH_OBSERVER(LauncherModelObserver, observers_,
134 LauncherStatusChanged()); 126 LauncherStatusChanged());
135 } 127 }
136 128
137 void LauncherModel::AddObserver(LauncherModelObserver* observer) { 129 void LauncherModel::AddObserver(LauncherModelObserver* observer) {
(...skipping 15 matching lines...) Expand all
153 CompareByWeight) - items_.begin(), 145 CompareByWeight) - items_.begin(),
154 static_cast<LauncherItems::difference_type>(index)); 146 static_cast<LauncherItems::difference_type>(index));
155 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, 147 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy,
156 CompareByWeight) - items_.begin(), 148 CompareByWeight) - items_.begin(),
157 static_cast<LauncherItems::difference_type>(index)); 149 static_cast<LauncherItems::difference_type>(index));
158 150
159 return index; 151 return index;
160 } 152 }
161 153
162 } // namespace ash 154 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_model.h ('k') | ash/launcher/launcher_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698