Don't add pending tasks to the lazy background task queue if there is no host.
BUG=297886
[email protected]
Review URL: https://codereview.chromium.org/24476002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@226093 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/lazy_background_task_queue.cc b/chrome/browser/extensions/lazy_background_task_queue.cc
index 0d13a93..fdaab75 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.cc
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc
@@ -79,8 +79,13 @@
ExtensionProcessManager* pm =
ExtensionSystem::Get(profile)->process_manager();
pm->IncrementLazyKeepaliveCount(extension);
- pm->CreateBackgroundHost(extension,
- BackgroundInfo::GetBackgroundURL(extension));
+ // Creating the background host may fail, e.g. if |profile| is incognito
+ // but the extension isn't enabled in incognito mode.
+ if (!pm->CreateBackgroundHost(
+ extension, BackgroundInfo::GetBackgroundURL(extension))) {
+ task.Run(NULL);
+ return;
+ }
}
} else {
tasks_list = it->second.get();