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

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

Issue 2352353002: Add AppLauncherId wrapper for items shown in shelf (Closed)
Patch Set: Review v3 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::RemovePinPosition(
397 profile_, ash::launcher::AppLauncherId(GetAppIDForShelfID(id)));
398 }
397 399
398 if (controller->type() == LauncherItemController::TYPE_APP || 400 if (controller->type() == LauncherItemController::TYPE_APP ||
399 controller->locked()) { 401 controller->locked()) {
400 UnpinRunningAppInternal(model_->ItemIndexByID(id)); 402 UnpinRunningAppInternal(model_->ItemIndexByID(id));
401 } else { 403 } else {
402 LauncherItemClosed(id); 404 LauncherItemClosed(id);
403 } 405 }
404 } 406 }
405 407
406 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { 408 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) {
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 return; 1172 return;
1171 1173
1172 const int max_index = model_->item_count(); 1174 const int max_index = model_->item_count();
1173 const int index = model_->ItemIndexByID(shelf_id); 1175 const int index = model_->ItemIndexByID(shelf_id);
1174 DCHECK_GT(index, 0); 1176 DCHECK_GT(index, 0);
1175 1177
1176 const std::string& app_id = GetAppIDForShelfID(shelf_id); 1178 const std::string& app_id = GetAppIDForShelfID(shelf_id);
1177 DCHECK(!app_id.empty()); 1179 DCHECK(!app_id.empty());
1178 1180
1179 std::string app_id_before; 1181 std::string app_id_before;
1180 std::vector<std::string> app_ids_after; 1182 std::vector<ash::launcher::AppLauncherId> 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 ash::launcher::AppLauncherId(app_id_after));
1197 } 1200 }
1198 } 1201 }
1199 1202
1200 ash::launcher::SetPinPosition(profile_, app_id, app_id_before, app_ids_after); 1203 ash::launcher::SetPinPosition(profile_, ash::launcher::AppLauncherId(app_id),
1204 ash::launcher::AppLauncherId(app_id_before),
1205 app_launcher_ids_after);
1201 } 1206 }
1202 1207
1203 void ChromeLauncherControllerImpl::OnSyncModelUpdated() { 1208 void ChromeLauncherControllerImpl::OnSyncModelUpdated() {
1204 UpdateAppLaunchersFromPref(); 1209 UpdateAppLaunchersFromPref();
1205 } 1210 }
1206 1211
1207 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() { 1212 void ChromeLauncherControllerImpl::ScheduleUpdateAppLaunchersFromPref() {
1208 base::ThreadTaskRunnerHandle::Get()->PostTask( 1213 base::ThreadTaskRunnerHandle::Get()->PostTask(
1209 FROM_HERE, 1214 FROM_HERE,
1210 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref, 1215 base::Bind(&ChromeLauncherControllerImpl::UpdateAppLaunchersFromPref,
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 if (index == -1) 1684 if (index == -1)
1680 continue; 1685 continue;
1681 ash::ShelfItem item = model_->items()[index]; 1686 ash::ShelfItem item = model_->items()[index];
1682 item.image = image; 1687 item.image = image;
1683 if (arc_deferred_launcher_) 1688 if (arc_deferred_launcher_)
1684 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1689 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1685 model_->Set(index, item); 1690 model_->Set(index, item);
1686 // It's possible we're waiting on more than one item, so don't break. 1691 // It's possible we're waiting on more than one item, so don't break.
1687 } 1692 }
1688 } 1693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698