summaryrefslogtreecommitdiffstats
path: root/ash/launcher/launcher_item_delegate.h
blob: c83de47b814e9b17aa3735afcafc726e0a30e3d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_
#define ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_

#include "ash/ash_export.h"
#include "ash/launcher/launcher_types.h"
#include "base/strings/string16.h"
#include "ui/base/models/simple_menu_model.h"

namespace aura {
class RootWindow;
}

namespace ui {
class Event;
}

namespace ash {

// A special menu model which keeps track of an "active" menu item.
class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel {
 public:
  explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate)
      : ui::SimpleMenuModel(delegate) {}

  // Returns |true| when the given |command_id| is active and needs to be drawn
  // in a special state.
  virtual bool IsCommandActive(int command_id) const = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel);
};

// Delegate for the LauncherItem.
class ASH_EXPORT LauncherItemDelegate {
 public:
  virtual ~LauncherItemDelegate() {}

  // Invoked when the user clicks on a window entry in the launcher.
  // |event| is the click event. The |event| is dispatched by a view
  // and has an instance of |views::View| as the event target
  // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed
  // that this was triggered by keyboard action (Alt+<number>) and special
  // handling might happen.
  // Returns true if a new item was created.
  virtual bool ItemSelected(const ui::Event& event) = 0;

  // Returns the title to display.
  virtual base::string16 GetTitle() = 0;

  // Returns the context menumodel for the specified item on
  // |root_window|.  Return NULL if there should be no context
  // menu. The caller takes ownership of the returned model.
  virtual ui::MenuModel* CreateContextMenu(aura::Window* root_window) = 0;

  // Returns the application menu model for the specified item. There are three
  // possible return values:
  //  - A return of NULL indicates that no menu is wanted for this item.
  //  - A return of a menu with one item means that only the name of the
  //    application/item was added and there are no active applications.
  //    Note: This is useful for hover menus which also show context help.
  //  - A list containing the title and the active list of items.
  // The caller takes ownership of the returned model.
  // |event_flags| specifies the flags of the event which triggered this menu.
  virtual ash::LauncherMenuModel* CreateApplicationMenu(int event_flags) = 0;

  // Whether the launcher item is draggable.
  virtual bool IsDraggable() = 0;

  // Returns true if a tooltip should be shown.
  virtual bool ShouldShowTooltip() = 0;
};

}  // namespace ash

#endif  // ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_