| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/launcher/launcher_item_delegate.h" |
| 8 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
| 9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" | 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
| 14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 15 | 16 |
| 16 class ChromeLauncherController; | 17 class ChromeLauncherController; |
| 17 class ChromeLauncherAppMenuItem; | 18 class ChromeLauncherAppMenuItem; |
| 18 | 19 |
| 19 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems; | 20 typedef ScopedVector<ChromeLauncherAppMenuItem> ChromeLauncherAppMenuItems; |
| 20 | 21 |
| 21 namespace aura { | 22 namespace aura { |
| 22 class Window; | 23 class Window; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class WebContents; | 27 class WebContents; |
| 27 } | 28 } |
| 28 | 29 |
| 29 // LauncherItemController is used by ChromeLauncherController to track one | 30 // LauncherItemController is used by ChromeLauncherController to track one |
| 30 // or more windows associated with a launcher item. | 31 // or more windows associated with a launcher item. |
| 31 class LauncherItemController { | 32 class LauncherItemController : public ash::LauncherItemDelegate { |
| 32 public: | 33 public: |
| 33 enum Type { | 34 enum Type { |
| 34 TYPE_APP, | 35 TYPE_APP, |
| 35 TYPE_APP_PANEL, | 36 TYPE_APP_PANEL, |
| 36 TYPE_SHORTCUT, | 37 TYPE_SHORTCUT, |
| 37 TYPE_WINDOWED_APP | 38 TYPE_WINDOWED_APP |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 LauncherItemController(Type type, | 41 LauncherItemController(Type type, |
| 41 const std::string& app_id, | 42 const std::string& app_id, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 56 DCHECK(locked_); | 57 DCHECK(locked_); |
| 57 locked_--; | 58 locked_--; |
| 58 } | 59 } |
| 59 bool locked() { return locked_ > 0; } | 60 bool locked() { return locked_ > 0; } |
| 60 | 61 |
| 61 bool image_set_by_controller() const { return image_set_by_controller_; } | 62 bool image_set_by_controller() const { return image_set_by_controller_; } |
| 62 void set_image_set_by_controller(bool image_set_by_controller) { | 63 void set_image_set_by_controller(bool image_set_by_controller) { |
| 63 image_set_by_controller_ = image_set_by_controller; | 64 image_set_by_controller_ = image_set_by_controller; |
| 64 } | 65 } |
| 65 | 66 |
| 66 // Returns the title for this item. | |
| 67 virtual string16 GetTitle() = 0; | |
| 68 | |
| 69 // Returns true if this item controls |window|. | 67 // Returns true if this item controls |window|. |
| 70 // When this |window| has multiple applications/tabs, it only returns true | 68 // When this |window| has multiple applications/tabs, it only returns true |
| 71 // it controls the currently visible app/tab. | 69 // it controls the currently visible app/tab. |
| 72 virtual bool IsCurrentlyShownInWindow(aura::Window* window) const = 0; | 70 virtual bool IsCurrentlyShownInWindow(aura::Window* window) const = 0; |
| 73 | 71 |
| 74 // Returns true if this item is open. | 72 // Returns true if this item is open. |
| 75 virtual bool IsOpen() const = 0; | 73 virtual bool IsOpen() const = 0; |
| 76 | 74 |
| 77 // Returns true if this item is visible (e.g. not minimized). | 75 // Returns true if this item is visible (e.g. not minimized). |
| 78 virtual bool IsVisible() const = 0; | 76 virtual bool IsVisible() const = 0; |
| 79 | 77 |
| 80 // Launches a new instance of the app associated with this item. | 78 // Launches a new instance of the app associated with this item. |
| 81 virtual void Launch(ash::LaunchSource source, int event_flags) = 0; | 79 virtual void Launch(ash::LaunchSource source, int event_flags) = 0; |
| 82 | 80 |
| 83 // Shows and activates the most-recently-active window associated with the | 81 // Shows and activates the most-recently-active window associated with the |
| 84 // item, or launches the item if it is not currently open. | 82 // item, or launches the item if it is not currently open. |
| 85 virtual void Activate(ash::LaunchSource source) = 0; | 83 virtual void Activate(ash::LaunchSource source) = 0; |
| 86 | 84 |
| 87 // Closes all windows associated with this item. | 85 // Closes all windows associated with this item. |
| 88 virtual void Close() = 0; | 86 virtual void Close() = 0; |
| 89 | 87 |
| 90 // Called when the item is clicked. The behavior varies by the number of | |
| 91 // windows associated with the item: | |
| 92 // * One window: toggles the minimize state. | |
| 93 // * Multiple windows: cycles the active window. | |
| 94 // The |event| is dispatched by a view, therefore the type of the | |
| 95 // event's target is |views::View|. | |
| 96 virtual void Clicked(const ui::Event& event) = 0; | |
| 97 | |
| 98 // Called when the controlled item is removed from the launcher. | |
| 99 virtual void OnRemoved() = 0; | |
| 100 | |
| 101 // Called to retrieve the list of running applications. | 88 // Called to retrieve the list of running applications. |
| 102 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0; | 89 virtual ChromeLauncherAppMenuItems GetApplicationList(int event_flags) = 0; |
| 103 | 90 |
| 104 // Helper function to get the ash::LauncherItemType for the item type. | 91 // Helper function to get the ash::LauncherItemType for the item type. |
| 105 ash::LauncherItemType GetLauncherItemType() const; | 92 ash::LauncherItemType GetLauncherItemType() const; |
| 106 | 93 |
| 107 protected: | 94 protected: |
| 108 // Helper function to return the title associated with |app_id_|. | 95 // Helper function to return the title associated with |app_id_|. |
| 109 // Returns an empty title if no matching extension can be found. | 96 // Returns an empty title if no matching extension can be found. |
| 110 string16 GetAppTitle() const; | 97 string16 GetAppTitle() const; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 121 // applications. | 108 // applications. |
| 122 int locked_; | 109 int locked_; |
| 123 | 110 |
| 124 // Set to true if the launcher item image has been set by the controller. | 111 // Set to true if the launcher item image has been set by the controller. |
| 125 bool image_set_by_controller_; | 112 bool image_set_by_controller_; |
| 126 | 113 |
| 127 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); | 114 DISALLOW_COPY_AND_ASSIGN(LauncherItemController); |
| 128 }; | 115 }; |
| 129 | 116 |
| 130 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ | 117 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_ |
| OLD | NEW |