Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / extensions / window_controller_list.h
blob2eaf233d5ecd5b35fea7f806236b956b5662d797
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_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_
6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_
8 #include <list>
10 #include "base/compiler_specific.h"
11 #include "base/memory/singleton.h"
12 #include "base/observer_list.h"
13 #include "chrome/browser/extensions/window_controller.h"
15 class Profile;
16 class UIThreadExtensionFunction;
18 namespace extensions {
20 class WindowControllerListObserver;
22 // Class to maintain a list of WindowControllers.
23 class WindowControllerList {
24 public:
25 typedef std::list<WindowController*> ControllerList;
27 WindowControllerList();
28 ~WindowControllerList();
30 void AddExtensionWindow(WindowController* window);
31 void RemoveExtensionWindow(WindowController* window);
33 void AddObserver(WindowControllerListObserver* observer);
34 void RemoveObserver(WindowControllerListObserver* observer);
36 // Returns a window matching |id|.
37 WindowController* FindWindowById(int id) const;
39 // Returns a window matching |id| using |filter|.
40 WindowController* FindWindowByIdWithFilter(
41 int id,
42 WindowController::TypeFilter filter) const;
44 // Returns a window matching the context the function was invoked in
45 // using |filter|.
46 WindowController* FindWindowForFunctionByIdWithFilter(
47 const UIThreadExtensionFunction* function,
48 int id,
49 WindowController::TypeFilter filter) const;
51 // Returns the focused or last added window matching the context the function
52 // was invoked in.
53 WindowController* CurrentWindowForFunction(
54 const UIThreadExtensionFunction* function) const;
56 // Returns the focused or last added window matching the context the function
57 // was invoked in using |filter|.
58 WindowController* CurrentWindowForFunctionWithFilter(
59 const UIThreadExtensionFunction* function,
60 WindowController::TypeFilter filter) const;
62 const ControllerList& windows() const { return windows_; }
64 static WindowControllerList* GetInstance();
66 private:
67 friend struct DefaultSingletonTraits<WindowControllerList>;
69 // Entries are not owned by this class and must be removed when destroyed.
70 ControllerList windows_;
72 base::ObserverList<WindowControllerListObserver> observers_;
74 DISALLOW_COPY_AND_ASSIGN(WindowControllerList);
77 } // namespace extensions
79 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_