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

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

Issue 2684723003: Remove LauncherItemController::Launch, cleanup. (Closed)
Patch Set: Use AppLauncherId Created 3 years, 10 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 LauncherItemController* controller = GetLauncherItemController(id); 408 LauncherItemController* controller = GetLauncherItemController(id);
409 controller->unlock(); 409 controller->unlock();
410 if (!controller->locked() && !IsPinned(id)) 410 if (!controller->locked() && !IsPinned(id))
411 CloseLauncherItem(id); 411 CloseLauncherItem(id);
412 } 412 }
413 413
414 void ChromeLauncherControllerImpl::Launch(ash::ShelfID id, int event_flags) { 414 void ChromeLauncherControllerImpl::Launch(ash::ShelfID id, int event_flags) {
415 LauncherItemController* controller = GetLauncherItemController(id); 415 LauncherItemController* controller = GetLauncherItemController(id);
416 if (!controller) 416 if (!controller)
417 return; // In case invoked from menu and item closed while menu up. 417 return; // In case invoked from menu and item closed while menu up.
418 controller->Launch(ash::LAUNCH_FROM_UNKNOWN, event_flags); 418
419 // Launching some items replaces the associated item controller instance,
420 // which destroys the app and launch id strings; making copies avoid crashes.
421 LaunchApp(ash::launcher::AppLauncherId(controller->app_id(),
422 controller->launch_id()),
423 ash::LAUNCH_FROM_UNKNOWN, event_flags);
419 } 424 }
420 425
421 void ChromeLauncherControllerImpl::Close(ash::ShelfID id) { 426 void ChromeLauncherControllerImpl::Close(ash::ShelfID id) {
422 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); 427 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id);
423 if (!delegate) 428 if (!delegate)
424 return; // May happen if menu closed. 429 return; // May happen if menu closed.
425 delegate->Close(); 430 delegate->Close();
426 } 431 }
427 432
428 bool ChromeLauncherControllerImpl::IsOpen(ash::ShelfID id) { 433 bool ChromeLauncherControllerImpl::IsOpen(ash::ShelfID id) {
(...skipping 19 matching lines...) Expand all
448 ash::ShelfID id = GetShelfIDForAppID(app_id); 453 ash::ShelfID id = GetShelfIDForAppID(app_id);
449 if (id) { 454 if (id) {
450 LauncherItemController* controller = GetLauncherItemController(id); 455 LauncherItemController* controller = GetLauncherItemController(id);
451 controller->Activate(source); 456 controller->Activate(source);
452 return; 457 return;
453 } 458 }
454 459
455 // Create a temporary application launcher item and use it to see if there are 460 // Create a temporary application launcher item and use it to see if there are
456 // running instances. 461 // running instances.
457 std::unique_ptr<AppShortcutLauncherItemController> app_controller( 462 std::unique_ptr<AppShortcutLauncherItemController> app_controller(
458 AppShortcutLauncherItemController::Create(app_id, "", this)); 463 AppShortcutLauncherItemController::Create(app_id, std::string(), this));
459 if (!app_controller->GetRunningApplications().empty()) 464 if (!app_controller->GetRunningApplications().empty())
460 app_controller->Activate(source); 465 app_controller->Activate(source);
461 else 466 else
462 LaunchApp(app_id, source, event_flags); 467 LaunchApp(ash::launcher::AppLauncherId(app_id), source, event_flags);
463 } 468 }
464 469
465 void ChromeLauncherControllerImpl::SetLauncherItemImage( 470 void ChromeLauncherControllerImpl::SetLauncherItemImage(
466 ash::ShelfID shelf_id, 471 ash::ShelfID shelf_id,
467 const gfx::ImageSkia& image) { 472 const gfx::ImageSkia& image) {
468 const ash::ShelfItem* item = GetItem(shelf_id); 473 const ash::ShelfItem* item = GetItem(shelf_id);
469 if (item) { 474 if (item) {
470 ash::ShelfItem new_item = *item; 475 ash::ShelfItem new_item = *item;
471 new_item.image = image; 476 new_item.image = image;
472 model_->Set(model_->ItemIndexByID(shelf_id), new_item); 477 model_->Set(model_->ItemIndexByID(shelf_id), new_item);
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 LauncherItemController* controller = GetLauncherItemController(item.id); 1496 LauncherItemController* controller = GetLauncherItemController(item.id);
1492 if (!controller || controller->image_set_by_controller()) 1497 if (!controller || controller->image_set_by_controller())
1493 continue; 1498 continue;
1494 item.image = image; 1499 item.image = image;
1495 if (arc_deferred_launcher_) 1500 if (arc_deferred_launcher_)
1496 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1501 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1497 model_->Set(index, item); 1502 model_->Set(index, item);
1498 // It's possible we're waiting on more than one item, so don't break. 1503 // It's possible we're waiting on more than one item, so don't break.
1499 } 1504 }
1500 } 1505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698