| OLD | NEW |
| 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 return; | 1161 return; |
| 1162 | 1162 |
| 1163 const int max_index = model_->item_count(); | 1163 const int max_index = model_->item_count(); |
| 1164 const int index = model_->ItemIndexByID(shelf_id); | 1164 const int index = model_->ItemIndexByID(shelf_id); |
| 1165 DCHECK_GT(index, 0); | 1165 DCHECK_GT(index, 0); |
| 1166 | 1166 |
| 1167 const std::string& app_id = GetAppIDForShelfID(shelf_id); | 1167 const std::string& app_id = GetAppIDForShelfID(shelf_id); |
| 1168 DCHECK(!app_id.empty()); | 1168 DCHECK(!app_id.empty()); |
| 1169 | 1169 |
| 1170 std::string app_id_before; | 1170 std::string app_id_before; |
| 1171 std::string app_id_after; | 1171 std::vector<std::string> app_ids_after; |
| 1172 | 1172 |
| 1173 for (int i = index - 1; i > 0; --i) { | 1173 for (int i = index - 1; i > 0; --i) { |
| 1174 const ash::ShelfID shelf_id_before = model_->items()[i].id; | 1174 const ash::ShelfID shelf_id_before = model_->items()[i].id; |
| 1175 if (IsPinned(shelf_id_before)) { | 1175 if (IsPinned(shelf_id_before)) { |
| 1176 app_id_before = GetAppIDForShelfID(shelf_id_before); | 1176 app_id_before = GetAppIDForShelfID(shelf_id_before); |
| 1177 DCHECK(!app_id_before.empty()); | 1177 DCHECK(!app_id_before.empty()); |
| 1178 break; | 1178 break; |
| 1179 } | 1179 } |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 for (int i = index + 1; i < max_index; ++i) { | 1182 for (int i = index + 1; i < max_index; ++i) { |
| 1183 const ash::ShelfID shelf_id_after = model_->items()[i].id; | 1183 const ash::ShelfID shelf_id_after = model_->items()[i].id; |
| 1184 if (IsPinned(shelf_id_after)) { | 1184 if (IsPinned(shelf_id_after)) { |
| 1185 app_id_after = GetAppIDForShelfID(shelf_id_after); | 1185 const std::string app_id_after = GetAppIDForShelfID(shelf_id_after); |
| 1186 DCHECK(!app_id_after.empty()); | 1186 DCHECK(!app_id_after.empty()); |
| 1187 break; | 1187 app_ids_after.push_back(app_id_after); |
| 1188 } | 1188 } |
| 1189 } | 1189 } |
| 1190 | 1190 |
| 1191 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_id_after); | 1191 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_ids_after); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1194 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
| 1195 UpdateAppLaunchersFromPref(); | 1195 UpdateAppLaunchersFromPref(); |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1198 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
| 1199 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1199 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1200 FROM_HERE, | 1200 FROM_HERE, |
| 1201 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1201 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 if (index == -1) | 1705 if (index == -1) |
| 1706 continue; | 1706 continue; |
| 1707 ash::ShelfItem item = model_->items()[index]; | 1707 ash::ShelfItem item = model_->items()[index]; |
| 1708 item.image = image; | 1708 item.image = image; |
| 1709 if (arc_deferred_launcher_) | 1709 if (arc_deferred_launcher_) |
| 1710 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1710 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1711 model_->Set(index, item); | 1711 model_->Set(index, item); |
| 1712 // It's possible we're waiting on more than one item, so don't break. | 1712 // It's possible we're waiting on more than one item, so don't break. |
| 1713 } | 1713 } |
| 1714 } | 1714 } |
| OLD | NEW |