| 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 "chrome/browser/ui/app_list/apps_model_builder.h" | 5 #include "chrome/browser/ui/app_list/apps_model_builder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 AddApps(service->extensions(), &apps); | 182 AddApps(service->extensions(), &apps); |
| 183 AddApps(service->disabled_extensions(), &apps); | 183 AddApps(service->disabled_extensions(), &apps); |
| 184 AddApps(service->terminated_extensions(), &apps); | 184 AddApps(service->terminated_extensions(), &apps); |
| 185 | 185 |
| 186 if (apps.empty()) | 186 if (apps.empty()) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 service->extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); | 189 service->extension_prefs()->extension_sorting()->FixNTPOrdinalCollisions(); |
| 190 std::sort(apps.begin(), apps.end(), &AppPrecedes); | 190 std::sort(apps.begin(), apps.end(), &AppPrecedes); |
| 191 | 191 |
| 192 for (size_t i = 0; i < apps.size(); ++i) | 192 ScopedVector<app_list::AppListItemModel> items; |
| 193 model_->Add(apps[i]); | 193 items.assign(apps.begin(), apps.end()); |
| 194 |
| 195 model_->AddAll(items.Pass()); |
| 196 |
| 194 } | 197 } |
| 195 | 198 |
| 196 void AppsModelBuilder::ResortApps() { | 199 void AppsModelBuilder::ResortApps() { |
| 197 // Scan app items in |model_| and put the apps that do not have valid ordinals | 200 // Scan app items in |model_| and put the apps that do not have valid ordinals |
| 198 // into |invalid_ordinal_apps|. This is needed to handle uninstalling a | 201 // into |invalid_ordinal_apps|. This is needed to handle uninstalling a |
| 199 // terminated app case, where there is no unload notification and uninstall | 202 // terminated app case, where there is no unload notification and uninstall |
| 200 // notification comes in after the app's ordinals are cleared. | 203 // notification comes in after the app's ordinals are cleared. |
| 201 // See http://crbug.com/256749. | 204 // See http://crbug.com/256749. |
| 202 Apps apps; | 205 Apps apps; |
| 203 Apps invalid_ordinal_apps; | 206 Apps invalid_ordinal_apps; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 318 |
| 316 ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; | 319 ExtensionAppItem* prev = target_index > 0 ? GetAppAt(target_index - 1) : NULL; |
| 317 ExtensionAppItem* next = target_index + 1 < model_->item_count() ? | 320 ExtensionAppItem* next = target_index + 1 < model_->item_count() ? |
| 318 GetAppAt(target_index + 1) : NULL; | 321 GetAppAt(target_index + 1) : NULL; |
| 319 GetAppAt(target_index)->Move(prev, next); | 322 GetAppAt(target_index)->Move(prev, next); |
| 320 } | 323 } |
| 321 | 324 |
| 322 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { | 325 void AppsModelBuilder::ListItemsChanged(size_t start, size_t count) { |
| 323 NOTREACHED(); | 326 NOTREACHED(); |
| 324 } | 327 } |
| OLD | NEW |