| Index: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
|
| diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
|
| index c2058b0779f87f67b76b8a0e7b34d01af87a5fab..1441b8f9af1d3e0b3339e8eca0bc138c5b52b873 100644
|
| --- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
|
| +++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
|
| @@ -16,7 +16,6 @@
|
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
|
| #include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
|
| #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
|
| -#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
|
| #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
|
| #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
|
| #include "chrome/browser/ui/browser.h"
|
| @@ -48,8 +47,8 @@ const int kClickSuppressionInMS = 1000;
|
| // exists yet on another users desktop, but they expect to get only their own
|
| // app items and not the ones from other users through activation.
|
| // TODO(skuhne): Remove this function and replace the call with
|
| -// launcher_controller()->IsBrowserFromActiveUser(browser) once this experiment
|
| -// goes away.
|
| +// ChromeLauncherController::IsBrowserFromActiveUser(browser) once this
|
| +// experiment goes away.
|
| bool CanBrowserBeUsedForDirectActivation(Browser* browser,
|
| ChromeLauncherController* launcher) {
|
| if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
|
| @@ -61,28 +60,27 @@ bool CanBrowserBeUsedForDirectActivation(Browser* browser,
|
| } // namespace
|
|
|
| // static
|
| -AppShortcutLauncherItemController* AppShortcutLauncherItemController::Create(
|
| - const ash::AppLaunchId& app_launch_id,
|
| - ChromeLauncherController* controller) {
|
| +std::unique_ptr<AppShortcutLauncherItemController>
|
| +AppShortcutLauncherItemController::Create(
|
| + const ash::AppLaunchId& app_launch_id) {
|
| if (app_launch_id.app_id() == ArcSupportHost::kHostAppId ||
|
| app_launch_id.app_id() == arc::kPlayStoreAppId) {
|
| - return new ArcPlaystoreShortcutLauncherItemController(controller);
|
| + return base::MakeUnique<ArcPlaystoreShortcutLauncherItemController>();
|
| }
|
| - return new AppShortcutLauncherItemController(app_launch_id, controller);
|
| + return base::WrapUnique<AppShortcutLauncherItemController>(
|
| + new AppShortcutLauncherItemController(app_launch_id));
|
| }
|
|
|
| // Item controller for an app shortcut. Shortcuts track app and launcher ids,
|
| // but do not have any associated windows (opening a shortcut will replace the
|
| -// item with the appropriate LauncherItemController type).
|
| +// item with the appropriate ash::ShelfItemDelegate type).
|
| AppShortcutLauncherItemController::AppShortcutLauncherItemController(
|
| - const ash::AppLaunchId& app_launch_id,
|
| - ChromeLauncherController* controller)
|
| - : LauncherItemController(app_launch_id, controller),
|
| - chrome_launcher_controller_(controller) {
|
| + const ash::AppLaunchId& app_launch_id)
|
| + : ash::ShelfItemDelegate(app_launch_id) {
|
| // To detect V1 applications we use their domain and match them against the
|
| // used URL. This will also work with applications like Google Drive.
|
| - const Extension* extension =
|
| - GetExtensionForAppID(app_launch_id.app_id(), controller->profile());
|
| + const Extension* extension = GetExtensionForAppID(
|
| + app_launch_id.app_id(), ChromeLauncherController::instance()->profile());
|
| // Some unit tests have no real extension.
|
| if (extension) {
|
| set_refocus_url(GURL(
|
| @@ -119,8 +117,8 @@ void AppShortcutLauncherItemController::ItemSelected(
|
|
|
| // Launching some items replaces this item controller instance, which
|
| // destroys its AppLaunchId string pair; making copies avoid crashes.
|
| - launcher_controller()->LaunchApp(ash::AppLaunchId(app_launch_id()), source,
|
| - ui::EF_NONE);
|
| + ChromeLauncherController::instance()->LaunchApp(
|
| + ash::AppLaunchId(app_launch_id()), source, ui::EF_NONE);
|
| callback.Run(ash::SHELF_ACTION_NEW_WINDOW_CREATED, base::nullopt);
|
| return;
|
| }
|
| @@ -129,16 +127,17 @@ void AppShortcutLauncherItemController::ItemSelected(
|
| callback.Run(action, GetAppMenuItems(event ? event->flags() : ui::EF_NONE));
|
| }
|
|
|
| -MenuItemList AppShortcutLauncherItemController::GetAppMenuItems(
|
| +ash::MenuItemList AppShortcutLauncherItemController::GetAppMenuItems(
|
| int event_flags) {
|
| - MenuItemList items;
|
| + ash::MenuItemList items;
|
| app_menu_items_ = GetRunningApplications();
|
| + ChromeLauncherController* controller = ChromeLauncherController::instance();
|
| for (size_t i = 0; i < app_menu_items_.size(); i++) {
|
| content::WebContents* tab = app_menu_items_[i];
|
| ash::mojom::MenuItemPtr item(ash::mojom::MenuItem::New());
|
| item->command_id = base::checked_cast<uint32_t>(i);
|
| - item->label = launcher_controller()->GetAppListTitle(tab);
|
| - item->image = *launcher_controller()->GetAppListIcon(tab).ToSkBitmap();
|
| + item->label = controller->GetAppListTitle(tab);
|
| + item->image = *controller->GetAppListIcon(tab).ToSkBitmap();
|
| items.push_back(std::move(item));
|
| }
|
| return items;
|
| @@ -176,7 +175,8 @@ void AppShortcutLauncherItemController::ExecuteCommand(uint32_t command_id,
|
| void AppShortcutLauncherItemController::Close() {
|
| // Close all running 'programs' of this type.
|
| std::vector<content::WebContents*> content =
|
| - launcher_controller()->GetV1ApplicationsFromAppId(app_id());
|
| + ChromeLauncherController::instance()->GetV1ApplicationsFromAppId(
|
| + app_id());
|
| for (size_t i = 0; i < content.size(); i++) {
|
| Browser* browser = chrome::FindBrowserWithWebContents(content[i]);
|
| if (!browser || !IsBrowserFromActiveUser(browser))
|
| @@ -200,8 +200,8 @@ AppShortcutLauncherItemController::GetRunningApplications() {
|
| refocus_pattern.Parse(refocus_url_.spec());
|
| }
|
|
|
| - const Extension* extension =
|
| - GetExtensionForAppID(app_id(), launcher_controller()->profile());
|
| + const Extension* extension = GetExtensionForAppID(
|
| + app_id(), ChromeLauncherController::instance()->profile());
|
|
|
| // It is possible to come here While an extension gets loaded.
|
| if (!extension)
|
| @@ -230,8 +230,9 @@ content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
|
| refocus_pattern.Parse(refocus_url_.spec());
|
| }
|
|
|
| + ChromeLauncherController* controller = ChromeLauncherController::instance();
|
| const Extension* extension =
|
| - GetExtensionForAppID(app_id(), launcher_controller()->profile());
|
| + GetExtensionForAppID(app_id(), controller->profile());
|
|
|
| // We may get here while the extension is loading (and NULL).
|
| if (!extension)
|
| @@ -242,7 +243,7 @@ content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
|
| browser_list->begin_last_active();
|
| it != browser_list->end_last_active(); ++it) {
|
| Browser* browser = *it;
|
| - if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller()))
|
| + if (!CanBrowserBeUsedForDirectActivation(browser, controller))
|
| continue;
|
| TabStripModel* tab_strip = browser->tab_strip_model();
|
| // We start to enumerate from the active index.
|
| @@ -261,7 +262,8 @@ content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
|
| for (BrowserList::const_iterator it = browser_list->begin();
|
| it != browser_list->end(); ++it) {
|
| Browser* browser = *it;
|
| - if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller()))
|
| + if (!CanBrowserBeUsedForDirectActivation(
|
| + browser, ChromeLauncherController::instance()))
|
| continue;
|
| TabStripModel* tab_strip = browser->tab_strip_model();
|
| for (int index = 0; index < tab_strip->count(); index++) {
|
| @@ -300,12 +302,13 @@ bool AppShortcutLauncherItemController::WebContentMatchesApp(
|
| // - The extension's origin + extent gets matched.
|
| // - The launcher controller knows that the tab got created for this app.
|
| const GURL tab_url = web_contents->GetURL();
|
| - return ((!refocus_pattern.match_all_urls() &&
|
| - refocus_pattern.MatchesURL(tab_url)) ||
|
| - (extension->OverlapsWithOrigin(tab_url) &&
|
| - extension->web_extent().MatchesURL(tab_url)) ||
|
| - launcher_controller()->IsWebContentHandledByApplication(web_contents,
|
| - app_id()));
|
| + return (
|
| + (!refocus_pattern.match_all_urls() &&
|
| + refocus_pattern.MatchesURL(tab_url)) ||
|
| + (extension->OverlapsWithOrigin(tab_url) &&
|
| + extension->web_extent().MatchesURL(tab_url)) ||
|
| + ChromeLauncherController::instance()->IsWebContentHandledByApplication(
|
| + web_contents, app_id()));
|
| }
|
|
|
| ash::ShelfAction AppShortcutLauncherItemController::ActivateContent(
|
| @@ -318,7 +321,7 @@ ash::ShelfAction AppShortcutLauncherItemController::ActivateContent(
|
| int old_index = tab_strip->active_index();
|
| if (index != old_index)
|
| tab_strip->ActivateTabAt(index, false);
|
| - return launcher_controller()->ActivateWindowOrMinimizeIfActive(
|
| + return ChromeLauncherController::instance()->ActivateWindowOrMinimizeIfActive(
|
| browser->window(),
|
| index == old_index && GetRunningApplications().size() == 1);
|
| }
|
| @@ -352,8 +355,8 @@ bool AppShortcutLauncherItemController::AdvanceToNextApp() {
|
| }
|
|
|
| bool AppShortcutLauncherItemController::IsV2App() {
|
| - const Extension* extension =
|
| - GetExtensionForAppID(app_id(), launcher_controller()->profile());
|
| + const Extension* extension = GetExtensionForAppID(
|
| + app_id(), ChromeLauncherController::instance()->profile());
|
| return extension && extension->is_platform_app();
|
| }
|
|
|
|
|