Chromium Code Reviews| Index: chrome/browser/extensions/window_controller.cc |
| diff --git a/chrome/browser/extensions/window_controller.cc b/chrome/browser/extensions/window_controller.cc |
| index 96f9eac9d8bd71810f4f980ccd3ae3c004698ead..225a792fc8019b122c8bff9403f66d453bee0563 100644 |
| --- a/chrome/browser/extensions/window_controller.cc |
| +++ b/chrome/browser/extensions/window_controller.cc |
| @@ -8,6 +8,7 @@ |
| #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| #include "chrome/browser/extensions/window_controller_list.h" |
| #include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/extensions/api/windows.h" |
| #include "ui/base/base_window.h" |
| #include "ui/gfx/geometry/rect.h" |
| @@ -16,6 +17,38 @@ namespace extensions { |
| /////////////////////////////////////////////////////////////////////////////// |
| // WindowController |
| +// A set bitmask values to be used as a WindowTypeFilter. This enum |
| +// needs to stay in sync with extensions::api::windows::WindowType. |
| +enum WindowTypeFilterValues { |
|
not at google - send to devlin
2015/08/05 17:33:25
Actually why do you even need this; can you use th
llandwerlin-old
2015/08/05 18:12:02
Done.
|
| + WINDOW_TYPE_FILTER_NONE = 0, |
| + WINDOW_TYPE_FILTER_NORMAL = 1 << 1, |
| + WINDOW_TYPE_FILTER_POPUP = 1 << 2, |
| + WINDOW_TYPE_FILTER_PANEL = 1 << 3, |
| + WINDOW_TYPE_FILTER_APP = 1 << 4, |
| + WINDOW_TYPE_FILTER_DEVTOOLS = 1 << 5 |
| +}; |
| + |
| +// static |
| +WindowTypeFilter WindowController::GetAllWindowFilter() { |
| + // extensions::WindowTypeFilterValues needs to be updated if there |
| + // is a change to extensions::api::windows:WindowType. |
| + COMPILE_ASSERT( |
| + api::windows::WINDOW_TYPE_LAST == api::windows::WINDOW_TYPE_DEVTOOLS, |
| + Update_WindowControllerList_to_match_WindowType); |
|
not at google - send to devlin
2015/08/05 17:33:25
I think this COMPILE_ASSERT can be left out. This
llandwerlin-old
2015/08/05 18:12:02
I want make sure that if someone adds a new window
not at google - send to devlin
2015/08/05 18:17:39
That makes sense.
|
| + COMPILE_ASSERT( |
| + (1 << api::windows::WINDOW_TYPE_DEVTOOLS) == WINDOW_TYPE_FILTER_DEVTOOLS, |
| + Update_WindowControllerList_to_match_WindowType); |
| + return (WINDOW_TYPE_FILTER_NORMAL | WINDOW_TYPE_FILTER_PANEL | |
| + WINDOW_TYPE_FILTER_POPUP | WINDOW_TYPE_FILTER_APP | |
| + WINDOW_TYPE_FILTER_DEVTOOLS); |
| +} |
| + |
| +// static |
| +WindowTypeFilter WindowController::GetDefaultWindowFilter() { |
| + return (WINDOW_TYPE_FILTER_NORMAL | WINDOW_TYPE_FILTER_PANEL | |
| + WINDOW_TYPE_FILTER_POPUP); |
| +} |
| + |
| WindowController::WindowController(ui::BaseWindow* window, Profile* profile) |
| : window_(window), profile_(profile) { |
| } |
| @@ -63,4 +96,10 @@ base::DictionaryValue* WindowController::CreateWindowValue() const { |
| return result; |
| } |
| +bool WindowController::MatchesFilter(WindowTypeFilter filter) const { |
| + WindowTypeFilter type = 1 |
| + << api::windows::ParseWindowType(GetWindowTypeText()); |
| + return (type & filter) != 0; |
| +} |
| + |
| } // namespace extensions |