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

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

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

Powered by Google App Engine
This is Rietveld 408576698