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

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

Issue 2696073002: Merge ShelfItemDelegate::ItemSelected & LauncherItemDelegate::Activate. (Closed)
Patch Set: nit 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h " 44 #include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h "
45 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" 45 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
46 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h" 46 #include "chrome/browser/ui/ash/launcher/app_window_launcher_item_controller.h"
47 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 47 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
48 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" 48 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
49 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h" 49 #include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controll er.h"
50 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 50 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
51 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h " 51 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_browser.h "
52 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h" 52 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
53 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h" 53 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
54 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h"
55 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h" 54 #include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h"
56 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 55 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
57 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h" 56 #include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h"
58 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 57 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
59 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h" 58 #include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_contr oller.h"
60 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h" 59 #include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
61 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 60 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
62 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 61 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
63 #include "chrome/browser/ui/browser.h" 62 #include "chrome/browser/ui/browser.h"
64 #include "chrome/browser/ui/browser_finder.h" 63 #include "chrome/browser/ui/browser_finder.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return false; 438 return false;
440 439
441 std::string app_id = GetAppIDForShelfID(id); 440 std::string app_id = GetAppIDForShelfID(id);
442 const Extension* extension = GetExtensionForAppID(app_id, profile()); 441 const Extension* extension = GetExtensionForAppID(app_id, profile());
443 // An extension can be synced / updated at any time and therefore not be 442 // An extension can be synced / updated at any time and therefore not be
444 // available. 443 // available.
445 return extension ? extension->is_platform_app() : false; 444 return extension ? extension->is_platform_app() : false;
446 } 445 }
447 446
448 void ChromeLauncherControllerImpl::ActivateApp(const std::string& app_id, 447 void ChromeLauncherControllerImpl::ActivateApp(const std::string& app_id,
449 ash::LaunchSource source, 448 ash::ShelfLaunchSource source,
450 int event_flags) { 449 int event_flags) {
451 // If there is an existing non-shortcut controller for this app, open it. 450 // If there is an existing non-shortcut controller for this app, open it.
452 ash::ShelfID id = GetShelfIDForAppID(app_id); 451 ash::ShelfID id = GetShelfIDForAppID(app_id);
453 if (id) { 452 if (id) {
454 LauncherItemController* controller = GetLauncherItemController(id); 453 model_->GetShelfItemDelegate(id)->ItemSelectedBySource(source);
455 controller->Activate(source);
456 return; 454 return;
457 } 455 }
458 456
459 // Create a temporary application launcher item and use it to see if there are 457 // Create a temporary application launcher item and use it to see if there are
460 // running instances. 458 // running instances.
461 std::unique_ptr<AppShortcutLauncherItemController> app_controller( 459 std::unique_ptr<AppShortcutLauncherItemController> controller(
462 AppShortcutLauncherItemController::Create(app_id, std::string(), this)); 460 AppShortcutLauncherItemController::Create(app_id, std::string(), this));
463 if (!app_controller->GetRunningApplications().empty()) 461 if (!controller->GetRunningApplications().empty())
464 app_controller->Activate(source); 462 controller->ItemSelectedBySource(source);
465 else 463 else
466 LaunchApp(ash::AppLauncherId(app_id), source, event_flags); 464 LaunchApp(ash::AppLauncherId(app_id), source, event_flags);
467 } 465 }
468 466
469 void ChromeLauncherControllerImpl::SetLauncherItemImage( 467 void ChromeLauncherControllerImpl::SetLauncherItemImage(
470 ash::ShelfID shelf_id, 468 ash::ShelfID shelf_id,
471 const gfx::ImageSkia& image) { 469 const gfx::ImageSkia& image) {
472 const ash::ShelfItem* item = GetItem(shelf_id); 470 const ash::ShelfItem* item = GetItem(shelf_id);
473 if (item) { 471 if (item) {
474 ash::ShelfItem new_item = *item; 472 ash::ShelfItem new_item = *item;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 LauncherItemController* controller = GetLauncherItemController(id); 542 LauncherItemController* controller = GetLauncherItemController(id);
545 DCHECK(controller); 543 DCHECK(controller);
546 AppShortcutLauncherItemController* app_controller = 544 AppShortcutLauncherItemController* app_controller =
547 static_cast<AppShortcutLauncherItemController*>(controller); 545 static_cast<AppShortcutLauncherItemController*>(controller);
548 app_controller->set_refocus_url(url); 546 app_controller->set_refocus_url(url);
549 } else { 547 } else {
550 NOTREACHED() << "Invalid launcher item or type"; 548 NOTREACHED() << "Invalid launcher item or type";
551 } 549 }
552 } 550 }
553 551
554 ash::ShelfItemDelegate::PerformedAction 552 ash::ShelfAction ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive(
555 ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive(
556 ui::BaseWindow* window, 553 ui::BaseWindow* window,
557 bool allow_minimize) { 554 bool allow_minimize) {
558 // In separated desktop mode we might have to teleport a window back to the 555 // In separated desktop mode we might have to teleport a window back to the
559 // current user. 556 // current user.
560 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == 557 if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
561 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { 558 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) {
562 aura::Window* native_window = window->GetNativeWindow(); 559 aura::Window* native_window = window->GetNativeWindow();
563 const AccountId& current_account_id = 560 const AccountId& current_account_id =
564 multi_user_util::GetAccountIdFromProfile(profile()); 561 multi_user_util::GetAccountIdFromProfile(profile());
565 chrome::MultiUserWindowManager* manager = 562 chrome::MultiUserWindowManager* manager =
566 chrome::MultiUserWindowManager::GetInstance(); 563 chrome::MultiUserWindowManager::GetInstance();
567 if (!manager->IsWindowOnDesktopOfUser(native_window, current_account_id)) { 564 if (!manager->IsWindowOnDesktopOfUser(native_window, current_account_id)) {
568 ash::MultiProfileUMA::RecordTeleportAction( 565 ash::MultiProfileUMA::RecordTeleportAction(
569 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER); 566 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER);
570 manager->ShowWindowForUser(native_window, current_account_id); 567 manager->ShowWindowForUser(native_window, current_account_id);
571 window->Activate(); 568 window->Activate();
572 return ash::ShelfItemDelegate::kExistingWindowActivated; 569 return ash::SHELF_ACTION_WINDOW_ACTIVATED;
573 } 570 }
574 } 571 }
575 572
576 if (window->IsActive() && allow_minimize) { 573 if (window->IsActive() && allow_minimize) {
577 window->Minimize(); 574 window->Minimize();
578 return ash::ShelfItemDelegate::kNoAction; 575 return ash::SHELF_ACTION_NONE;
579 } 576 }
580 577
581 window->Show(); 578 window->Show();
582 window->Activate(); 579 window->Activate();
583 return ash::ShelfItemDelegate::kExistingWindowActivated; 580 return ash::SHELF_ACTION_WINDOW_ACTIVATED;
584 } 581 }
585 582
586 void ChromeLauncherControllerImpl::ActiveUserChanged( 583 void ChromeLauncherControllerImpl::ActiveUserChanged(
587 const std::string& user_email) { 584 const std::string& user_email) {
588 // Store the order of running applications for the user which gets inactive. 585 // Store the order of running applications for the user which gets inactive.
589 RememberUnpinnedRunningApplicationOrder(); 586 RememberUnpinnedRunningApplicationOrder();
590 // Coming here the default profile is already switched. All profile specific 587 // Coming here the default profile is already switched. All profile specific
591 // resources get released and the new profile gets attached instead. 588 // resources get released and the new profile gets attached instead.
592 ReleaseProfile(); 589 ReleaseProfile();
593 // When coming here, the active user has already be changed so that we can 590 // When coming here, the active user has already be changed so that we can
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 LauncherItemController* controller = GetLauncherItemController(item.id); 1492 LauncherItemController* controller = GetLauncherItemController(item.id);
1496 if (!controller || controller->image_set_by_controller()) 1493 if (!controller || controller->image_set_by_controller())
1497 continue; 1494 continue;
1498 item.image = image; 1495 item.image = image;
1499 if (arc_deferred_launcher_) 1496 if (arc_deferred_launcher_)
1500 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1497 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1501 model_->Set(index, item); 1498 model_->Set(index, item);
1502 // It's possible we're waiting on more than one item, so don't break. 1499 // It's possible we're waiting on more than one item, so don't break.
1503 } 1500 }
1504 } 1501 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698