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
3 // found in the LICENSE file.
5 #ifndef ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_
6 #define ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_
8 #include "ash/ash_export.h"
9 #include "ash/launcher/launcher_types.h"
10 #include "base/strings/string16.h"
11 #include "ui/base/models/simple_menu_model.h"
23 // A special menu model which keeps track of an "active" menu item.
24 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel {
26 explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate)
27 : ui::SimpleMenuModel(delegate) {}
29 // Returns |true| when the given |command_id| is active and needs to be drawn
30 // in a special state.
31 virtual bool IsCommandActive(int command_id) const = 0;
34 DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel);
37 // Delegate for the LauncherItem.
38 class ASH_EXPORT LauncherItemDelegate {
40 virtual ~LauncherItemDelegate() {}
42 // Invoked when the user clicks on a window entry in the launcher.
43 // |event| is the click event. The |event| is dispatched by a view
44 // and has an instance of |views::View| as the event target
45 // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed
46 // that this was triggered by keyboard action (Alt+<number>) and special
47 // handling might happen.
48 virtual void ItemSelected(const ui::Event& event) = 0;
50 // Returns the title to display.
51 virtual base::string16 GetTitle() = 0;
53 // Returns the context menumodel for the specified item on
54 // |root_window|. Return NULL if there should be no context
55 // menu. The caller takes ownership of the returned model.
56 virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0;
58 // Returns the application menu model for the specified item. There are three
59 // possible return values:
60 // - A return of NULL indicates that no menu is wanted for this item.
61 // - A return of a menu with one item means that only the name of the
62 // application/item was added and there are no active applications.
63 // Note: This is useful for hover menus which also show context help.
64 // - A list containing the title and the active list of items.
65 // The caller takes ownership of the returned model.
66 // |event_flags| specifies the flags of the event which triggered this menu.
67 virtual ash::LauncherMenuModel* CreateApplicationMenu(int event_flags) = 0;
69 // Whether the launcher item is draggable.
70 virtual bool IsDraggable() = 0;
72 // Returns true if a tooltip should be shown.
73 virtual bool ShouldShowTooltip() = 0;
78 #endif // ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_