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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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::RemovePinPosition( |
397 profile_, ash::launcher::AppLauncherId(GetAppIDForShelfID(id))); | |
stevenjb
2016/09/27 16:42:36
{} around multi-line if bodies.
Andra Paraschiv
2016/10/03 15:53:02
Done.
| |
397 | 398 |
398 if (controller->type() == LauncherItemController::TYPE_APP || | 399 if (controller->type() == LauncherItemController::TYPE_APP || |
399 controller->locked()) { | 400 controller->locked()) { |
400 UnpinRunningAppInternal(model_->ItemIndexByID(id)); | 401 UnpinRunningAppInternal(model_->ItemIndexByID(id)); |
401 } else { | 402 } else { |
402 LauncherItemClosed(id); | 403 LauncherItemClosed(id); |
403 } | 404 } |
404 } | 405 } |
405 | 406 |
406 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { | 407 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1170 return; | 1171 return; |
1171 | 1172 |
1172 const int max_index = model_->item_count(); | 1173 const int max_index = model_->item_count(); |
1173 const int index = model_->ItemIndexByID(shelf_id); | 1174 const int index = model_->ItemIndexByID(shelf_id); |
1174 DCHECK_GT(index, 0); | 1175 DCHECK_GT(index, 0); |
1175 | 1176 |
1176 const std::string& app_id = GetAppIDForShelfID(shelf_id); | 1177 const std::string& app_id = GetAppIDForShelfID(shelf_id); |
1177 DCHECK(!app_id.empty()); | 1178 DCHECK(!app_id.empty()); |
1178 | 1179 |
1179 std::string app_id_before; | 1180 std::string app_id_before; |
1180 std::vector<std::string> app_ids_after; | 1181 std::vector<std::unique_ptr<ash::launcher::AppLauncherId>> |
1182 app_launcher_ids_after; | |
1181 | 1183 |
1182 for (int i = index - 1; i > 0; --i) { | 1184 for (int i = index - 1; i > 0; --i) { |
1183 const ash::ShelfID shelf_id_before = model_->items()[i].id; | 1185 const ash::ShelfID shelf_id_before = model_->items()[i].id; |
1184 if (IsPinned(shelf_id_before)) { | 1186 if (IsPinned(shelf_id_before)) { |
1185 app_id_before = GetAppIDForShelfID(shelf_id_before); | 1187 app_id_before = GetAppIDForShelfID(shelf_id_before); |
1186 DCHECK(!app_id_before.empty()); | 1188 DCHECK(!app_id_before.empty()); |
1187 break; | 1189 break; |
1188 } | 1190 } |
1189 } | 1191 } |
1190 | 1192 |
1191 for (int i = index + 1; i < max_index; ++i) { | 1193 for (int i = index + 1; i < max_index; ++i) { |
1192 const ash::ShelfID shelf_id_after = model_->items()[i].id; | 1194 const ash::ShelfID shelf_id_after = model_->items()[i].id; |
1193 if (IsPinned(shelf_id_after)) { | 1195 if (IsPinned(shelf_id_after)) { |
1194 const std::string app_id_after = GetAppIDForShelfID(shelf_id_after); | 1196 const std::string app_id_after = GetAppIDForShelfID(shelf_id_after); |
1195 DCHECK(!app_id_after.empty()); | 1197 DCHECK(!app_id_after.empty()); |
1196 app_ids_after.push_back(app_id_after); | 1198 app_launcher_ids_after.push_back( |
1199 std::unique_ptr<ash::launcher::AppLauncherId>( | |
1200 new ash::launcher::AppLauncherId(app_id_after))); | |
stevenjb
2016/09/27 16:42:36
app_launcher_ids_after.push_back(base::MakeUnique<
Andra Paraschiv
2016/10/03 15:53:02
Done.
| |
1197 } | 1201 } |
1198 } | 1202 } |
1199 | 1203 |
1200 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_ids_after); | 1204 ash::launcher::SetPinPosition(profile_, ash::launcher::AppLauncherId(app_id), |
1205 ash::launcher::AppLauncherId(app_id_before), | |
1206 app_launcher_ids_after); | |
1201 } | 1207 } |
1202 | 1208 |
1203 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { | 1209 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { |
1204 UpdateAppLaunchersFromPref(); | 1210 UpdateAppLaunchersFromPref(); |
1205 } | 1211 } |
1206 | 1212 |
1207 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { | 1213 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { |
1208 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1214 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1209 FROM_HERE, | 1215 FROM_HERE, |
1210 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, | 1216 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1719 if (index == -1) | 1725 if (index == -1) |
1720 continue; | 1726 continue; |
1721 ash::ShelfItem item = model_->items()[index]; | 1727 ash::ShelfItem item = model_->items()[index]; |
1722 item.image = image; | 1728 item.image = image; |
1723 if (arc_deferred_launcher_) | 1729 if (arc_deferred_launcher_) |
1724 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1730 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
1725 model_->Set(index, item); | 1731 model_->Set(index, item); |
1726 // It's possible we're waiting on more than one item, so don't break. | 1732 // It's possible we're waiting on more than one item, so don't break. |
1727 } | 1733 } |
1728 } | 1734 } |
OLD | NEW |