Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / app_window_launcher_item_controller.h
blob5edbe79eef91cef6da15f31805eef3afc44cd80a
1 // Copyright 2014 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_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_
8 #include <list>
9 #include <string>
11 #include "base/memory/scoped_ptr.h"
12 #include "base/scoped_observer.h"
13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
14 #include "ui/aura/window_observer.h"
16 namespace aura {
17 class Window;
20 namespace extensions {
21 class AppWindow;
24 namespace gfx {
25 class Image;
28 class ChromeLauncherController;
30 // This is a LauncherItemController for app windows. There is one instance per
31 // app, per launcher id. For apps with multiple windows, each item controller
32 // keeps track of all windows associated with the app and their activation
33 // order. Instances are owned by ash::ShelfItemDelegateManager.
35 // Tests are in chrome_launcher_controller_browsertest.cc
36 class AppWindowLauncherItemController : public LauncherItemController,
37 public aura::WindowObserver {
38 public:
39 AppWindowLauncherItemController(Type type,
40 const std::string& app_shelf_id,
41 const std::string& app_id,
42 ChromeLauncherController* controller);
44 ~AppWindowLauncherItemController() override;
46 void AddAppWindow(extensions::AppWindow* app_window,
47 ash::ShelfItemStatus status);
49 void RemoveAppWindowForWindow(aura::Window* window);
51 void SetActiveWindow(aura::Window* window);
53 const std::string& app_shelf_id() const { return app_shelf_id_; }
55 // LauncherItemController overrides:
56 bool IsOpen() const override;
57 bool IsVisible() const override;
58 void Launch(ash::LaunchSource source, int event_flags) override;
59 ash::ShelfItemDelegate::PerformedAction Activate(
60 ash::LaunchSource source) override;
61 ChromeLauncherAppMenuItems GetApplicationList(int event_flags) override;
62 ash::ShelfItemDelegate::PerformedAction ItemSelected(
63 const ui::Event& eent) override;
64 base::string16 GetTitle() override;
65 ui::MenuModel* CreateContextMenu(aura::Window* root_window) override;
66 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override;
67 bool IsDraggable() override;
68 bool ShouldShowTooltip() override;
69 void Close() override;
71 // aura::WindowObserver overrides:
72 void OnWindowPropertyChanged(aura::Window* window,
73 const void* key,
74 intptr_t old) override;
76 // Get the number of running applications/incarnations of this.
77 size_t app_window_count() const { return app_windows_.size(); }
79 // Activates the window at position |index|.
80 void ActivateIndexedApp(size_t index);
82 private:
83 typedef std::list<extensions::AppWindow*> AppWindowList;
85 // Returns the action performed. Should be one of kNoAction,
86 // kExistingWindowActivated, or kExistingWindowMinimized.
87 ash::ShelfItemDelegate::PerformedAction ShowAndActivateOrMinimize(
88 extensions::AppWindow* app_window);
90 // Activate the given |window_to_show|, or - if already selected - advance to
91 // the next window of similar type.
92 // Returns the action performed. Should be one of kNoAction,
93 // kExistingWindowActivated, or kExistingWindowMinimized.
94 ash::ShelfItemDelegate::PerformedAction ActivateOrAdvanceToNextAppWindow(
95 extensions::AppWindow* window_to_show);
97 // List of associated app windows
98 AppWindowList app_windows_;
100 // Pointer to the most recently active app window
101 extensions::AppWindow* last_active_app_window_;
103 // The launcher id associated with this set of windows. There is one
104 // AppLauncherItemController for each |app_shelf_id_|.
105 const std::string app_shelf_id_;
107 // Scoped list of observed windows (for removal on destruction)
108 ScopedObserver<aura::Window, aura::WindowObserver> observed_windows_;
110 DISALLOW_COPY_AND_ASSIGN(AppWindowLauncherItemController);
113 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_WINDOW_LAUNCHER_ITEM_CONTROLLER_H_