| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_LAUNCHER_LAUNCHER_DELEGATE_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_ |
| 6 #define ASH_LAUNCHER_LAUNCHER_DELEGATE_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "ui/base/models/simple_menu_model.h" | 11 #include "ui/base/models/simple_menu_model.h" |
| 12 | 12 |
| 13 namespace aura { | 13 namespace aura { |
| 14 class RootWindow; | 14 class RootWindow; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 class Event; | 18 class Event; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 class Launcher; | |
| 23 | 22 |
| 24 // A special menu model which keeps track of an "active" menu item. | 23 // A special menu model which keeps track of an "active" menu item. |
| 25 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel { | 24 class ASH_EXPORT LauncherMenuModel : public ui::SimpleMenuModel { |
| 26 public: | 25 public: |
| 27 explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate) | 26 explicit LauncherMenuModel(ui::SimpleMenuModel::Delegate* delegate) |
| 28 : ui::SimpleMenuModel(delegate) {} | 27 : ui::SimpleMenuModel(delegate) {} |
| 29 | 28 |
| 30 // Returns |true| when the given |command_id| is active and needs to be drawn | 29 // Returns |true| when the given |command_id| is active and needs to be drawn |
| 31 // in a special state. | 30 // in a special state. |
| 32 virtual bool IsCommandActive(int command_id) const = 0; | 31 virtual bool IsCommandActive(int command_id) const = 0; |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel); | 34 DISALLOW_COPY_AND_ASSIGN(LauncherMenuModel); |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 // Delegate for the Launcher. | 37 // Delegate for the LauncherItem. |
| 39 class ASH_EXPORT LauncherDelegate { | 38 // TODO(simon.hong81): Remove LauncherItem from abstract function parameters. |
| 39 class ASH_EXPORT LauncherItemDelegate { |
| 40 public: | 40 public: |
| 41 // Launcher owns the delegate. | 41 virtual ~LauncherItemDelegate() {} |
| 42 virtual ~LauncherDelegate() {} | |
| 43 | 42 |
| 44 // Invoked when the user clicks on a window entry in the launcher. | 43 // Invoked when the user clicks on a window entry in the launcher. |
| 45 // |event| is the click event. The |event| is dispatched by a view | 44 // |event| is the click event. The |event| is dispatched by a view |
| 46 // and has an instance of |views::View| as the event target | 45 // and has an instance of |views::View| as the event target |
| 47 // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed | 46 // but not |aura::Window|. If the |event| is of type KeyEvent, it is assumed |
| 48 // that this was triggered by keyboard action (Alt+<number>) and special | 47 // that this was triggered by keyboard action (Alt+<number>) and special |
| 49 // handling might happen. | 48 // handling might happen. |
| 50 virtual void ItemSelected(const LauncherItem& item, | 49 virtual void ItemSelected(const LauncherItem& item, |
| 51 const ui::Event& event) = 0; | 50 const ui::Event& event) = 0; |
| 52 | 51 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 65 // - A return of a menu with one item means that only the name of the | 64 // - A return of a menu with one item means that only the name of the |
| 66 // application/item was added and there are no active applications. | 65 // application/item was added and there are no active applications. |
| 67 // Note: This is useful for hover menus which also show context help. | 66 // Note: This is useful for hover menus which also show context help. |
| 68 // - A list containing the title and the active list of items. | 67 // - A list containing the title and the active list of items. |
| 69 // The caller takes ownership of the returned model. | 68 // The caller takes ownership of the returned model. |
| 70 // |event_flags| specifies the flags of the event which triggered this menu. | 69 // |event_flags| specifies the flags of the event which triggered this menu. |
| 71 virtual LauncherMenuModel* CreateApplicationMenu( | 70 virtual LauncherMenuModel* CreateApplicationMenu( |
| 72 const LauncherItem& item, | 71 const LauncherItem& item, |
| 73 int event_flags) = 0; | 72 int event_flags) = 0; |
| 74 | 73 |
| 75 // Returns the id of the item associated with the specified window, or 0 if | |
| 76 // there isn't one. | |
| 77 // Note: Windows of tabbed browsers will return the |LauncherID| of the | |
| 78 // currently active tab or selected tab. | |
| 79 virtual LauncherID GetIDByWindow(aura::Window* window) = 0; | |
| 80 | |
| 81 // Whether the given launcher item is draggable. | 74 // Whether the given launcher item is draggable. |
| 82 virtual bool IsDraggable(const LauncherItem& item) = 0; | 75 virtual bool IsDraggable(const LauncherItem& item) = 0; |
| 83 | 76 |
| 84 // Returns true if a tooltip should be shown for the item. | 77 // Returns true if a tooltip should be shown for the item. |
| 85 virtual bool ShouldShowTooltip(const LauncherItem& item) = 0; | 78 virtual bool ShouldShowTooltip(const LauncherItem& item) = 0; |
| 86 | |
| 87 // Callback used to allow delegate to perform initialization actions that | |
| 88 // depend on the Launcher being in a known state. | |
| 89 virtual void OnLauncherCreated(Launcher* launcher) = 0; | |
| 90 | |
| 91 // Callback used to inform the delegate that a specific launcher no longer | |
| 92 // exists. | |
| 93 virtual void OnLauncherDestroyed(Launcher* launcher) = 0; | |
| 94 | |
| 95 // Get the launcher ID from an application ID. | |
| 96 virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) = 0; | |
| 97 | |
| 98 // Get the application ID for a given launcher ID. | |
| 99 virtual const std::string& GetAppIDForLauncherID(LauncherID id) = 0; | |
| 100 | |
| 101 // Pins an app with |app_id| to launcher. A running instance will get pinned. | |
| 102 // In case there is no running instance a new launcher item is created and | |
| 103 // pinned. | |
| 104 virtual void PinAppWithID(const std::string& app_id) = 0; | |
| 105 | |
| 106 // Check if the app with |app_id_| is pinned to the launcher. | |
| 107 virtual bool IsAppPinned(const std::string& app_id) = 0; | |
| 108 | |
| 109 // Unpins app item with |app_id|. | |
| 110 virtual void UnpinAppWithID(const std::string& app_id) = 0; | |
| 111 }; | 79 }; |
| 112 | 80 |
| 113 } // namespace ash | 81 } // namespace ash |
| 114 | 82 |
| 115 #endif // ASH_LAUNCHER_LAUNCHER_DELEGATE_H_ | 83 #endif // ASH_LAUNCHER_LAUNCHER_ITEM_DELEGATE_H_ |
| OLD | NEW |