| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/process_manager.h" | 5 #include "extensions/browser/process_manager.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 bool ProcessManager::CreateBackgroundHost(const Extension* extension, | 358 bool ProcessManager::CreateBackgroundHost(const Extension* extension, |
| 359 const GURL& url) { | 359 const GURL& url) { |
| 360 // Hosted apps are taken care of from BackgroundContentsService. Ignore them | 360 // Hosted apps are taken care of from BackgroundContentsService. Ignore them |
| 361 // here. | 361 // here. |
| 362 if (extension->is_hosted_app()) | 362 if (extension->is_hosted_app()) |
| 363 return false; | 363 return false; |
| 364 | 364 |
| 365 // Don't create hosts if the embedder doesn't allow it. | 365 // Don't create hosts if the embedder doesn't allow it. |
| 366 ProcessManagerDelegate* delegate = | 366 ProcessManagerDelegate* delegate = |
| 367 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); | 367 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); |
| 368 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_)) | 368 if (delegate && |
| 369 !delegate->IsBackgroundPageAllowed(browser_context_, extension)) |
| 369 return false; | 370 return false; |
| 370 | 371 |
| 371 // Don't create multiple background hosts for an extension. | 372 // Don't create multiple background hosts for an extension. |
| 372 if (GetBackgroundHostForExtension(extension->id())) | 373 if (GetBackgroundHostForExtension(extension->id())) |
| 373 return true; // TODO(kalman): return false here? It might break things... | 374 return true; // TODO(kalman): return false here? It might break things... |
| 374 | 375 |
| 375 ExtensionHost* host = | 376 ExtensionHost* host = |
| 376 new ExtensionHost(extension, GetSiteInstanceForURL(url).get(), url, | 377 new ExtensionHost(extension, GetSiteInstanceForURL(url).get(), url, |
| 377 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 378 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
| 378 host->CreateRenderViewSoon(); | 379 host->CreateRenderViewSoon(); |
| 379 OnBackgroundHostCreated(host); | 380 OnBackgroundHostCreated(host); |
| 380 return true; | 381 return true; |
| 381 } | 382 } |
| 382 | 383 |
| 383 void ProcessManager::MaybeCreateStartupBackgroundHosts() { | 384 void ProcessManager::MaybeCreateStartupBackgroundHosts() { |
| 384 if (startup_background_hosts_created_) | 385 if (startup_background_hosts_created_) |
| 385 return; | 386 return; |
| 386 | 387 |
| 387 // The embedder might disallow background pages entirely. | 388 // The embedder might disallow background pages entirely. |
| 388 ProcessManagerDelegate* delegate = | 389 ProcessManagerDelegate* delegate = |
| 389 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); | 390 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); |
| 390 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_)) | 391 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_, nullptr)) |
| 391 return; | 392 return; |
| 392 | 393 |
| 393 // The embedder might want to defer background page loading. For example, | 394 // The embedder might want to defer background page loading. For example, |
| 394 // Chrome defers background page loading when it is launched to show the app | 395 // Chrome defers background page loading when it is launched to show the app |
| 395 // list, then triggers a load later when a browser window opens. | 396 // list, then triggers a load later when a browser window opens. |
| 396 if (delegate && | 397 if (delegate && |
| 397 delegate->DeferCreatingStartupBackgroundHosts(browser_context_)) | 398 delegate->DeferCreatingStartupBackgroundHosts(browser_context_)) |
| 398 return; | 399 return; |
| 399 | 400 |
| 400 CreateStartupBackgroundHosts(); | 401 CreateStartupBackgroundHosts(); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 991 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
| 991 BrowserContext* original_context = | 992 BrowserContext* original_context = |
| 992 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); | 993 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); |
| 993 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); | 994 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); |
| 994 } | 995 } |
| 995 | 996 |
| 996 return ProcessManager::GetSiteInstanceForURL(url); | 997 return ProcessManager::GetSiteInstanceForURL(url); |
| 997 } | 998 } |
| 998 | 999 |
| 999 } // namespace extensions | 1000 } // namespace extensions |
| OLD | NEW |