| 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 "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 AppWindow* app_window = registry->GetAppWindowForNativeWindow(window); | 35 AppWindow* app_window = registry->GetAppWindowForNativeWindow(window); |
| 36 if (app_window) | 36 if (app_window) |
| 37 return app_window; | 37 return app_window; |
| 38 } | 38 } |
| 39 | 39 |
| 40 return NULL; | 40 return NULL; |
| 41 } | 41 } |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 bool AppWindowRegistryUtil::IsAppWindowRegisteredInAnyProfile( | 44 bool AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile( |
| 45 int window_type_mask) { | 45 int window_type_mask) { |
| 46 std::vector<Profile*> profiles = | 46 std::vector<Profile*> profiles = |
| 47 g_browser_process->profile_manager()->GetLoadedProfiles(); | 47 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 48 for (std::vector<Profile*>::const_iterator i = profiles.begin(); | 48 for (std::vector<Profile*>::const_iterator i = profiles.begin(); |
| 49 i != profiles.end(); | 49 i != profiles.end(); |
| 50 ++i) { | 50 ++i) { |
| 51 AppWindowRegistry* registry = | 51 AppWindowRegistry* registry = |
| 52 Factory::GetForBrowserContext(*i, false /* create */); | 52 Factory::GetForBrowserContext(*i, false /* create */); |
| 53 if (!registry) | 53 if (!registry) |
| 54 continue; | 54 continue; |
| 55 | 55 |
| 56 const AppWindowList& app_windows = registry->app_windows(); | 56 const AppWindowList& app_windows = registry->app_windows(); |
| 57 if (app_windows.empty()) | 57 if (app_windows.empty()) |
| 58 continue; | 58 continue; |
| 59 | 59 |
| 60 if (window_type_mask == 0) | 60 for (const AppWindow* window : app_windows) { |
| 61 return true; | 61 if (!window->is_hidden() && |
| 62 | 62 (window_type_mask == 0 || |
| 63 for (AppWindowList::const_iterator j = app_windows.begin(); | 63 (window->window_type() & window_type_mask))) |
| 64 j != app_windows.end(); ++j) { | |
| 65 if ((*j)->window_type() & window_type_mask) | |
| 66 return true; | 64 return true; |
| 67 } | 65 } |
| 68 } | 66 } |
| 69 | 67 |
| 70 return false; | 68 return false; |
| 71 } | 69 } |
| 72 | 70 |
| 73 // static | 71 // static |
| 74 void AppWindowRegistryUtil::CloseAllAppWindows() { | 72 void AppWindowRegistryUtil::CloseAllAppWindows() { |
| 75 std::vector<Profile*> profiles = | 73 std::vector<Profile*> profiles = |
| 76 g_browser_process->profile_manager()->GetLoadedProfiles(); | 74 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 77 for (std::vector<Profile*>::const_iterator i = profiles.begin(); | 75 for (std::vector<Profile*>::const_iterator i = profiles.begin(); |
| 78 i != profiles.end(); | 76 i != profiles.end(); |
| 79 ++i) { | 77 ++i) { |
| 80 AppWindowRegistry* registry = | 78 AppWindowRegistry* registry = |
| 81 Factory::GetForBrowserContext(*i, false /* create */); | 79 Factory::GetForBrowserContext(*i, false /* create */); |
| 82 if (!registry) | 80 if (!registry) |
| 83 continue; | 81 continue; |
| 84 | 82 |
| 85 while (!registry->app_windows().empty()) | 83 while (!registry->app_windows().empty()) |
| 86 registry->app_windows().front()->GetBaseWindow()->Close(); | 84 registry->app_windows().front()->GetBaseWindow()->Close(); |
| 87 } | 85 } |
| 88 } | 86 } |
| OLD | NEW |