| // Copyright 2024 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "chrome/browser/android/tab_features.h" |
| |
| #include "chrome/browser/net/qwac_web_contents_observer.h" |
| #include "chrome/browser/preloading/new_tab_page_preload/new_tab_page_preload_pipeline_manager.h" |
| #include "chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h" |
| #include "chrome/browser/sync/sessions/sync_sessions_web_contents_router_factory.h" |
| #include "chrome/browser/translate/chrome_translate_client.h" |
| #include "chrome/browser/ui/contextual_search/tab_contextualization_controller.h" |
| #include "chrome/common/buildflags.h" |
| #include "components/favicon/content/content_favicon_driver.h" |
| #include "components/tabs/public/tab_interface.h" |
| #include "net/base/features.h" |
| #include "ui/base/unowned_user_data/user_data_factory.h" |
| |
| #if BUILDFLAG(ENABLE_GLIC_ANDROID) |
| #include "chrome/browser/glic/public/widget/glic_side_panel_coordinator_android.h" |
| #include "chrome/browser/glic/service/glic_instance_helper.h" |
| #endif |
| |
| namespace tabs { |
| |
| TabFeatures::TabFeatures(content::WebContents* web_contents, Profile* profile) { |
| sync_sessions_router_ = |
| std::make_unique<sync_sessions::SyncSessionsRouterTabHelper>( |
| web_contents, |
| sync_sessions::SyncSessionsWebContentsRouterFactory::GetForProfile( |
| profile), |
| ChromeTranslateClient::FromWebContents(web_contents), |
| favicon::ContentFaviconDriver::FromWebContents(web_contents)); |
| |
| if (base::FeatureList::IsEnabled(net::features::kVerifyQWACs)) { |
| qwac_web_contents_observer_ = |
| std::make_unique<QwacWebContentsObserver>(web_contents); |
| } |
| |
| new_tab_page_preload_pipeline_manager_ = |
| std::make_unique<NewTabPagePreloadPipelineManager>(web_contents); |
| |
| TabInterface* const tab = TabInterface::GetFromContents(web_contents); |
| tab_contextualization_controller_ = |
| GetUserDataFactory().CreateInstance<lens::TabContextualizationController>( |
| *tab, tab); |
| |
| #if BUILDFLAG(ENABLE_GLIC_ANDROID) |
| glic_instance_helper_ = |
| GetUserDataFactory().CreateInstance<glic::GlicInstanceHelper>(*tab, tab); |
| glic_side_panel_coordinator_ = |
| GetUserDataFactory() |
| .CreateInstance<glic::GlicSidePanelCoordinatorAndroid>(*tab, tab); |
| #endif |
| } |
| |
| TabFeatures::~TabFeatures() = default; |
| |
| // static |
| ui::UserDataFactoryWithOwner<TabInterface>& TabFeatures::GetUserDataFactory() { |
| static base::NoDestructor<ui::UserDataFactoryWithOwner<TabInterface>> factory; |
| return *factory; |
| } |
| |
| } // namespace tabs |