Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_API_TABS_WINDOWS_UTIL_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_UTIL_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_UTIL_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_UTIL_H__ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/window_controller_list.h" | |
| 9 #include "chrome/common/extensions/api/windows.h" | |
| 10 | |
| 8 class UIThreadExtensionFunction; | 11 class UIThreadExtensionFunction; |
| 9 | 12 |
| 13 namespace content { | |
| 14 class BrowserContext; | |
| 15 } | |
| 16 | |
| 10 namespace extensions { | 17 namespace extensions { |
| 18 class Extension; | |
| 11 class WindowController; | 19 class WindowController; |
| 12 } | 20 } |
| 13 | 21 |
| 14 namespace windows_util { | 22 namespace windows_util { |
| 15 | 23 |
| 24 // Returns the default filter to be used when operating on the windows | |
| 25 // from WindowControllerList when using the chrome.windows APIs. | |
| 26 extensions::WindowTypeFilter GetDefaultWindowTypeFilter(); | |
|
not at google - send to devlin
2015/08/04 18:05:03
It would be better for the enum and the utils that
llandwerlin-old
2015/08/05 11:01:22
Done, much simpler indeed. Thanks.
| |
| 27 | |
| 28 // Returns a filter allowing all window types to be manipulated | |
| 29 // through the chrome.windows APIs. | |
| 30 extensions::WindowTypeFilter GetAllWindowTypeFilter(); | |
|
not at google - send to devlin
2015/08/04 18:05:03
GetAllWindowTypesFilter.
llandwerlin-old
2015/08/05 11:01:22
Since you proposed MatchesFilter, I renamed these
| |
| 31 | |
| 32 // Returns true if the window type of |controller| matches the |filter|. | |
| 33 bool WindowMatchesTypeFilter(const extensions::WindowController* controller, | |
| 34 extensions::WindowTypeFilter filter); | |
|
not at google - send to devlin
2015/08/04 18:05:03
A method on extensions::WindowController called "M
llandwerlin-old
2015/08/05 11:01:22
Done.
| |
| 35 | |
| 36 // Converts an array of window types given by the chrome.windows APIs | |
| 37 // to a WindowTypeFilter. | |
| 38 extensions::WindowTypeFilter WindowTypeFilterFromWindowTypes( | |
| 39 const std::vector<extensions::api::windows::WindowType>& types); | |
| 40 | |
| 16 // Populates |controller| for given |window_id|. If the window is not found, | 41 // Populates |controller| for given |window_id|. If the window is not found, |
| 17 // returns false and sets UIThreadExtensionFunction error_. | 42 // returns false and sets UIThreadExtensionFunction error_. |
| 18 bool GetWindowFromWindowID(UIThreadExtensionFunction* function, | 43 bool GetWindowFromWindowID(UIThreadExtensionFunction* function, |
| 19 int window_id, | 44 int window_id, |
| 45 extensions::WindowTypeFilter filter, | |
| 20 extensions::WindowController** controller); | 46 extensions::WindowController** controller); |
| 21 | 47 |
| 22 // Returns true if |function| (and the profile and extension that it was | 48 // Returns true if |function| (and the profile and extension that it was |
| 23 // invoked from) can operate on the window wrapped by |window_controller|. | 49 // invoked from) can operate on the window wrapped by |window_controller|. |
| 50 // If |all_window_types| is set this function will return true for any | |
| 51 // kind of window (including app and devtools), otherwise it will | |
| 52 // return true only for normal browser windows as well as windows | |
| 53 // created by the extension. | |
| 24 bool CanOperateOnWindow(const UIThreadExtensionFunction* function, | 54 bool CanOperateOnWindow(const UIThreadExtensionFunction* function, |
| 25 const extensions::WindowController* controller); | 55 const extensions::WindowController* controller, |
| 56 extensions::WindowTypeFilter filter); | |
| 26 | 57 |
| 27 } // namespace windows_util | 58 } // namespace windows_util |
| 28 | 59 |
| 29 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_UTIL_H__ | 60 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_UTIL_H__ |
| OLD | NEW |