diff options
Diffstat (limited to 'src/browser.cpp')
-rw-r--r-- | src/browser.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 1d09951..d7834f4 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -110,30 +110,13 @@ std::shared_ptr<WebEngineProfile> Browser::profile(const QString storageName) // profile with name storageName has not been loaded Q_ASSERT(m_config); - if(storageName.isEmpty()) { - // construct off-the-record profile - std::shared_ptr<WebEngineProfile> otr = std::make_shared<WebEngineProfile>(nullptr); - otr->setRequestInterceptor(m_urlRequestInterceptor.get()); - connect(otr.get(), &WebEngineProfile::downloadRequested, m_downloadManager.get(), &DownloadsWidget::addDownload); - m_profiles.insert("", otr); - - return otr; - } else { - // regular profile - const QString &path = QString::fromStdString(m_config->value<std::string>("profile.path").value()); - - // Build a profile list from the folders in the profile.path - QDir profileDir(path); - - // set profile parents to nullptr, otherwise both Browser and std::shared_ptr try to free them - std::shared_ptr<WebEngineProfile> profile = std::make_shared<WebEngineProfile>(storageName, profileDir.absoluteFilePath(storageName), nullptr); - profile->setRequestInterceptor(m_urlRequestInterceptor.get()); - connect(profile.get(), &WebEngineProfile::downloadRequested, m_downloadManager.get(), &DownloadsWidget::addDownload); - m_profiles.insert(storageName, profile); - - return profile; - } + const QString &path = QString::fromStdString(m_config->value<std::string>("profile.path").value()); + std::shared_ptr<WebEngineProfile> _profile = std::shared_ptr<WebEngineProfile>(createProfile(storageName, path, nullptr)); + _profile->setRequestInterceptor(m_urlRequestInterceptor.get()); + connect(_profile.get(), &WebEngineProfile::downloadRequested, m_downloadManager.get(), &DownloadsWidget::addDownload); + m_profiles.insert(storageName, _profile); + return _profile; } QStringList Browser::profiles() const |