Chromium Code Reviews| 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 UIThreadExtensionFunction; | 16 class UIThreadExtensionFunction; |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 // A set bit field values to be used as a WindowTypeFilter. This enum | |
| 21 // needs to stay in sync with extensions::api::windows::WindowType. | |
| 22 enum WindowTypeFilterValues : uint32 { | |
|
not at google - send to devlin
2015/08/04 18:05:03
Hm, I've never seen ": uint32" be needed before, i
llandwerlin-old
2015/08/05 11:01:22
dropped the : uint32 and moved the enum inside win
| |
| 23 WINDOW_TYPE_FILTER_NONE = 0, | |
| 24 WINDOW_TYPE_FILTER_NORMAL = 1 << 1, | |
| 25 WINDOW_TYPE_FILTER_POPUP = 1 << 2, | |
| 26 WINDOW_TYPE_FILTER_PANEL = 1 << 3, | |
| 27 WINDOW_TYPE_FILTER_APP = 1 << 4, | |
| 28 WINDOW_TYPE_FILTER_DEVTOOLS = 1 << 5 | |
| 29 }; | |
| 30 typedef uint32 WindowTypeFilter; | |
| 31 | |
| 20 class WindowControllerListObserver; | 32 class WindowControllerListObserver; |
| 21 | 33 |
| 22 // Class to maintain a list of WindowControllers. | 34 // Class to maintain a list of WindowControllers. |
| 23 class WindowControllerList { | 35 class WindowControllerList { |
| 24 public: | 36 public: |
| 25 typedef std::list<WindowController*> ControllerList; | 37 typedef std::list<WindowController*> ControllerList; |
| 26 | 38 |
| 27 WindowControllerList(); | 39 WindowControllerList(); |
| 28 ~WindowControllerList(); | 40 ~WindowControllerList(); |
| 29 | 41 |
| 30 void AddExtensionWindow(WindowController* window); | 42 void AddExtensionWindow(WindowController* window); |
| 31 void RemoveExtensionWindow(WindowController* window); | 43 void RemoveExtensionWindow(WindowController* window); |
| 32 | 44 |
| 33 void AddObserver(WindowControllerListObserver* observer); | 45 void AddObserver(WindowControllerListObserver* observer); |
| 34 void RemoveObserver(WindowControllerListObserver* observer); | 46 void RemoveObserver(WindowControllerListObserver* observer); |
| 35 | 47 |
| 36 // Returns a window matching |id|. | 48 // Returns a window matching |id|. |
| 37 WindowController* FindWindowById(int id) const; | 49 WindowController* FindWindowById(int id) const; |
| 38 | 50 |
| 51 // Returns a window matching |id| using |filter|. | |
| 52 WindowController* FindWindowByIdWithFilter(int id, | |
| 53 WindowTypeFilter filter) const; | |
| 54 | |
| 39 // Returns a window matching the context the function was invoked in. | 55 // Returns a window matching the context the function was invoked in. |
| 40 WindowController* FindWindowForFunctionById( | 56 WindowController* FindWindowForFunctionById( |
| 41 const UIThreadExtensionFunction* function, | 57 const UIThreadExtensionFunction* function, |
| 42 int id) const; | 58 int id) const; |
| 43 | 59 |
| 60 // Returns a window matching the context the function was invoked in | |
| 61 // using |filter|. | |
| 62 WindowController* FindWindowForFunctionByIdWithFilter( | |
| 63 const UIThreadExtensionFunction* function, | |
| 64 int id, | |
| 65 WindowTypeFilter filter) const; | |
| 66 | |
| 44 // Returns the focused or last added window matching the context the function | 67 // Returns the focused or last added window matching the context the function |
| 45 // was invoked in. | 68 // was invoked in. |
| 46 WindowController* CurrentWindowForFunction( | 69 WindowController* CurrentWindowForFunction( |
| 47 const UIThreadExtensionFunction* function) const; | 70 const UIThreadExtensionFunction* function) const; |
| 48 | 71 |
| 72 // Returns the focused or last added window matching the context the function | |
| 73 // was invoked in using |filter|. | |
| 74 WindowController* CurrentWindowForFunctionWithFilter( | |
| 75 const UIThreadExtensionFunction* function, | |
| 76 WindowTypeFilter filter) const; | |
| 77 | |
| 49 const ControllerList& windows() const { return windows_; } | 78 const ControllerList& windows() const { return windows_; } |
| 50 | 79 |
| 51 static WindowControllerList* GetInstance(); | 80 static WindowControllerList* GetInstance(); |
| 52 | 81 |
| 53 private: | 82 private: |
| 54 friend struct DefaultSingletonTraits<WindowControllerList>; | 83 friend struct DefaultSingletonTraits<WindowControllerList>; |
| 55 | 84 |
| 56 // Entries are not owned by this class and must be removed when destroyed. | 85 // Entries are not owned by this class and must be removed when destroyed. |
| 57 ControllerList windows_; | 86 ControllerList windows_; |
| 58 | 87 |
| 59 base::ObserverList<WindowControllerListObserver> observers_; | 88 base::ObserverList<WindowControllerListObserver> observers_; |
| 60 | 89 |
| 61 DISALLOW_COPY_AND_ASSIGN(WindowControllerList); | 90 DISALLOW_COPY_AND_ASSIGN(WindowControllerList); |
| 62 }; | 91 }; |
| 63 | 92 |
| 64 } // namespace extensions | 93 } // namespace extensions |
| 65 | 94 |
| 66 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ | 95 #endif // CHROME_BROWSER_EXTENSIONS_WINDOW_CONTROLLER_LIST_H_ |
| OLD | NEW |