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

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

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for unittest.. Created 7 years, 2 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 97f62bd4e6a7fe7f8a1bc3d9a5c0222aaf61f4b5..a05ff2e0a7093af1cccdb286dd45dfdddf00096c 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
@@ -5,6 +5,8 @@
#include "chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h"
#include "apps/native_app_window.h"
+#include "ash/launcher/launcher_model.h"
+#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -12,6 +14,8 @@
#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/launcher_application_menu_item_model.h"
+#include "chrome/browser/ui/ash/launcher/launcher_context_menu.h"
#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
@@ -25,6 +29,10 @@
#include "ui/events/event.h"
#include "ui/views/corewm/window_animations.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
+#endif
+
using extensions::Extension;
namespace {
@@ -56,10 +64,6 @@ AppShortcutLauncherItemController::AppShortcutLauncherItemController(
AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {
}
-string16 AppShortcutLauncherItemController::GetTitle() {
- return GetAppTitle();
-}
-
bool AppShortcutLauncherItemController::IsCurrentlyShownInWindow(
aura::Window* window) const {
Browser* browser = chrome::FindBrowserWithWindow(window);
@@ -131,21 +135,6 @@ void AppShortcutLauncherItemController::Close() {
}
}
-void AppShortcutLauncherItemController::Clicked(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;
- }
- Activate(ash::LAUNCH_FROM_UNKNOWN);
-}
-
-void AppShortcutLauncherItemController::OnRemoved() {
- // AppShortcutLauncherItemController is unowned; delete on removal.
- delete this;
-}
-
ChromeLauncherAppMenuItems
AppShortcutLauncherItemController::GetApplicationList(int event_flags) {
ChromeLauncherAppMenuItems items;
@@ -199,6 +188,44 @@ AppShortcutLauncherItemController::GetRunningApplications() {
return items;
}
+void AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) {
+#if defined(OS_CHROMEOS)
+ if (!app_id().empty())
+ chromeos::default_pinned_apps_field_trial::RecordShelfAppClick(app_id());
+#endif
+ // 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;
+ }
+ Activate(ash::LAUNCH_FROM_UNKNOWN);
+}
+
+base::string16 AppShortcutLauncherItemController::GetTitle() {
+ return GetAppTitle();
+}
+
+ui::MenuModel* AppShortcutLauncherItemController::CreateContextMenu(
+ aura::RootWindow* root_window) {
+ ash::LauncherItem item =
+ *(launcher_controller()->model()->ItemByID(launcher_id()));
+ return new LauncherContextMenu(launcher_controller(), &item, root_window);
+}
+
+ash::LauncherMenuModel*
+AppShortcutLauncherItemController::CreateApplicationMenu(int event_flags) {
+ return new LauncherApplicationMenuItemModel(GetApplicationList(event_flags));
+}
+
+bool AppShortcutLauncherItemController::IsDraggable() {
+ return true;
+}
+
+bool AppShortcutLauncherItemController::ShouldShowTooltip() {
+ return true;
+}
+
content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
URLPattern refocus_pattern(URLPattern::SCHEME_ALL);
refocus_pattern.SetMatchAllURLs(true);

Powered by Google App Engine
This is Rietveld 408576698