Commit 454ac851 authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

[Chromecast] Launch background pages while loading an extension

We need a ProcessManager to exist in order to load background
pages but like everything extension-related it is lazy created

Bug: b/73768170
Test: load extension at start verify background script prints occur


Change-Id: I63ccc58ee819ec0435646c296ceb0d7678c433cc
Reviewed-on: https://chromium-review.googlesource.com/959343Reviewed-by: default avatarKevin Schoedel <kpschoedel@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545851}
parent 4a941ec1
......@@ -100,6 +100,7 @@
#include "chromecast/browser/extensions/cast_prefs.h"
#include "chromecast/common/cast_extensions_client.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" // nogncheck
#include "extensions/browser/browser_context_keyed_service_factories.h" // nogncheck
#include "extensions/browser/extension_prefs.h" // nogncheck
#endif
......@@ -541,6 +542,8 @@ void CastBrowserMainParts::PreMainMessageLoopRun() {
cast_browser_process_->browser_context(), user_pref_service_.get());
extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
extensions::EnsureBrowserContextKeyedServiceFactoriesBuilt();
extensions::CastExtensionSystem* extension_system =
static_cast<extensions::CastExtensionSystem*>(
extensions::ExtensionSystem::Get(
......
......@@ -20,8 +20,10 @@
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/info_map.h"
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/null_app_sorting.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/quota_service.h"
#include "extensions/browser/renderer_startup_helper.h"
#include "extensions/browser/runtime_data.h"
......@@ -32,6 +34,7 @@
#include "extensions/common/constants.h"
#include "extensions/common/file_util.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/background_info.h"
using content::BrowserContext;
using content::BrowserThread;
......@@ -95,7 +98,7 @@ const Extension* CastExtensionSystem::LoadExtensionByManifest(
return nullptr;
}
extension_registrar_->AddExtension(extension);
PostLoadExtension(extension);
return extension.get();
}
......@@ -124,16 +127,23 @@ const Extension* CastExtensionSystem::LoadExtension(
LOG(WARNING) << warning.message;
}
extension_registrar_->AddExtension(extension);
PostLoadExtension(extension);
return extension.get();
}
void CastExtensionSystem::PostLoadExtension(
const scoped_refptr<extensions::Extension>& extension) {
extension_registrar_->AddExtension(extension);
}
const Extension* CastExtensionSystem::LoadApp(const base::FilePath& app_dir) {
return LoadExtension(app_dir);
}
void CastExtensionSystem::Init() {
extensions::ProcessManager::Get(browser_context_);
// Inform the rest of the extensions system to start.
ready_.Signal();
content::NotificationService::current()->Notify(
......
......@@ -102,6 +102,7 @@ class CastExtensionSystem : public ExtensionSystem,
bool ShouldBlockExtension(const Extension* extension) override;
private:
void PostLoadExtension(const scoped_refptr<extensions::Extension>& extension);
void OnExtensionRegisteredWithRequestContexts(
scoped_refptr<Extension> extension);
content::BrowserContext* browser_context_; // Not owned.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment