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_WINDOW_CONTROLLER_LIST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "chrome/browser/extensions/window_controller.h" | 13 #include "chrome/browser/extensions/window_controller.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 class ChromeUIThreadExtensionFunction; | 16 class ChromeExtensionFunctionDetails; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 class WindowControllerListObserver; | 20 class WindowControllerListObserver; |
21 | 21 |
22 // Class to maintain a list of WindowControllers. | 22 // Class to maintain a list of WindowControllers. |
23 class WindowControllerList { | 23 class WindowControllerList { |
24 public: | 24 public: |
25 typedef std::list<WindowController*> ControllerList; | 25 typedef std::list<WindowController*> ControllerList; |
26 | 26 |
27 WindowControllerList(); | 27 WindowControllerList(); |
28 ~WindowControllerList(); | 28 ~WindowControllerList(); |
29 | 29 |
30 void AddExtensionWindow(WindowController* window); | 30 void AddExtensionWindow(WindowController* window); |
31 void RemoveExtensionWindow(WindowController* window); | 31 void RemoveExtensionWindow(WindowController* window); |
32 | 32 |
33 void AddObserver(WindowControllerListObserver* observer); | 33 void AddObserver(WindowControllerListObserver* observer); |
34 void RemoveObserver(WindowControllerListObserver* observer); | 34 void RemoveObserver(WindowControllerListObserver* observer); |
35 | 35 |
36 // Returns a window matching |id|. | 36 // Returns a window matching |id|. |
37 WindowController* FindWindowById(int id) const; | 37 WindowController* FindWindowById(int id) const; |
38 | 38 |
39 // Returns a window matching the context the function was invoked in. | 39 // Returns a window matching the context the function was invoked in. |
40 WindowController* FindWindowForFunctionById( | 40 WindowController* FindWindowForFunctionById( |
41 const ChromeUIThreadExtensionFunction* function, | 41 const ChromeExtensionFunctionDetails& function_details, |
42 int id) const; | 42 int id) const; |
43 | 43 |
44 // Returns the focused or last added window matching the context the function | 44 // Returns the focused or last added window matching the context the function |
45 // was invoked in. | 45 // was invoked in. |
46 WindowController* CurrentWindowForFunction( | 46 WindowController* CurrentWindowForFunction( |
47 const ChromeUIThreadExtensionFunction* function) const; | 47 const ChromeExtensionFunctionDetails& function_details) const; |
48 | 48 |
49 const ControllerList& windows() const { return windows_; } | 49 const ControllerList& windows() const { return windows_; } |
50 | 50 |
51 static WindowControllerList* GetInstance(); | 51 static WindowControllerList* GetInstance(); |
52 | 52 |
53 private: | 53 private: |
54 friend struct DefaultSingletonTraits<WindowControllerList>; | 54 friend struct DefaultSingletonTraits<WindowControllerList>; |
55 | 55 |
56 // Entries are not owned by this class and must be removed when destroyed. | 56 // Entries are not owned by this class and must be removed when destroyed. |
57 ControllerList windows_; | 57 ControllerList windows_; |
58 | 58 |
59 ObserverList<WindowControllerListObserver> observers_; | 59 ObserverList<WindowControllerListObserver> observers_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(WindowControllerList); | 61 DISALLOW_COPY_AND_ASSIGN(WindowControllerList); |
62 }; | 62 }; |
63 | 63 |
64 } // namespace extensions | 64 } // namespace extensions |
65 | 65 |
66 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ | 66 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ |
OLD | NEW |