Chromium Code Reviews| 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 const AppWindowList& app_windows = registry->app_windows(); | |
| 245 while (!app_windows.empty()) | |
|
tapted
2014/04/03 03:49:15
nit: I would just use !registry->app_windows_.empt
jackhou1
2014/04/03 04:00:52
Done.
| |
| 246 app_windows.front()->GetBaseWindow()->Close(); | |
| 247 } | |
| 248 } | |
| 249 | |
| 231 void AppWindowRegistry::OnDevToolsStateChanged( | 250 void AppWindowRegistry::OnDevToolsStateChanged( |
| 232 content::DevToolsAgentHost* agent_host, | 251 content::DevToolsAgentHost* agent_host, |
| 233 bool attached) { | 252 bool attached) { |
| 234 content::RenderViewHost* rvh = agent_host->GetRenderViewHost(); | 253 content::RenderViewHost* rvh = agent_host->GetRenderViewHost(); |
| 235 // Ignore unrelated notifications. | 254 // Ignore unrelated notifications. |
| 236 if (!rvh || | 255 if (!rvh || |
| 237 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_) | 256 rvh->GetSiteInstance()->GetProcess()->GetBrowserContext() != context_) |
| 238 return; | 257 return; |
| 239 | 258 |
| 240 std::string key = GetWindowKeyForRenderViewHost(this, rvh); | 259 std::string key = GetWindowKeyForRenderViewHost(this, rvh); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 return false; | 317 return false; |
| 299 } | 318 } |
| 300 | 319 |
| 301 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( | 320 content::BrowserContext* AppWindowRegistry::Factory::GetBrowserContextToUse( |
| 302 content::BrowserContext* context) const { | 321 content::BrowserContext* context) const { |
| 303 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( | 322 return extensions::ExtensionsBrowserClient::Get()->GetOriginalContext( |
| 304 context); | 323 context); |
| 305 } | 324 } |
| 306 | 325 |
| 307 } // namespace extensions | 326 } // namespace extensions |
| OLD | NEW |