| 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..24da3ccd06570cbb9eb42833e93088a7441d18c5 100644
|
| --- a/chrome/browser/extensions/window_controller_list.cc
|
| +++ b/chrome/browser/extensions/window_controller_list.cc
|
| @@ -55,30 +55,54 @@ void WindowControllerList::RemoveObserver(
|
| }
|
|
|
| WindowController* WindowControllerList::FindWindowById(int id) const {
|
| + return FindWindowByIdWithFilter(id,
|
| + windows_util::GetDefaultWindowTypeFilter());
|
| +}
|
| +
|
| +WindowController* WindowControllerList::FindWindowByIdWithFilter(
|
| + int id,
|
| + WindowTypeFilter filter) const {
|
| for (ControllerList::const_iterator iter = windows().begin();
|
| iter != windows().end(); ++iter) {
|
| - if ((*iter)->GetWindowId() == id)
|
| + if ((*iter)->GetWindowId() == id &&
|
| + windows_util::WindowMatchesTypeFilter(*iter, filter))
|
| return *iter;
|
| }
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| 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::GetDefaultWindowTypeFilter());
|
| +}
|
| +
|
| +WindowController* WindowControllerList::FindWindowForFunctionByIdWithFilter(
|
| + const UIThreadExtensionFunction* function,
|
| + int id,
|
| + WindowTypeFilter filter) const {
|
| + WindowController* controller = FindWindowByIdWithFilter(id, filter);
|
| + if (controller &&
|
| + windows_util::CanOperateOnWindow(function, controller, filter))
|
| return controller;
|
| - return NULL;
|
| + return nullptr;
|
| }
|
|
|
| WindowController* WindowControllerList::CurrentWindowForFunction(
|
| const UIThreadExtensionFunction* function) const {
|
| - WindowController* result = NULL;
|
| + return CurrentWindowForFunctionWithFilter(
|
| + function, windows_util::GetDefaultWindowTypeFilter());
|
| +}
|
| +
|
| +WindowController* WindowControllerList::CurrentWindowForFunctionWithFilter(
|
| + const UIThreadExtensionFunction* function,
|
| + WindowTypeFilter filter) const {
|
| + WindowController* result = nullptr;
|
| // 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
|
|
|