| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 void ChromeLauncherControllerImpl::Unpin(ash::ShelfID id) { | 386 void ChromeLauncherControllerImpl::Unpin(ash::ShelfID id) { |
| 387 UnpinAndUpdatePrefs(id, true /* update_prefs */); | 387 UnpinAndUpdatePrefs(id, true /* update_prefs */); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id, | 390 void ChromeLauncherControllerImpl::UnpinAndUpdatePrefs(ash::ShelfID id, |
| 391 bool update_prefs) { | 391 bool update_prefs) { |
| 392 LauncherItemController* controller = GetLauncherItemController(id); | 392 LauncherItemController* controller = GetLauncherItemController(id); |
| 393 CHECK(controller); | 393 CHECK(controller); |
| 394 | 394 |
| 395 if (update_prefs) | 395 if (update_prefs) { |
| 396 ash::launcher::RemovePinPosition(profile_, GetAppIDForShelfID(id)); | 396 ash::launcher::AppLauncherId* app_launcher_id = |
| 397 new ash::launcher::AppLauncherId(GetAppIDForShelfID(id)); |
| 398 ash::launcher::RemovePinPosition(profile_, app_launcher_id); |
| 399 } |
| 397 | 400 |
| 398 if (controller->type() == LauncherItemController::TYPE_APP || | 401 if (controller->type() == LauncherItemController::TYPE_APP || |
| 399 controller->locked()) { | 402 controller->locked()) { |
| 400 UnpinRunningAppInternal(model_->ItemIndexByID(id)); | 403 UnpinRunningAppInternal(model_->ItemIndexByID(id)); |
| 401 } else { | 404 } else { |
| 402 LauncherItemClosed(id); | 405 LauncherItemClosed(id); |
| 403 } | 406 } |
| 404 } | 407 } |
| 405 | 408 |
| 406 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { | 409 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 | 1193 |
| 1191 for (int i = index + 1; i < max_index; ++i) { | 1194 for (int i = index + 1; i < max_index; ++i) { |
| 1192 const ash::ShelfID shelf_id_after = model_->items()[i].id; | 1195 const ash::ShelfID shelf_id_after = model_->items()[i].id; |
| 1193 if (IsPinned(shelf_id_after)) { | 1196 if (IsPinned(shelf_id_after)) { |
| 1194 app_id_after = GetAppIDForShelfID(shelf_id_after); | 1197 app_id_after = GetAppIDForShelfID(shelf_id_after); |
| 1195 DCHECK(!app_id_after.empty()); | 1198 DCHECK(!app_id_after.empty()); |
| 1196 break; | 1199 break; |
| 1197 } | 1200 } |
| 1198 } | 1201 } |
| 1199 | 1202 |
| 1200 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_id_after); | 1203 ash::launcher::AppLauncherId* app_launcher_id = |
| 1204 new ash::launcher::AppLauncherId(app_id); |
| 1205 ash::launcher::AppLauncherId* app_launcher_id_before = |
| 1206 new ash::launcher::AppLauncherId(app_id_before); |
| 1207 ash::launcher::AppLauncherId* app_launcher_id_after = |
| 1208 new ash::launcher::AppLauncherId(app_id_after); |
| 1209 |
| 1210 ash::launcher::SetPinPosition(profile_, app_launcher_id, |
| 1211 app_launcher_id_before, app_launcher_id_after); |
| 1201 } | 1212 } |
| 1202 | 1213 |
| 1203 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1214 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
| 1204 UpdateAppLaunchersFromPref(); | 1215 UpdateAppLaunchersFromPref(); |
| 1205 } | 1216 } |
| 1206 | 1217 |
| 1207 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1218 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
| 1208 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1219 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1209 FROM_HERE, | 1220 FROM_HERE, |
| 1210 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1221 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 if (index == -1) | 1730 if (index == -1) |
| 1720 continue; | 1731 continue; |
| 1721 ash::ShelfItem item = model_->items()[index]; | 1732 ash::ShelfItem item = model_->items()[index]; |
| 1722 item.image = image; | 1733 item.image = image; |
| 1723 if (arc_deferred_launcher_) | 1734 if (arc_deferred_launcher_) |
| 1724 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1735 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
| 1725 model_->Set(index, item); | 1736 model_->Set(index, item); |
| 1726 // It's possible we're waiting on more than one item, so don't break. | 1737 // It's possible we're waiting on more than one item, so don't break. |
| 1727 } | 1738 } |
| 1728 } | 1739 } |
| OLD | NEW |