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 CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_
8 #include "ash/launcher/launcher_types.h"
9 #include "ash/shelf/shelf_item_delegate.h"
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h"
15 #include "ui/events/event.h"
17 class ChromeLauncherController
;
18 class ChromeLauncherAppMenuItem
;
20 typedef ScopedVector
<ChromeLauncherAppMenuItem
> ChromeLauncherAppMenuItems
;
30 // LauncherItemController is used by ChromeLauncherController to track one
31 // or more windows associated with a shelf item.
32 class LauncherItemController
: public ash::ShelfItemDelegate
{
41 LauncherItemController(Type type
,
42 const std::string
& app_id
,
43 ChromeLauncherController
* launcher_controller
);
44 virtual ~LauncherItemController();
46 Type
type() const { return type_
; }
47 ash::LauncherID
launcher_id() const { return launcher_id_
; }
48 void set_launcher_id(ash::LauncherID id
) { launcher_id_
= id
; }
49 virtual const std::string
& app_id() const;
50 ChromeLauncherController
* launcher_controller() const {
51 return launcher_controller_
;
54 // Lock this item to the launcher without being pinned (windowed v1 apps).
55 void lock() { locked_
++; }
60 bool locked() { return locked_
> 0; }
62 bool image_set_by_controller() const { return image_set_by_controller_
; }
63 void set_image_set_by_controller(bool image_set_by_controller
) {
64 image_set_by_controller_
= image_set_by_controller
;
67 // Returns true if this item is open.
68 virtual bool IsOpen() const = 0;
70 // Returns true if this item is visible (e.g. not minimized).
71 virtual bool IsVisible() const = 0;
73 // Launches a new instance of the app associated with this item.
74 virtual void Launch(ash::LaunchSource source
, int event_flags
) = 0;
76 // Shows and activates the most-recently-active window associated with the
77 // item, or launches the item if it is not currently open.
78 // Returns true when a new item got created.
79 virtual bool Activate(ash::LaunchSource source
) = 0;
81 // Called to retrieve the list of running applications.
82 virtual ChromeLauncherAppMenuItems
GetApplicationList(int event_flags
) = 0;
84 // Helper function to get the ash::LauncherItemType for the item type.
85 ash::LauncherItemType
GetLauncherItemType() const;
88 // Helper function to return the title associated with |app_id_|.
89 // Returns an empty title if no matching extension can be found.
90 base::string16
GetAppTitle() const;
94 // App id will be empty if there is no app associated with the window.
95 const std::string app_id_
;
96 ash::LauncherID launcher_id_
;
97 ChromeLauncherController
* launcher_controller_
;
99 // The lock counter which tells the launcher if the item can be removed from
100 // the launcher (0) or not (>0). It is being used for windowed V1
104 // Set to true if the launcher item image has been set by the controller.
105 bool image_set_by_controller_
;
107 DISALLOW_COPY_AND_ASSIGN(LauncherItemController
);
110 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_ITEM_CONTROLLER_H_