| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/apps/app_window_registry_util.h" | 5 #include "chrome/browser/apps/app_window_registry_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/stl_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "extensions/browser/app_window/app_window.h" | 13 #include "extensions/browser/app_window/app_window.h" |
| 13 #include "extensions/browser/app_window/app_window_registry.h" | 14 #include "extensions/browser/app_window/app_window_registry.h" |
| 14 #include "extensions/browser/app_window/native_app_window.h" | 15 #include "extensions/browser/app_window/native_app_window.h" |
| 15 | 16 |
| 16 using extensions::AppWindow; | 17 using extensions::AppWindow; |
| 17 using extensions::AppWindowRegistry; | 18 using extensions::AppWindowRegistry; |
| 18 | 19 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 AppWindowRegistry* registry = | 79 AppWindowRegistry* registry = |
| 79 Factory::GetForBrowserContext(*i, false /* create */); | 80 Factory::GetForBrowserContext(*i, false /* create */); |
| 80 if (!registry) | 81 if (!registry) |
| 81 continue; | 82 continue; |
| 82 | 83 |
| 83 // Ask each app window to close, but cater for windows removing or | 84 // Ask each app window to close, but cater for windows removing or |
| 84 // rearranging themselves in the ordered window list in response. | 85 // rearranging themselves in the ordered window list in response. |
| 85 AppWindowList window_list_copy(registry->app_windows()); | 86 AppWindowList window_list_copy(registry->app_windows()); |
| 86 for (const auto& window : window_list_copy) { | 87 for (const auto& window : window_list_copy) { |
| 87 // Ensure window is still valid. | 88 // Ensure window is still valid. |
| 88 if (std::find(registry->app_windows().begin(), | 89 if (ContainsValue(registry->app_windows(), window)) |
| 89 registry->app_windows().end(), | |
| 90 window) != registry->app_windows().end()) | |
| 91 window->GetBaseWindow()->Close(); | 90 window->GetBaseWindow()->Close(); |
| 92 } | 91 } |
| 93 } | 92 } |
| 94 } | 93 } |
| OLD | NEW |