Chromium Code Reviews| Index: chrome/browser/extensions/window_controller_list.cc |
| diff --git a/chrome/browser/extensions/window_controller_list.cc b/chrome/browser/extensions/window_controller_list.cc |
| index cea69d568d448b11d3bc8925b43dd2fcb10038bf..3c853a2ae2583045263236b5cc51e7e0a1c074d6 100644 |
| --- a/chrome/browser/extensions/window_controller_list.cc |
| +++ b/chrome/browser/extensions/window_controller_list.cc |
| @@ -63,22 +63,50 @@ WindowController* WindowControllerList::FindWindowById(int id) const { |
| return NULL; |
| } |
| +WindowController* WindowControllerList::FindWindowByIdWithFilter( |
| + int id, |
| + const WindowTypeFilter& filter) const { |
| + for (ControllerList::const_iterator iter = windows().begin(); |
| + iter != windows().end(); ++iter) { |
| + if ((*iter)->GetWindowId() == id && |
| + windows_util::WindowMatchesTypeFilter(*iter, filter)) |
|
not at google - send to devlin
2015/07/31 21:48:03
To share code with this and FindWindowById, and on
llandwerlin-old
2015/08/03 10:11:54
Done.
|
| + return *iter; |
| + } |
| + return NULL; |
|
not at google - send to devlin
2015/07/31 21:48:03
NULL --> nullptr
llandwerlin-old
2015/08/03 10:11:54
Done.
|
| +} |
| + |
| WindowController* WindowControllerList::FindWindowForFunctionById( |
| const UIThreadExtensionFunction* function, |
| int id) const { |
| - WindowController* controller = FindWindowById(id); |
| - if (controller && windows_util::CanOperateOnWindow(function, controller)) |
| + return FindWindowForFunctionByIdWithFilter( |
| + function, id, windows_util::GetDefaultWindowTypeFilters()); |
| +} |
| + |
| +WindowController* WindowControllerList::FindWindowForFunctionByIdWithFilter( |
| + const UIThreadExtensionFunction* function, |
| + int id, |
| + const WindowTypeFilter& filter) const { |
| + WindowController* controller = FindWindowByIdWithFilter(id, filter); |
| + if (controller && |
| + windows_util::CanOperateOnWindow(function, controller, filter)) |
| return controller; |
| return NULL; |
| } |
| WindowController* WindowControllerList::CurrentWindowForFunction( |
| const UIThreadExtensionFunction* function) const { |
| + return CurrentWindowForFunctionWithFilter( |
| + function, windows_util::GetDefaultWindowTypeFilters()); |
| +} |
| + |
| +WindowController* WindowControllerList::CurrentWindowForFunctionWithFilter( |
| + const UIThreadExtensionFunction* function, |
| + const WindowTypeFilter& filter) const { |
| WindowController* result = NULL; |
| // Returns either the focused window (if any), or the last window in the list. |
| for (ControllerList::const_iterator iter = windows().begin(); |
| iter != windows().end(); ++iter) { |
| - if (windows_util::CanOperateOnWindow(function, *iter)) { |
| + if (windows_util::CanOperateOnWindow(function, *iter, filter)) { |
| result = *iter; |
| if (result->window()->IsActive()) |
| break; // use focused window |