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

Unified Diff: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc

Issue 2671923002: mash: Cleanup ash shelf application menu code. (Closed)
Patch Set: Add comments 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 side-by-side diff with in-line comments
Download patch
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 069d9a3d9e761fb62288cdb9ca037602cf86dfb1..b42c02a24c6378aa2c6c0171c03660c300725ba7 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
@@ -6,17 +6,16 @@
#include <stddef.h>
+#include "ash/public/cpp/shelf_application_menu_item.h"
#include "ash/wm/window_util.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/ash/launcher/arc_playstore_shortcut_launcher_item_controller.h"
-#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item_tab.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
-#include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.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"
@@ -125,6 +124,29 @@ AppShortcutLauncherItemController::Activate(ash::LaunchSource source) {
return ActivateContent(content);
}
+ash::ShelfItemDelegate::PerformedAction
+AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) {
+ // In case of a keyboard event, we were called by a hotkey. In that case we
+ // activate the next item in line if an item of our list is already active.
+ if (event.type() == ui::ET_KEY_RELEASED && AdvanceToNextApp())
+ return kExistingWindowActivated;
+ return Activate(ash::LAUNCH_FROM_UNKNOWN);
+}
+
+ash::ShelfAppMenuItemList AppShortcutLauncherItemController::GetAppMenuItems(
+ int event_flags) {
+ ash::ShelfAppMenuItemList items;
+ std::vector<content::WebContents*> content_list = GetRunningApplications();
+ for (size_t i = 0; i < content_list.size(); i++) {
+ content::WebContents* web_contents = content_list[i];
+ gfx::Image app_icon = launcher_controller()->GetAppListIcon(web_contents);
+ base::string16 title = launcher_controller()->GetAppListTitle(web_contents);
+ items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemTab>(
+ title, &app_icon, web_contents));
+ }
+ return items;
+}
+
void AppShortcutLauncherItemController::Close() {
// Close all running 'programs' of this type.
std::vector<content::WebContents*> content =
@@ -140,28 +162,6 @@ void AppShortcutLauncherItemController::Close() {
}
}
-ChromeLauncherAppMenuItems
-AppShortcutLauncherItemController::GetApplicationList(int event_flags) {
- ChromeLauncherAppMenuItems items;
- // Add the application name to the menu.
- base::string16 app_title = LauncherControllerHelper::GetAppTitle(
- launcher_controller()->profile(), app_id());
- items.push_back(
- base::MakeUnique<ChromeLauncherAppMenuItem>(app_title, nullptr, false));
-
- std::vector<content::WebContents*> content_list = GetRunningApplications();
-
- for (size_t i = 0; i < content_list.size(); i++) {
- content::WebContents* web_contents = content_list[i];
- // Get the icon.
- gfx::Image app_icon = launcher_controller()->GetAppListIcon(web_contents);
- base::string16 title = launcher_controller()->GetAppListTitle(web_contents);
- items.push_back(base::MakeUnique<ChromeLauncherAppMenuItemTab>(
- title, &app_icon, web_contents, i == 0));
- }
- return items;
-}
-
std::vector<content::WebContents*>
AppShortcutLauncherItemController::GetRunningApplications() {
std::vector<content::WebContents*> items;
@@ -195,22 +195,6 @@ AppShortcutLauncherItemController::GetRunningApplications() {
return items;
}
-ash::ShelfItemDelegate::PerformedAction
-AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) {
- // In case of a keyboard event, we were called by a hotkey. In that case we
- // activate the next item in line if an item of our list is already active.
- if (event.type() == ui::ET_KEY_RELEASED) {
- if (AdvanceToNextApp())
- return kExistingWindowActivated;
- }
- return Activate(ash::LAUNCH_FROM_UNKNOWN);
-}
-
-ui::SimpleMenuModel* AppShortcutLauncherItemController::CreateApplicationMenu(
- int event_flags) {
- return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags));
-}
-
content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
URLPattern refocus_pattern(URLPattern::SCHEME_ALL);
refocus_pattern.SetMatchAllURLs(true);

Powered by Google App Engine
This is Rietveld 408576698