Home | History | Annotate | Download | only in launcher
      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.
      4 
      5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_CONTROLLER_H_
      6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_CONTROLLER_H_
      7 
      8 #include <list>
      9 #include <map>
     10 #include <string>
     11 
     12 #include "apps/shell_window_registry.h"
     13 #include "ui/aura/client/activation_change_observer.h"
     14 #include "ui/aura/window_observer.h"
     15 
     16 namespace apps {
     17 class ShellWindow;
     18 }
     19 
     20 namespace aura {
     21 
     22 class Window;
     23 
     24 namespace client {
     25 class ActivationClient;
     26 }
     27 
     28 }
     29 
     30 class ChromeLauncherController;
     31 class ShellWindowLauncherItemController;
     32 
     33 // ShellWindowLauncherController observes the Shell Window registry and the
     34 // aura window manager. It handles adding and removing launcher items from
     35 // ChromeLauncherController.
     36 class ShellWindowLauncherController
     37     : public apps::ShellWindowRegistry::Observer,
     38       public aura::WindowObserver,
     39       public aura::client::ActivationChangeObserver {
     40  public:
     41   explicit ShellWindowLauncherController(ChromeLauncherController* owner);
     42   virtual ~ShellWindowLauncherController();
     43 
     44   // Overridden from ShellWindowRegistry::Observer:
     45   virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) OVERRIDE;
     46   virtual void OnShellWindowIconChanged(
     47       apps::ShellWindow* shell_window) OVERRIDE;
     48   virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window) OVERRIDE;
     49 
     50   // Overriden from aura::WindowObserver:
     51   virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
     52 
     53   // Overriden from client::ActivationChangeObserver:
     54   virtual void OnWindowActivated(aura::Window* gained_active,
     55                                  aura::Window* lost_active) OVERRIDE;
     56 
     57   // Returns the number of running applications.
     58   int NumberOfAppsRunning();
     59 
     60   // Activate the application with the given index.
     61   void ActivateAppAt(int index);
     62 
     63  private:
     64   typedef std::map<std::string, ShellWindowLauncherItemController*>
     65       AppControllerMap;
     66   typedef std::map<aura::Window*, std::string> WindowToAppLauncherIdMap;
     67 
     68   ShellWindowLauncherItemController* ControllerForWindow(aura::Window* window);
     69 
     70   ChromeLauncherController* owner_;
     71   apps::ShellWindowRegistry* registry_;  // Unowned convenience pointer
     72   aura::client::ActivationClient* activation_client_;
     73 
     74   // Map of app launcher id to controller.
     75   AppControllerMap app_controller_map_;
     76 
     77   // Allows us to get from an aura::Window to the app launcher id.
     78   WindowToAppLauncherIdMap window_to_app_launcher_id_map_;
     79 
     80   DISALLOW_COPY_AND_ASSIGN(ShellWindowLauncherController);
     81 };
     82 
     83 #endif  // CHROME_BROWSER_UI_ASH_LAUNCHER_SHELL_WINDOW_LAUNCHER_CONTROLLER_H_
     84