Posts

Showing posts with the label chromium-extensions

chromium : extensions, how a extension list on web store was installed to chrome

Image
If you find a liked extension on chrome web store , you can install it just by simple click the "ADD TO CHROME" button. Let's go deep into chromium codes, and see how it happened. The key module is chrome.webstore, which a buildin JS object in chrome. chrome/renderer/extensions/webstore_bindings.cc chrome/renderer/extensions/webstore_bindings.h   WebstoreBindings::Install TabHelper::DoInlineInstall WebstoreInlineInstaller::BeginInstall WebstoreStandaloneInstaller::ProceedWithInstallPrompt ShowInstallUI   show install prompt dialog WebstoreStandaloneInstaller::ProceedWithInstallPrompt NavigationObserver::OnInstallPromptDone ExtensionService::EnableExtension ExtensionRegistrar::EnableExtension

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::IsHandled

chromium : extensions, how content scripts get executed

extensions::Dispatcher::RunScriptsAtDocumentEnd #2 0x5595477272c3 extensions::Dispatcher::RunScriptsAtDocumentEnd() #3 0x55954c42bb3c ChromeExtensionsRendererClient::RunScriptsAtDocumentEnd() #4 0x55954c382721 ChromeContentRendererClient::RunScriptsAtDocumentEnd() #5 0x7ff32f28b88c content::RenderFrameImpl::RunScriptsAtDocumentReady() #6 0x7ff3226b9739 blink::LocalFrameClientImpl::RunScriptsAtDocumentReady() #7 0x7ff322f6de36 blink::FrameLoader::FinishedParsing() #8 0x7ff32239b40b blink::Document::FinishedParsing() #9 0x7ff323a6a773 blink::HTMLConstructionSite::FinishedParsing() #10 0x7ff323adf2d7 blink::HTMLTreeBuilder::Finished() #11 0x7ff323a7e316 blink::HTMLDocumentParser::end() #12 0x7ff323a74c7f blink::HTMLDocumentParser::AttemptToRunDeferredScriptsAndEnd() #13 0x7ff323a749a6 blink::HTMLDocumentParser::PrepareToStopParsing() #14 0x7ff323a7a9cc blink::HTMLDocumentParser::ProcessTokenizedChunkFromBackgroundParser() #15 0x7ff323a7657d blink::HTMLDocumentParser::P

chromium : how extension install prompt dialog get showed

Image
  #2 0x5589ca9aaeba ExtensionInstallPrompt::ShowDialog() #3 0x5589ca9aac7c ExtensionInstallPrompt::ShowDialog() #4 0x5589ca9aa96e ExtensionInstallPrompt::ShowDialog() #5 0x5589cb168cca extensions::WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess() #6 0x5589cab3821b extensions::WebstoreInstallHelper::ReportResultsIfComplete() #7 0x5589cab37efd extensions::WebstoreInstallHelper::OnFetchComplete() #8 0x5589c85da07b chrome::BitmapFetcher::OnImageDecoded() #9 0x5589c85dc1d1 ImageDecoder::OnDecodeImageSucceeded() #10 0x5589c7303c4f _ZN4base8internal13FunctorTraitsIMN10extensions8internal26ScopedCallbackRunnerHelperIFvRKNSt3__16vectorIhNS5_9allocatorIhEEEEN6device5mojom18SerialReceiveErrorEEEEFvSB_SE_EvE6InvokeIPSG_JS9_SE_EEEvSI_OT_DpOT0_ #11 0x5589c7303baa _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN10extensions8internal26ScopedCallbackRunnerHelperIFvRKNSt3__16vectorIhNS7_9allocatorIhEEEEN6device5mojom18SerialReceiveErrorEEEEFvSD_SG_EJPSI_SB_SG_EEEvOT_DpOT0_

chromium : extensions load back trace

#2 0x55c01d36db9d extensions::ExtensionRegistry::AddEnabled() #3 0x55c01d3696cf extensions::ExtensionRegistrar::AddExtension() #4 0x55c020eda0f6 ExtensionService::AddExtension() #5 0x55c020f7e344 extensions::InstalledLoader::Load() #6 0x55c020f7f31b extensions::InstalledLoader::LoadAllExtensions() #7 0x55c020ed12e5 ExtensionService::Init() #8 0x55c020f10a82 extensions::ExtensionSystemImpl::Shared::Init() #9 0x55c020f11462 extensions::ExtensionSystemImpl::InitForRegularProfile() #10 0x55c01eb6419a ProfileManager::DoFinalInitForServices() #11 0x55c01eb63fd3 ProfileManager::DoFinalInit() #12 0x55c01eb65d73 ProfileManager::AddProfile() #13 0x55c01eb576d2 ProfileManager::CreateAndInitializeProfile() #14 0x55c01eb57227 ProfileManager::GetProfile() #15 0x55c0222cb5f8 GetStartupProfile() #16 0x55c01e6db67f (anonymous namespace)::CreatePrimaryProfile() #17 0x55c01e6d9366 ChromeBrowserMainParts::PreMainMessageLoopRunImpl() #18 0x55c01e6d85cc ChromeBrowserMainParts::PreMainMessageLoopRun() #19 0

chromium : How KeyedService was created

DependencyManager::CreateContextServices void DependencyManager::CreateContextServices(base::SupportsUserData* context, bool is_testing_context) { MarkContextLive(context); std::vector<DependencyNode*> construction_order; if (!dependency_graph_.GetConstructionOrder(&construction_order)) { NOTREACHED(); } #ifndef NDEBUG DumpContextDependencies(context); #endif for (auto* dependency_node : construction_order) { KeyedServiceBaseFactory* factory = static_cast<KeyedServiceBaseFactory*>(dependency_node); if (is_testing_context && factory->ServiceIsNULLWhileTesting() && !factory->HasTestingFactory(context)) { factory->SetEmptyTestingFactory(context); } else if (factory->ServiceIsCreatedWithContext()) { factory->CreateServiceNow(context); } } }   #14 0x7f08ec0395de DependencyManager::CreateContextServices() #15 0x7f0

chromium : extensions UI(chrome://extensions) create back trace

#2 0x561c61ba4b95 (anonymous namespace)::GetWebUIFactoryFunction() #3 0x561c61ba35b2 ChromeWebUIControllerFactory::GetWebUIType() #4 0x561c61ba5962 ChromeWebUIControllerFactory::UseWebUIForURL() #5 0x7fe6df4aa299 content::WebUIControllerFactoryRegistry::UseWebUIForURL() #6 0x7fe6df4aa3f5 content::WebUIControllerFactoryRegistry::IsURLAcceptableForWebUI() #7 0x7fe6df4b2147 content::WebUIImpl::OnWebUISend() #8 0x7fe6df4b59ef _ZN3IPC20DispatchToMethodImplIN7content9WebUIImplEMS2_FvPNS1_15RenderFrameHostERK4GURLRKNSt3__112basic_stringIcNS8_11char_traitsIcEENS8_9allocatorIcEEEERKN4base9ListValueEES3_NS8_5tupleIJS5_SE_SI_EEEJLm0ELm1ELm2EEEEvPT_T0_PT1_OT2_NS8_16integer_sequenceImJXspT3_EEEE #9 0x7fe6df4b58d0 _ZN3IPC16DispatchToMethodIN7content9WebUIImplENS1_15RenderFrameHostEJRK4GURLRKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKN4base9ListValueEENS7_5tupleIJS4_SD_SH_EEEEENS7_9enable_ifIXeqsZT1_sr3std10tuple_sizeINS7_5decayIT2_E4typeEEE5valueEvE4typeEPT_MST_FvPT0_DpT1_ESW

chromium : extensions RendererStartupHelper InitializeProcess back trace

#2 0x561c5ce30032 extensions::RendererStartupHelper::InitializeProcess() #3 0x561c5ce2f331 extensions::RendererStartupHelper::Observe() #4 0x7fe6def2a33f content::NotificationServiceImpl::Notify() #5 0x7fe6df12ebac content::RenderProcessHostImpl::OnProcessLaunched() #6 0x7fe6de83aebc content::ChildProcessLauncher::Notify() #7 0x7fe6de83da40 content::internal::ChildProcessLauncherHelper::PostLaunchOnClientThread() #8 0x7fe6de83e529 _ZN4base8internal13FunctorTraitsIMN7content8internal26ChildProcessLauncherHelperEFvNS4_7ProcessEiEvE6InvokeI13scoped_refptrIS4_EJS5_iEEEvS7_OT_DpOT0_ #9 0x7fe6de83e43a _ZN4base8internal12InvokeHelperILb0EvE8MakeItSoIMN7content8internal26ChildProcessLauncherHelperEFvNS6_7ProcessEiEJ13scoped_refptrIS6_ES7_iEEEvOT_DpOT0_ #10 0x7fe6de83e3a3 _ZN4base8internal7InvokerINS0_9BindStateIMN7content8internal26ChildProcessLauncherHelperEFvNS5_7ProcessEiEJ13scoped_refptrIS5_ENS0_13PassedWrapperIS6_EEiEEEFvvEE7RunImplIS8_NSt3__15tupleIJSA_SC_iEEEJLm0ELm1ELm2EEEEvOT_OT0_NSH_

chromium : extensions::Extension construction back trace in Browser process

#2 0x55aaedfdafa6 extensions::Extension::Create() #3 0x55aaedfdaf22 extensions::Extension::Create() #4 0x55aaeec372eb extensions::ComponentLoader::CreateExtension() #5 0x55aaeec34321 extensions::ComponentLoader::Load() #6 0x55aaeec34100 extensions::ComponentLoader::LoadAll() #7 0x55aaeecc028c ExtensionService::Init() #8 0x55aaeecffa72 extensions::ExtensionSystemImpl::Shared::Init() #9 0x55aaeed00452 extensions::ExtensionSystemImpl::InitForRegularProfile() #10 0x55aaec95317a ProfileManager::DoFinalInitForServices() #11 0x55aaec952fb3 ProfileManager::DoFinalInit() #12 0x55aaec954d53 ProfileManager::AddProfile() #13 0x55aaec9466b2 ProfileManager::CreateAndInitializeProfile() #14 0x55aaec946207 ProfileManager::GetProfile() #15 0x55aaf00ba618 GetStartupProfile() #16 0x55aaec4ca65f (anonymous namespace)::CreatePrimaryProfile() #17 0x55aaec4c8346 ChromeBrowserMainParts::PreMainMessageLoopRunImpl() #18 0x55aaec4c75ac ChromeBrowserMainParts::PreMainMessageLoopRun() #19 0x7f1d0223d1e4 content::B

chromium : extensions::Extension construction back trace in Render process

extensions/renderer/dispatcher.cc extensions::Dispatcher receive ExtensionMsg_Loaded from extensions/browser/renderer_startup_helper.cc RendererStartupHelper::InitializeProcess // Loaded extensions. std::vector<ExtensionMsg_Loaded_Params> loaded_extensions; BrowserContext* renderer_context = process->GetBrowserContext(); const ExtensionSet& extensions = ExtensionRegistry::Get(browser_context_)->enabled_extensions(); for (const auto& ext : extensions) { // OnLoadedExtension should have already been called for the extension. DCHECK(base::ContainsKey(extension_process_map_, ext->id())); DCHECK(!base::ContainsKey(extension_process_map_[ext->id()], process)); if (!IsExtensionVisibleToContext(*ext, renderer_context)) continue; // TODO(kalman): Only include tab specific permissions for extension // processes, no other process needs it, so it's mildly wasteful. // I am not sure this is possible to know this