Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / launcher / launcher_delegate.h
blobbcde60fda365d9b1f7b5bb72ee88f4726c943b10
1 // Copyright (c) 2012 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_DELEGATE_H_
6 #define ASH_LAUNCHER_LAUNCHER_DELEGATE_H_
8 #include "ash/ash_export.h"
9 #include "ash/launcher/launcher_types.h"
10 #include "base/string16.h"
11 #include "ui/base/models/simple_menu_model.h"
13 namespace aura {
14 class RootWindow;
17 namespace ui {
18 class Event;
21 namespace ash {
22 class Launcher;
24 // A special menu model which keeps track of an "active" menu item.
25 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel {
26 public:
27 explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate)
28 : ui::SimpleMenuModel(delegate) {}
30 // Returns |true| when the given |command_id| is active and needs to be drawn
31 // in a special state.
32 virtual bool IsCommandActive(int command_id) const = 0;
34 private:
35 DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel);
38 // Delegate for the Launcher.
39 class ASH_EXPORT LauncherDelegate {
40 public:
41 // Launcher owns the delegate.
42 virtual ~LauncherDelegate() {}
44 // Invoked when the user clicks on button in the launcher to open last used
45 // window (or create a new one if there is no last used window).
46 // |event_flags| is the flags of the click event.
47 virtual void OnBrowserShortcutClicked(int event_flags) = 0;
49 // Invoked when the user clicks on a window entry in the launcher.
50 // |event| is the click event. The |event| is dispatched by a view
51 // and has an instance of |views::View| as the event target
52 // but not |aura::Window|.
53 virtual void ItemClicked(const LauncherItem& item,
54 const ui::Event& event) = 0;
56 // Returns the resource id of the image to show on the browser shortcut
57 // button.
58 virtual int GetBrowserShortcutResourceId() = 0;
60 // Returns the title to display for the specified launcher item.
61 virtual string16 GetTitle(const LauncherItem& item) = 0;
63 // Returns the context menumodel for the specified item on
64 // |root_window|. Return NULL if there should be no context
65 // menu. The caller takes ownership of the returned model.
66 virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item,
67 aura::RootWindow* root_window) = 0;
69 // Returns the application menu model for the specified item. There are three
70 // possible return values:
71 // - A return of NULL indicates that no menu is wanted for this item.
72 // - A return of a menu with one item means that only the name of the
73 // application/item was added and there are no active applications.
74 // Note: This is useful for hover menus which also show context help.
75 // - A list containing the title and the active list of items.
76 // The caller takes ownership of the returned model.
77 // |event_flags| specifies the flags of the event which triggered this menu.
78 virtual LauncherMenuModel* CreateApplicationMenu(
79 const LauncherItem& item,
80 int event_flags) = 0;
82 // Returns the id of the item associated with the specified window, or 0 if
83 // there isn't one.
84 virtual LauncherID GetIDByWindow(aura::Window* window) = 0;
86 // Whether the given launcher item is draggable.
87 virtual bool IsDraggable(const LauncherItem& item) = 0;
89 // Returns true if a tooltip should be shown for the item.
90 virtual bool ShouldShowTooltip(const LauncherItem& item) = 0;
92 // Callback used to allow delegate to perform initialization actions that
93 // depend on the Launcher being in a known state.
94 virtual void OnLauncherCreated(Launcher* launcher) = 0;
96 // Callback used to inform the delegate that a specific launcher no longer
97 // exists.
98 virtual void OnLauncherDestroyed(Launcher* launcher) = 0;
101 } // namespace ash
103 #endif // ASH_LAUNCHER_LAUNCHER_DELEGATE_H_