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

Side by Side Diff: apps/app_window_registry.cc

Issue 220373003: Prevent Chrome from quitting when apps are open. (Mac) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « apps/app_window_registry.h ('k') | chrome/app/chromium_strings.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "apps/app_window.h" 5 #include "apps/app_window.h"
6 #include "apps/app_window_registry.h" 6 #include "apps/app_window_registry.h"
7 #include "apps/apps_client.h" 7 #include "apps/apps_client.h"
8 #include "apps/ui/native_app_window.h" 8 #include "apps/ui/native_app_window.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h" 9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 for (const_iterator j = app_windows.begin(); j != app_windows.end(); ++j) { 236 for (const_iterator j = app_windows.begin(); j != app_windows.end(); ++j) {
237 if ((*j)->window_type() & window_type_mask) 237 if ((*j)->window_type() & window_type_mask)
238 return true; 238 return true;
239 } 239 }
240 } 240 }
241 241
242 return false; 242 return false;
243 } 243 }
244 244
245 // static
246 void AppWindowRegistry::CloseAllAppWindows() {
247 std::vector<content::BrowserContext*> contexts =
248 AppsClient::Get()->GetLoadedBrowserContexts();
249 for (std::vector<content::BrowserContext*>::const_iterator i =
250 contexts.begin();
251 i != contexts.end();
252 ++i) {
253 AppWindowRegistry* registry =
254 Factory::GetForBrowserContext(*i, false /* create */);
255 if (!registry)
256 continue;
257
258 while (!registry->app_windows().empty())
259 registry->app_windows().front()->GetBaseWindow()->Close();
260 }
261 }
262
245 void AppWindowRegistry::OnDevToolsStateChanged( 263 void AppWindowRegistry::OnDevToolsStateChanged(
246 content::DevToolsAgentHost* agent_host, 264 content::DevToolsAgentHost* agent_host,
247 bool attached) { 265 bool attached) {
248 content::RenderViewHost* rvh = agent_host->GetRenderViewHost(); 266 content::RenderViewHost* rvh = agent_host->GetRenderViewHost();
249 // Ignore unrelated notifications. 267 // Ignore unrelated notifications.
250 if (!rvh || 268 if (!rvh ||
251 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_) 269 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_)
252 return; 270 return;
253 271
254 std::string key = GetWindowKeyForRenderViewHost(this, rvh); 272 std::string key = GetWindowKeyForRenderViewHost(this, rvh);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return false; 330 return false;
313 } 331 }
314 332
315 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( 333 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse(
316 content::BrowserContext* context) const { 334 content::BrowserContext* context) const {
317 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( 335 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext(
318 context); 336 context);
319 } 337 }
320 338
321 } // namespace apps 339 } // namespace apps
OLDNEW
« no previous file with comments | « apps/app_window_registry.h ('k') | chrome/app/chromium_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698