OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "chrome/browser/extensions/extension_window_controller.h" | 13 #include "chrome/browser/extensions/extension_window_controller.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
| 16 class UIThreadExtensionFunction; |
16 | 17 |
17 // Class to maintain a list of ExtensionWindowControllers. | 18 // Class to maintain a list of ExtensionWindowControllers. |
18 class ExtensionWindowList { | 19 class ExtensionWindowList { |
19 public: | 20 public: |
20 typedef std::list<ExtensionWindowController*> WindowList; | 21 typedef std::list<ExtensionWindowController*> WindowList; |
21 typedef ExtensionWindowController::ProfileMatchType ProfileMatchType; | |
22 | 22 |
23 ExtensionWindowList(); | 23 ExtensionWindowList(); |
24 ~ExtensionWindowList(); | 24 ~ExtensionWindowList(); |
25 | 25 |
26 void AddExtensionWindow(ExtensionWindowController* window); | 26 void AddExtensionWindow(ExtensionWindowController* window); |
27 void RemoveExtensionWindow(ExtensionWindowController* window); | 27 void RemoveExtensionWindow(ExtensionWindowController* window); |
28 | 28 |
29 // Returns a window matching the profile and id, or NULL. | 29 // Returns a window matching the context the function was invoked in. |
30 ExtensionWindowController* FindWindowById(Profile* profile, | 30 ExtensionWindowController* FindWindowById( |
31 ProfileMatchType match_type, | 31 const UIThreadExtensionFunction* function, |
32 int id) const; | 32 int id) const; |
33 | 33 |
34 // Returns the focused or last added window matching the profile, or NULL. | 34 // Returns the focused or last added window matching the context the function |
35 ExtensionWindowController* CurrentWindow(Profile* profile, | 35 // was invoked in. |
36 ProfileMatchType match_type) const; | 36 ExtensionWindowController* CurrentWindow( |
| 37 const UIThreadExtensionFunction* function) const; |
37 | 38 |
38 const WindowList& windows() const { return windows_; } | 39 const WindowList& windows() const { return windows_; } |
39 | 40 |
40 static ExtensionWindowList* GetInstance(); | 41 static ExtensionWindowList* GetInstance(); |
41 | 42 |
42 private: | 43 private: |
43 friend struct DefaultSingletonTraits<ExtensionWindowList>; | 44 friend struct DefaultSingletonTraits<ExtensionWindowList>; |
44 | 45 |
45 // Entries are not owned by this class and must be removed when destroyed. | 46 // Entries are not owned by this class and must be removed when destroyed. |
46 WindowList windows_; | 47 WindowList windows_; |
47 | 48 |
48 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowList); | 49 DISALLOW_COPY_AND_ASSIGN(ExtensionWindowList); |
49 }; | 50 }; |
50 | 51 |
51 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ | 52 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WINDOW_LIST_H_ |
OLD | NEW |