| 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 "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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 for (const_iterator j = app_windows.begin(); j != app_windows.end(); ++j) { | 222 for (const_iterator j = app_windows.begin(); j != app_windows.end(); ++j) { |
| 223 if ((*j)->window_type() & window_type_mask) | 223 if ((*j)->window_type() & window_type_mask) |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 return false; | 228 return false; |
| 229 } | 229 } |
| 230 | 230 |
| 231 // static |
| 232 void AppWindowRegistry::CloseAllAppWindows() { |
| 233 std::vector<content::BrowserContext*> contexts = |
| 234 AppsClient::Get()->GetLoadedBrowserContexts(); |
| 235 for (std::vector<content::BrowserContext*>::const_iterator i = |
| 236 contexts.begin(); |
| 237 i != contexts.end(); |
| 238 ++i) { |
| 239 AppWindowRegistry* registry = |
| 240 Factory::GetForBrowserContext(*i, false /* create */); |
| 241 if (!registry) |
| 242 continue; |
| 243 |
| 244 while (!registry->app_windows().empty()) |
| 245 registry->app_windows().front()->GetBaseWindow()->Close(); |
| 246 } |
| 247 } |
| 248 |
| 231 void AppWindowRegistry::OnDevToolsStateChanged( | 249 void AppWindowRegistry::OnDevToolsStateChanged( |
| 232 content::DevToolsAgentHost* agent_host, | 250 content::DevToolsAgentHost* agent_host, |
| 233 bool attached) { | 251 bool attached) { |
| 234 content::RenderViewHost* rvh = agent_host->GetRenderViewHost(); | 252 content::RenderViewHost* rvh = agent_host->GetRenderViewHost(); |
| 235 // Ignore unrelated notifications. | 253 // Ignore unrelated notifications. |
| 236 if (!rvh || | 254 if (!rvh || |
| 237 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_) | 255 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_) |
| 238 return; | 256 return; |
| 239 | 257 |
| 240 std::string key = GetWindowKeyForRenderViewHost(this, rvh); | 258 std::string key = GetWindowKeyForRenderViewHost(this, rvh); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return false; | 316 return false; |
| 299 } | 317 } |
| 300 | 318 |
| 301 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( | 319 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( |
| 302 content::BrowserContext* context) const { | 320 content::BrowserContext* context) const { |
| 303 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( | 321 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( |
| 304 context); | 322 context); |
| 305 } | 323 } |
| 306 | 324 |
| 307 } // namespace extensions | 325 } // namespace extensions |
| OLD | NEW |