OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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) { |
450 int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id(); | |
James Cook
2017/02/15 00:44:40
Is it correct to assume the primary display here?
msw
2017/02/15 19:59:18
Good idea, I've replaced assumptions of primary wi
| |
451 // If there is an existing non-shortcut controller for this app, open it. | 451 // If there is an existing non-shortcut controller for this app, open it. |
452 ash::ShelfID id = GetShelfIDForAppID(app_id); | 452 ash::ShelfID id = GetShelfIDForAppID(app_id); |
453 if (id) { | 453 if (id) { |
454 LauncherItemController* controller = GetLauncherItemController(id); | 454 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
455 controller->Activate(source); | 455 delegate->ItemSelected(ui::ET_UNKNOWN, event_flags, display_id, source); |
456 return; | 456 return; |
457 } | 457 } |
458 | 458 |
459 // 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 |
460 // running instances. | 460 // running instances. |
461 std::unique_ptr<AppShortcutLauncherItemController> app_controller( | 461 std::unique_ptr<AppShortcutLauncherItemController> controller( |
462 AppShortcutLauncherItemController::Create(app_id, std::string(), this)); | 462 AppShortcutLauncherItemController::Create(app_id, std::string(), this)); |
463 if (!app_controller->GetRunningApplications().empty()) | 463 if (!controller->GetRunningApplications().empty()) |
464 app_controller->Activate(source); | 464 controller->ItemSelected(ui::ET_UNKNOWN, event_flags, display_id, source); |
465 else | 465 else |
466 LaunchApp(ash::AppLauncherId(app_id), source, event_flags); | 466 LaunchApp(ash::AppLauncherId(app_id), source, event_flags); |
467 } | 467 } |
468 | 468 |
469 void ChromeLauncherControllerImpl::SetLauncherItemImage( | 469 void ChromeLauncherControllerImpl::SetLauncherItemImage( |
470 ash::ShelfID shelf_id, | 470 ash::ShelfID shelf_id, |
471 const gfx::ImageSkia& image) { | 471 const gfx::ImageSkia& image) { |
472 const ash::ShelfItem* item = GetItem(shelf_id); | 472 const ash::ShelfItem* item = GetItem(shelf_id); |
473 if (item) { | 473 if (item) { |
474 ash::ShelfItem new_item = *item; | 474 ash::ShelfItem new_item = *item; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 LauncherItemController* controller = GetLauncherItemController(id); | 544 LauncherItemController* controller = GetLauncherItemController(id); |
545 DCHECK(controller); | 545 DCHECK(controller); |
546 AppShortcutLauncherItemController* app_controller = | 546 AppShortcutLauncherItemController* app_controller = |
547 static_cast<AppShortcutLauncherItemController*>(controller); | 547 static_cast<AppShortcutLauncherItemController*>(controller); |
548 app_controller->set_refocus_url(url); | 548 app_controller->set_refocus_url(url); |
549 } else { | 549 } else { |
550 NOTREACHED() << "Invalid launcher item or type"; | 550 NOTREACHED() << "Invalid launcher item or type"; |
551 } | 551 } |
552 } | 552 } |
553 | 553 |
554 ash::ShelfItemDelegate::PerformedAction | 554 ash::ShelfAction ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( |
555 ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( | |
556 ui::BaseWindow* window, | 555 ui::BaseWindow* window, |
557 bool allow_minimize) { | 556 bool allow_minimize) { |
558 // In separated desktop mode we might have to teleport a window back to the | 557 // In separated desktop mode we might have to teleport a window back to the |
559 // current user. | 558 // current user. |
560 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == | 559 if (chrome::MultiUserWindowManager::GetMultiProfileMode() == |
561 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { | 560 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) { |
562 aura::Window* native_window = window->GetNativeWindow(); | 561 aura::Window* native_window = window->GetNativeWindow(); |
563 const AccountId& current_account_id = | 562 const AccountId& current_account_id = |
564 multi_user_util::GetAccountIdFromProfile(profile()); | 563 multi_user_util::GetAccountIdFromProfile(profile()); |
565 chrome::MultiUserWindowManager* manager = | 564 chrome::MultiUserWindowManager* manager = |
566 chrome::MultiUserWindowManager::GetInstance(); | 565 chrome::MultiUserWindowManager::GetInstance(); |
567 if (!manager->IsWindowOnDesktopOfUser(native_window, current_account_id)) { | 566 if (!manager->IsWindowOnDesktopOfUser(native_window, current_account_id)) { |
568 ash::MultiProfileUMA::RecordTeleportAction( | 567 ash::MultiProfileUMA::RecordTeleportAction( |
569 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER); | 568 ash::MultiProfileUMA::TELEPORT_WINDOW_RETURN_BY_LAUNCHER); |
570 manager->ShowWindowForUser(native_window, current_account_id); | 569 manager->ShowWindowForUser(native_window, current_account_id); |
571 window->Activate(); | 570 window->Activate(); |
572 return ash::ShelfItemDelegate::kExistingWindowActivated; | 571 return ash::kExistingWindowActivated; |
573 } | 572 } |
574 } | 573 } |
575 | 574 |
576 if (window->IsActive() && allow_minimize) { | 575 if (window->IsActive() && allow_minimize) { |
577 window->Minimize(); | 576 window->Minimize(); |
578 return ash::ShelfItemDelegate::kNoAction; | 577 return ash::kNoAction; |
579 } | 578 } |
580 | 579 |
581 window->Show(); | 580 window->Show(); |
582 window->Activate(); | 581 window->Activate(); |
583 return ash::ShelfItemDelegate::kExistingWindowActivated; | 582 return ash::kExistingWindowActivated; |
584 } | 583 } |
585 | 584 |
586 void ChromeLauncherControllerImpl::ActiveUserChanged( | 585 void ChromeLauncherControllerImpl::ActiveUserChanged( |
587 const std::string& user_email) { | 586 const std::string& user_email) { |
588 // Store the order of running applications for the user which gets inactive. | 587 // Store the order of running applications for the user which gets inactive. |
589 RememberUnpinnedRunningApplicationOrder(); | 588 RememberUnpinnedRunningApplicationOrder(); |
590 // Coming here the default profile is already switched. All profile specific | 589 // Coming here the default profile is already switched. All profile specific |
591 // resources get released and the new profile gets attached instead. | 590 // resources get released and the new profile gets attached instead. |
592 ReleaseProfile(); | 591 ReleaseProfile(); |
593 // When coming here, the active user has already be changed so that we can | 592 // 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 Loading... | |
1495 LauncherItemController* controller = GetLauncherItemController(item.id); | 1494 LauncherItemController* controller = GetLauncherItemController(item.id); |
1496 if (!controller || controller->image_set_by_controller()) | 1495 if (!controller || controller->image_set_by_controller()) |
1497 continue; | 1496 continue; |
1498 item.image = image; | 1497 item.image = image; |
1499 if (arc_deferred_launcher_) | 1498 if (arc_deferred_launcher_) |
1500 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1499 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); |
1501 model_->Set(index, item); | 1500 model_->Set(index, item); |
1502 // It's possible we're waiting on more than one item, so don't break. | 1501 // It's possible we're waiting on more than one item, so don't break. |
1503 } | 1502 } |
1504 } | 1503 } |
OLD | NEW |