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::IsAppWindowRegisteredInAnyProfile( |
tapted
2015/01/06 00:51:28
IsAppWindowRegisteredInAnyProfile -> IsAppWindowVi
jackhou1
2015/01/06 02:13:14
Done.
| |
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) | |
61 return true; | |
62 | |
63 for (AppWindowList::const_iterator j = app_windows.begin(); | 60 for (AppWindowList::const_iterator j = app_windows.begin(); |
tapted
2015/01/06 00:51:28
oooh range-based-for!
jackhou1
2015/01/06 02:13:14
Done.
| |
64 j != app_windows.end(); ++j) { | 61 j != app_windows.end(); ++j) { |
65 if ((*j)->window_type() & window_type_mask) | 62 if (!(*j)->is_hidden() && |
63 (window_type_mask == 0 || (*j)->window_type() & window_type_mask)) { | |
tapted
2015/01/06 00:51:28
nit: brackets around the bitwise '&'
jackhou1
2015/01/06 02:13:14
Done.
| |
66 return true; | 64 return true; |
65 } | |
67 } | 66 } |
68 } | 67 } |
69 | 68 |
70 return false; | 69 return false; |
71 } | 70 } |
72 | 71 |
73 // static | 72 // static |
74 void AppWindowRegistryUtil::CloseAllAppWindows() { | 73 void AppWindowRegistryUtil::CloseAllAppWindows() { |
75 std::vector<Profile*> profiles = | 74 std::vector<Profile*> profiles = |
76 g_browser_process->profile_manager()->GetLoadedProfiles(); | 75 g_browser_process->profile_manager()->GetLoadedProfiles(); |
77 for (std::vector<Profile*>::const_iterator i = profiles.begin(); | 76 for (std::vector<Profile*>::const_iterator i = profiles.begin(); |
78 i != profiles.end(); | 77 i != profiles.end(); |
79 ++i) { | 78 ++i) { |
80 AppWindowRegistry* registry = | 79 AppWindowRegistry* registry = |
81 Factory::GetForBrowserContext(*i, false /* create */); | 80 Factory::GetForBrowserContext(*i, false /* create */); |
82 if (!registry) | 81 if (!registry) |
83 continue; | 82 continue; |
84 | 83 |
85 while (!registry->app_windows().empty()) | 84 while (!registry->app_windows().empty()) |
86 registry->app_windows().front()->GetBaseWindow()->Close(); | 85 registry->app_windows().front()->GetBaseWindow()->Close(); |
87 } | 86 } |
88 } | 87 } |
OLD | NEW |