• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef ASH_SHELF_SHELF_ITEM_DELEGATE_H_
6 #define ASH_SHELF_SHELF_ITEM_DELEGATE_H_
7 
8 #include "ash/ash_export.h"
9 #include "base/strings/string16.h"
10 
11 namespace aura {
12 class Window;
13 }
14 
15 namespace ui {
16 class Event;
17 class MenuModel;
18 }
19 
20 namespace ash {
21 
22 class ShelfMenuModel;
23 
24 // Delegate for the ShelfItem.
25 class ASH_EXPORT ShelfItemDelegate {
26  public:
~ShelfItemDelegate()27   virtual ~ShelfItemDelegate() {}
28 
29   // Invoked when the user clicks on a window entry in the launcher.
30   // |event| is the click event. The |event| is dispatched by a view
31   // and has an instance of |views::View| as the event target
32   // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed
33   // that this was triggered by keyboard action (Alt+<number>) and special
34   // handling might happen.
35   // Returns true if a new item was created.
36   virtual bool ItemSelected(const ui::Event& event) = 0;
37 
38   // Returns the title to display.
39   virtual base::string16 GetTitle() = 0;
40 
41   // Returns the context menumodel for the specified item on
42   // |root_window|.  Return NULL if there should be no context
43   // menu. The caller takes ownership of the returned model.
44   virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0;
45 
46   // Returns the application menu model for the specified item. There are three
47   // possible return values:
48   //  - A return of NULL indicates that no menu is wanted for this item.
49   //  - A return of a menu with one item means that only the name of the
50   //    application/item was added and there are no active applications.
51   //    Note: This is useful for hover menus which also show context help.
52   //  - A list containing the title and the active list of items.
53   // The caller takes ownership of the returned model.
54   // |event_flags| specifies the flags of the event which triggered this menu.
55   virtual ShelfMenuModel* CreateApplicationMenu(int event_flags) = 0;
56 
57   // Whether the launcher item is draggable.
58   virtual bool IsDraggable() = 0;
59 
60   // Returns true if a tooltip should be shown.
61   virtual bool ShouldShowTooltip() = 0;
62 
63   // Closes all windows associated with this item.
64   virtual void Close() = 0;
65 
66 };
67 
68 }  // namespace ash
69 
70 #endif  // ASH_SHELF_SHELF_ITEM_DELEGATE_H_
71