Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/browser/apps/app_window_registry_util.cc

Issue 800473006: Don't include hidden windows in IsAppWindowRegisteredInAnyProfile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/app_window_registry_util.h ('k') | chrome/browser/ui/apps/apps_metro_handler_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698