Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2366073002: Fix crash on item drag in shelf. (Closed)
Patch Set: Drop NOTREACHED Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 return; 1170 return;
1171 1171
1172 const int max_index = model_->item_count(); 1172 const int max_index = model_->item_count();
1173 const int index = model_->ItemIndexByID(shelf_id); 1173 const int index = model_->ItemIndexByID(shelf_id);
1174 DCHECK_GT(index, 0); 1174 DCHECK_GT(index, 0);
1175 1175
1176 const std::string& app_id = GetAppIDForShelfID(shelf_id); 1176 const std::string& app_id = GetAppIDForShelfID(shelf_id);
1177 DCHECK(!app_id.empty()); 1177 DCHECK(!app_id.empty());
1178 1178
1179 std::string app_id_before; 1179 std::string app_id_before;
1180 std::string app_id_after; 1180 std::vector<std::string> app_ids_after;
1181 1181
1182 for (int i = index - 1; i > 0; --i) { 1182 for (int i = index - 1; i > 0; --i) {
1183 const ash::ShelfID shelf_id_before = model_->items()[i].id; 1183 const ash::ShelfID shelf_id_before = model_->items()[i].id;
1184 if (IsPinned(shelf_id_before)) { 1184 if (IsPinned(shelf_id_before)) {
1185 app_id_before = GetAppIDForShelfID(shelf_id_before); 1185 app_id_before = GetAppIDForShelfID(shelf_id_before);
1186 DCHECK(!app_id_before.empty()); 1186 DCHECK(!app_id_before.empty());
1187 break; 1187 break;
1188 } 1188 }
1189 } 1189 }
1190 1190
1191 for (int i = index + 1; i < max_index; ++i) { 1191 for (int i = index + 1; i < max_index; ++i) {
1192 const ash::ShelfID shelf_id_after = model_->items()[i].id; 1192 const ash::ShelfID shelf_id_after = model_->items()[i].id;
1193 if (IsPinned(shelf_id_after)) { 1193 if (IsPinned(shelf_id_after)) {
1194 app_id_after = GetAppIDForShelfID(shelf_id_after); 1194 const std::string app_id_after = GetAppIDForShelfID(shelf_id_after);
1195 DCHECK(!app_id_after.empty()); 1195 DCHECK(!app_id_after.empty());
1196 break; 1196 app_ids_after.push_back(app_id_after);
1197 } 1197 }
1198 } 1198 }
1199 1199
1200 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_id_after); 1200 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_ids_after);
1201 } 1201 }
1202 1202
1203 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { 1203 void ChromeLauncherControllerImpl::OnSyncModelUpdated() {
1204 UpdateAppLaunchersFromPref(); 1204 UpdateAppLaunchersFromPref();
1205 } 1205 }
1206 1206
1207 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { 1207 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() {
1208 base::ThreadTaskRunnerHandle::Get()->PostTask( 1208 base::ThreadTaskRunnerHandle::Get()->PostTask(
1209 FROM_HERE, 1209 FROM_HERE,
1210 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, 1210 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref,
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 if (index == -1) 1719 if (index == -1)
1720 continue; 1720 continue;
1721 ash::ShelfItem item = model_->items()[index]; 1721 ash::ShelfItem item = model_->items()[index];
1722 item.image = image; 1722 item.image = image;
1723 if (arc_deferred_launcher_) 1723 if (arc_deferred_launcher_)
1724 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1724 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1725 model_->Set(index, item); 1725 model_->Set(index, item);
1726 // It's possible we're waiting on more than one item, so don't break. 1726 // It's possible we're waiting on more than one item, so don't break.
1727 } 1727 }
1728 } 1728 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698