|
16 | 16 | #endif |
17 | 17 | #include <QLoggingCategory> |
18 | 18 |
|
19 | | -static QScopedPointer<QWebEngineProfile> g_profile; |
20 | 19 | static Q_LOGGING_CATEGORY(log, "WebBrowser.Browser") |
21 | 20 | CFrmWebBrowser::CFrmWebBrowser(CParameterWebBrowser *pPara, QWidget *parent) |
22 | 21 | : QWidget{parent} |
@@ -309,40 +308,42 @@ void CFrmWebBrowser::SetConnect(CFrmWebView* pWeb) |
309 | 308 |
|
310 | 309 | QWebEngineProfile* CFrmWebBrowser::GetProfile(bool offTheRecord) |
311 | 310 | { |
312 | | - if (!offTheRecord && !g_profile) { |
| 311 | + if(offTheRecord) |
| 312 | + return QWebEngineProfile::defaultProfile(); |
| 313 | + if(m_profile) |
| 314 | + return m_profile.get(); |
313 | 315 |
|
314 | 316 | #if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0) |
315 | | - const QString name = "io.github.KangLin.RabbitRemoteControl." |
316 | | - + QLatin1StringView(qWebEngineChromiumVersion()); |
317 | | - QWebEngineProfileBuilder profileBuilder; |
318 | | - g_profile.reset(profileBuilder.createProfile(name)); |
| 317 | + const QString name = "io.github.KangLin.RabbitRemoteControl." |
| 318 | + + QLatin1StringView(qWebEngineChromiumVersion()); |
| 319 | + QWebEngineProfileBuilder profileBuilder; |
| 320 | + m_profile.reset(profileBuilder.createProfile(name)); |
319 | 321 | #else |
320 | | - const QString name = "io.github.KangLin.RabbitRemoteControl"; |
321 | | - g_profile.reset(new QWebEngineProfile(name)); |
| 322 | + const QString name = "io.github.KangLin.RabbitRemoteControl"; |
| 323 | + g_profile.reset(new QWebEngineProfile(name)); |
322 | 324 | #endif |
323 | | - if(!g_profile) |
324 | | - return QWebEngineProfile::defaultProfile(); |
325 | | - |
326 | | - g_profile->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); |
327 | | - g_profile->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true); |
328 | | - g_profile->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true); |
329 | | - g_profile->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); |
330 | | - g_profile->settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true); |
331 | | - g_profile->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); |
332 | | - #if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) |
333 | | - g_profile->settings()->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false); |
334 | | - #endif |
335 | | - bool check = connect(g_profile.get(), &QWebEngineProfile::downloadRequested, |
336 | | - &m_DownloadManager, &CFrmDownloadManager::slotDownloadRequested); |
337 | | - Q_ASSERT(check); |
338 | | - qDebug(log) << "User agent:" << g_profile->httpUserAgent() |
339 | | - << "Persistent path:" << g_profile->persistentStoragePath() |
340 | | - << "Cache path:" << g_profile->cachePath() |
341 | | - << "Storage name:" << g_profile->storageName() |
342 | | - << "Is off the Record:" << g_profile->isOffTheRecord() |
343 | | - << "Download:" << g_profile->downloadPath(); |
344 | | - } |
345 | | - return offTheRecord ? QWebEngineProfile::defaultProfile() : g_profile.get(); |
| 325 | + if(!m_profile) |
| 326 | + return QWebEngineProfile::defaultProfile(); |
| 327 | + |
| 328 | + m_profile->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true); |
| 329 | + m_profile->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true); |
| 330 | + m_profile->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true); |
| 331 | + m_profile->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false); |
| 332 | + m_profile->settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true); |
| 333 | + m_profile->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); |
| 334 | +#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) |
| 335 | + m_profile->settings()->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false); |
| 336 | +#endif |
| 337 | + bool check = connect(m_profile.get(), &QWebEngineProfile::downloadRequested, |
| 338 | + &m_DownloadManager, &CFrmDownloadManager::slotDownloadRequested); |
| 339 | + Q_ASSERT(check); |
| 340 | + qDebug(log) << "User agent:" << m_profile->httpUserAgent() |
| 341 | + << "Persistent path:" << m_profile->persistentStoragePath() |
| 342 | + << "Cache path:" << m_profile->cachePath() |
| 343 | + << "Storage name:" << m_profile->storageName() |
| 344 | + << "Is off the Record:" << m_profile->isOffTheRecord() |
| 345 | + << "Download:" << m_profile->downloadPath(); |
| 346 | + return m_profile.get(); |
346 | 347 | } |
347 | 348 |
|
348 | 349 | CFrmWebView *CFrmWebBrowser::CreateWebView(bool offTheRecord) |
|
0 commit comments