| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const GURL& url) override; | 99 const GURL& url) override; |
| 100 scoped_refptr<content::SiteInstance> GetSiteInstanceForURL(const GURL& url) | 100 scoped_refptr<content::SiteInstance> GetSiteInstanceForURL(const GURL& url) |
| 101 override; | 101 override; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(IncognitoProcessManager); | 104 DISALLOW_COPY_AND_ASSIGN(IncognitoProcessManager); |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 static void CreateBackgroundHostForExtensionLoad( | 107 static void CreateBackgroundHostForExtensionLoad( |
| 108 ProcessManager* manager, const Extension* extension) { | 108 ProcessManager* manager, const Extension* extension) { |
| 109 DVLOG(1) << "CreateBackgroundHostForExtensionLoad " << extension->id(); | |
| 110 if (BackgroundInfo::HasPersistentBackgroundPage(extension)) | 109 if (BackgroundInfo::HasPersistentBackgroundPage(extension)) |
| 111 manager->CreateBackgroundHost(extension, | 110 manager->CreateBackgroundHost(extension, |
| 112 BackgroundInfo::GetBackgroundURL(extension)); | 111 BackgroundInfo::GetBackgroundURL(extension)); |
| 113 } | 112 } |
| 114 | 113 |
| 115 void PropagateExtensionWakeResult(const base::Callback<void(bool)>& callback, | 114 void PropagateExtensionWakeResult(const base::Callback<void(bool)>& callback, |
| 116 extensions::ExtensionHost* host) { | 115 extensions::ExtensionHost* host) { |
| 117 callback.Run(host != nullptr); | 116 callback.Run(host != nullptr); |
| 118 } | 117 } |
| 119 | 118 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 bool ProcessManager::CreateBackgroundHost(const Extension* extension, | 357 bool ProcessManager::CreateBackgroundHost(const Extension* extension, |
| 359 const GURL& url) { | 358 const GURL& url) { |
| 360 // Hosted apps are taken care of from BackgroundContentsService. Ignore them | 359 // Hosted apps are taken care of from BackgroundContentsService. Ignore them |
| 361 // here. | 360 // here. |
| 362 if (extension->is_hosted_app()) | 361 if (extension->is_hosted_app()) |
| 363 return false; | 362 return false; |
| 364 | 363 |
| 365 // Don't create hosts if the embedder doesn't allow it. | 364 // Don't create hosts if the embedder doesn't allow it. |
| 366 ProcessManagerDelegate* delegate = | 365 ProcessManagerDelegate* delegate = |
| 367 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); | 366 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); |
| 368 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_)) | 367 if (delegate && |
| 368 !delegate->IsExtensionBackgroundPageAllowed(browser_context_, extension)) |
| 369 return false; | 369 return false; |
| 370 | 370 |
| 371 // Don't create multiple background hosts for an extension. | 371 // Don't create multiple background hosts for an extension. |
| 372 if (GetBackgroundHostForExtension(extension->id())) | 372 if (GetBackgroundHostForExtension(extension->id())) |
| 373 return true; // TODO(kalman): return false here? It might break things... | 373 return true; // TODO(kalman): return false here? It might break things... |
| 374 | 374 |
| 375 DVLOG(1) << "CreateBackgroundHost " << extension->id(); |
| 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 && |
| 392 !delegate->AreBackgroundPagesAllowedForContext(browser_context_)) |
| 391 return; | 393 return; |
| 392 | 394 |
| 393 // The embedder might want to defer background page loading. For example, | 395 // 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 | 396 // 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. | 397 // list, then triggers a load later when a browser window opens. |
| 396 if (delegate && | 398 if (delegate && |
| 397 delegate->DeferCreatingStartupBackgroundHosts(browser_context_)) | 399 delegate->DeferCreatingStartupBackgroundHosts(browser_context_)) |
| 398 return; | 400 return; |
| 399 | 401 |
| 400 CreateStartupBackgroundHosts(); | 402 CreateStartupBackgroundHosts(); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 if (extension && !IncognitoInfo::IsSplitMode(extension)) { | 992 if (extension && !IncognitoInfo::IsSplitMode(extension)) { |
| 991 BrowserContext* original_context = | 993 BrowserContext* original_context = |
| 992 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); | 994 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); |
| 993 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); | 995 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); |
| 994 } | 996 } |
| 995 | 997 |
| 996 return ProcessManager::GetSiteInstanceForURL(url); | 998 return ProcessManager::GetSiteInstanceForURL(url); |
| 997 } | 999 } |
| 998 | 1000 |
| 999 } // namespace extensions | 1001 } // namespace extensions |
| OLD | NEW |