OLD | NEW |
| (Empty) |
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_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/memory/singleton.h" | |
12 #include "chrome/browser/extensions/extension_window_controller.h" | |
13 | |
14 class Profile; | |
15 class UIThreadExtensionFunction; | |
16 | |
17 // Class to maintain a list of ExtensionWindowControllers. | |
18 class ExtensionWindowList { | |
19 public: | |
20 typedef std::list<ExtensionWindowController*> WindowList; | |
21 | |
22 ExtensionWindowList(); | |
23 ~ExtensionWindowList(); | |
24 | |
25 void AddExtensionWindow(ExtensionWindowController* window); | |
26 void RemoveExtensionWindow(ExtensionWindowController* window); | |
27 | |
28 // Returns a window matching the context the function was invoked in. | |
29 ExtensionWindowController* FindWindowForFunctionById( | |
30 const UIThreadExtensionFunction* function, | |
31 int id) const; | |
32 | |
33 // Returns the focused or last added window matching the context the function | |
34 // was invoked in. | |
35 ExtensionWindowController* CurrentWindowForFunction( | |
36 const UIThreadExtensionFunction* function) const; | |
37 | |
38 const WindowList& windows() const { return windows_; } | |
39 | |
40 static ExtensionWindowList* GetInstance(); | |
41 | |
42 private: | |
43 friend struct DefaultSingletonTraits<ExtensionWindowList>; | |
44 | |
45 // Entries are not owned by this class and must be removed when destroyed. | |
46 WindowList windows_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowList); | |
49 }; | |
50 | |
51 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ | |
OLD | NEW |