| OLD | NEW |
| 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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/launcher/launcher_model_observer.h" | 10 #include "ash/launcher/launcher_model_observer.h" |
| 11 | 11 |
| 12 namespace ash { | 12 namespace ash { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 int LauncherItemTypeToWeight(LauncherItemType type) { | 16 int LauncherItemTypeToWeight(LauncherItemType type) { |
| 17 switch (type) { | 17 if (ash::switches::UseAlternateShelfLayout()) { |
| 18 case TYPE_BROWSER_SHORTCUT: | 18 switch (type) { |
| 19 case TYPE_APP_SHORTCUT: | 19 case TYPE_APP_LIST: |
| 20 case TYPE_WINDOWED_APP: | 20 return 0; |
| 21 return 0; | 21 case TYPE_BROWSER_SHORTCUT: |
| 22 case TYPE_TABBED: | 22 case TYPE_APP_SHORTCUT: |
| 23 case TYPE_PLATFORM_APP: | 23 case TYPE_WINDOWED_APP: |
| 24 return 1; | 24 return 1; |
| 25 case TYPE_APP_LIST: | 25 case TYPE_TABBED: |
| 26 return ash::switches::UseAlternateShelfLayout() ? 0 : 2; | 26 case TYPE_PLATFORM_APP: |
| 27 case TYPE_APP_PANEL: | 27 return 2; |
| 28 return 3; | 28 case TYPE_APP_PANEL: |
| 29 return 3; |
| 30 } |
| 31 } else { |
| 32 switch (type) { |
| 33 case TYPE_BROWSER_SHORTCUT: |
| 34 case TYPE_APP_SHORTCUT: |
| 35 case TYPE_WINDOWED_APP: |
| 36 return 0; |
| 37 case TYPE_TABBED: |
| 38 case TYPE_PLATFORM_APP: |
| 39 return 1; |
| 40 case TYPE_APP_LIST: |
| 41 return 2; |
| 42 case TYPE_APP_PANEL: |
| 43 return 3; |
| 44 } |
| 29 } | 45 } |
| 30 | 46 |
| 31 NOTREACHED() << "Invalid type " << type; | 47 NOTREACHED() << "Invalid type " << type; |
| 32 return 1; | 48 return 1; |
| 33 } | 49 } |
| 34 | 50 |
| 35 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { | 51 bool CompareByWeight(const LauncherItem& a, const LauncherItem& b) { |
| 36 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type); | 52 return LauncherItemTypeToWeight(a.type) < LauncherItemTypeToWeight(b.type); |
| 37 } | 53 } |
| 38 | 54 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 CompareByWeight) - items_.begin(), | 175 CompareByWeight) - items_.begin(), |
| 160 static_cast<LauncherItems::difference_type>(index)); | 176 static_cast<LauncherItems::difference_type>(index)); |
| 161 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, | 177 index = std::min(std::upper_bound(items_.begin(), items_.end(), weight_dummy, |
| 162 CompareByWeight) - items_.begin(), | 178 CompareByWeight) - items_.begin(), |
| 163 static_cast<LauncherItems::difference_type>(index)); | 179 static_cast<LauncherItems::difference_type>(index)); |
| 164 | 180 |
| 165 return index; | 181 return index; |
| 166 } | 182 } |
| 167 | 183 |
| 168 } // namespace ash | 184 } // namespace ash |
| OLD | NEW |