diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2020-06-19 11:17:50 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-04 18:41:41 +0200 |
commit | 881339e9d9054c46f2621119246de7a13c83761a (patch) | |
tree | 77db7d7188c4ac61cab939c2ccd7a9610d4a01f4 /src/core/profile_adapter.cpp | |
parent | 4d67b9f639114ddec0521980495ba27921800e39 (diff) |
Replace FaviconManager with Chromium's Favicon Component
Task-number: QTBUG-51184
Change-Id: Ie050cb23f2c86841a66ec384bfbcdf0713cffa7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/profile_adapter.cpp')
-rw-r--r-- | src/core/profile_adapter.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index 9a6275a84..204974c28 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -39,6 +39,10 @@ #include "profile_adapter.h" +#include "components/favicon/core/favicon_service.h" +#include "components/history/content/browser/history_database_helper.h" +#include "components/history/core/browser/history_database_params.h" +#include "components/history/core/browser/history_service.h" #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" @@ -51,6 +55,7 @@ #include "api/qwebengineurlscheme.h" #include "content_browser_client_qt.h" #include "download_manager_delegate_qt.h" +#include "favicon_service_factory_qt.h" #include "permission_manager_qt.h" #include "profile_adapter_client.h" #include "profile_io_data_qt.h" @@ -151,6 +156,8 @@ void ProfileAdapter::setStorageName(const QString &storageName) m_profile->m_profileIOData->resetNetworkContext(); if (m_visitedLinksManager) resetVisitedLinksManager(); + + reinitializeHistoryService(); } } @@ -164,6 +171,14 @@ void ProfileAdapter::setOffTheRecord(bool offTheRecord) m_profile->m_profileIOData->resetNetworkContext(); if (m_visitedLinksManager) resetVisitedLinksManager(); + + if (offTheRecord) { + favicon::FaviconService *faviconService = + FaviconServiceFactoryQt::GetForBrowserContext(m_profile.data()); + faviconService->SetHistoryService(nullptr); + } else if (!m_name.isEmpty()) { + reinitializeHistoryService(); + } } ProfileQt *ProfileAdapter::profile() @@ -273,6 +288,9 @@ void ProfileAdapter::setDataPath(const QString &path) m_profile->m_profileIOData->resetNetworkContext(); if (!m_offTheRecord && m_visitedLinksManager) resetVisitedLinksManager(); + + if (!m_offTheRecord) + reinitializeHistoryService(); } void ProfileAdapter::setDownloadPath(const QString &path) @@ -652,6 +670,21 @@ void ProfileAdapter::resetVisitedLinksManager() m_visitedLinksManager.reset(new VisitedLinksManagerQt(m_profile.data(), persistVisitedLinks())); } +void ProfileAdapter::reinitializeHistoryService() +{ + Q_ASSERT(!m_profile->IsOffTheRecord()); + if (m_profile->ensureDirectoryExists()) { + favicon::FaviconService *faviconService = + FaviconServiceFactoryQt::GetForBrowserContext(m_profile.data()); + history::HistoryService *historyService = static_cast<history::HistoryService *>( + HistoryServiceFactoryQt::GetInstance()->GetForBrowserContext(m_profile.data())); + Q_ASSERT(historyService); + faviconService->SetHistoryService(historyService); + } else { + qWarning("Favicon database is not available for this profile."); + } +} + void ProfileAdapter::setUseForGlobalCertificateVerification(bool enable) { if (m_usedForGlobalCertificateVerification == enable) |