chromium : extensions, how background scripts/page get loaded.

Summary

a generated background page such as
chrome-extension://ffdhgjkakefolmigapfdgbcneopmidbf/_generated_background_page.html
will be loaded soon afer extensions service init.

the content of background page is generated by GeneratedBackgroundPageJob.
specially for scheme "chrome-extension://"

GenerateBackgroundPageContents

#3 0x56110ab93b63 extensions::(anonymous namespace)::GeneratedBackgroundPageJob::GetData()
#4 0x7fb7125791e9 net::URLRequestSimpleJob::GetRefCountedData()
#5 0x7fb712578baf net::URLRequestSimpleJob::StartAsync()

extensions::CreateExtensionProtocolHandler

void ProfileIOData::SetUpJobFactoryDefaultsForBuilder(
    net::URLRequestContextBuilder* builder,
    content::URLRequestInterceptorScopedVector request_interceptors,
    std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
        protocol_handler_interceptor) const {
// NOTE(willchan): Keep these protocol handlers in sync with
// ProfileIOData::IsHandledProtocol().
#if BUILDFLAG(ENABLE_EXTENSIONS)
  DCHECK(extension_info_map_.get());
  // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
  bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
  builder->SetProtocolHandler(extensions::kExtensionScheme,
                              extensions::CreateExtensionProtocolHandler(
                                  is_incognito, extension_info_map_.get()));
#endif

GeneratedBackgroundPageJob

#2 0x55593de3c42e extensions::(anonymous namespace)::GeneratedBackgroundPageJob::GeneratedBackgroundPageJob()
#3 0x55593de3b4cd extensions::(anonymous namespace)::ExtensionProtocolHandler::MaybeCreateJob()
#4 0x7f0f359c0352 net::URLRequestJobFactoryImpl::MaybeCreateJobWithProtocolHandler()
#5 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#6 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#7 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#8 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#9 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#10 0x7f0f359ba13e net::URLRequestInterceptingJobFactory::MaybeCreateJobWithProtocolHandler()
#11 0x55593f4ea748 ProtocolHandlerRegistry::JobInterceptorFactory::MaybeCreateJobWithProtocolHandler()
#12 0x7f0f359c0c5f net::URLRequestJobManager::CreateJob()
#13 0x7f0f35981e78 net::URLRequest::BeforeRequestComplete()

LoadURL("chrome-extension://ffdhgjkakefolmigapfdgbcneopmidbf/_generated_background_page.html")

[20357:20357:0120/200335.076376:INFO:navigation_controller_impl.cc(659)]  url chrome-extension://ffdhgjkakefolmigapfdgbcneopmidbf/_generated_background_page.html
#2 0x7f4943d1ba52 content::NavigationControllerImpl::LoadURL()
#3 0x56433d6fdc98 extensions::ExtensionHost::LoadInitialURL()
#4 0x56433d6fce59 extensions::ExtensionHost::CreateRenderViewNow()
#5 0x56433d80b5ce extensions::SerialExtensionHostQueue::ProcessOneHost()

CreateBackgroundHostForExtensionLoad

#2 0x557dfb4320c8 extensions::SerialExtensionHostQueue::PostTask()
#3 0x557dfb432074 extensions::SerialExtensionHostQueue::Add()
#4 0x557dfb3f3ffd extensions::LoadMonitoringExtensionHostQueue::Add()
#5 0x557dfb323dae extensions::ExtensionHost::CreateRenderViewSoon()
#6 0x557dfb3fe434 extensions::ProcessManager::CreateBackgroundHost()
#7 0x557dfb40381e extensions::(anonymous namespace)::CreateBackgroundHostForExtensionLoad()
#8 0x557dfb3ff6ad extensions::ProcessManager::CreateStartupBackgroundHosts()
#9 0x557dfb3ff45f extensions::ProcessManager::MaybeCreateStartupBackgroundHosts()
#10 0x557dfb402520 extensions::ProcessManager::Observe()
#11 0x7fbea48e3558 content::NotificationServiceImpl::Notify()
#12 0x557dfeed50af ExtensionService::SetReadyAndNotifyListeners()
#13 0x557dfeed36a0 ExtensionService::Init()
#14 0x557dfef12dc2 extensions::ExtensionSystemImpl::Shared::Init()
#15 0x557dfef137a2 extensions::ExtensionSystemImpl::InitForRegularProfile()
#16 0x557dfcb664ba ProfileManager::DoFinalInitForServices()
#17 0x557dfcb662f3 ProfileManager::DoFinalInit()
#18 0x557dfcb68093 ProfileManager::AddProfile()
#19 0x557dfcb599f2 ProfileManager::CreateAndInitializeProfile()
#20 0x557dfcb59547 ProfileManager::GetProfile()
#21 0x557e002cda08 GetStartupProfile()
#22 0x557dfc6dd99f (anonymous namespace)::CreatePrimaryProfile()
#23 0x557dfc6db686 ChromeBrowserMainParts::PreMainMessageLoopRunImpl()
#24 0x557dfc6da8ec ChromeBrowserMainParts::PreMainMessageLoopRun()
#25 0x7fbea41181e4 content::BrowserMainLoop::PreMainMessageLoopRun()

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe