Skip to content

Commit

Permalink
UI: Use shared cookie manager for YT Control Panel
Browse files Browse the repository at this point in the history
Use the cookie manager shared by service integration browser docks for
YouTube Control Panel.

This will enable users of the YouTube Chat panel have a better (creator
facing) experience for observed chat message latency, for those users
who sign-in to the YouTube Control Panel or YouTube Live Chat.

NOTE: This commit does not have any migration logic for existing
logged-in users of YTCP, they will need to sign-in again. Based on usage
stats, this is not going to affect a large fraction of OBS users.
  • Loading branch information
msuman-google committed Sep 11, 2024
1 parent b8dd6fe commit e7cfada
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
27 changes: 7 additions & 20 deletions UI/window-dock-youtube-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,13 @@ static constexpr const char *INGESTION_STOPPED = "INGESTION_STOPPED";

YouTubeAppDock::YouTubeAppDock(const QString &title)
: BrowserDock(title),
dockBrowser(nullptr),
cookieManager(nullptr)
dockBrowser(nullptr)
{
cef->init_browser();
OBSBasic::InitBrowserPanelSafeBlock();
AddYouTubeAppDock();
}

YouTubeAppDock::~YouTubeAppDock()
{
if (cookieManager) {
cookieManager->FlushStore();
delete cookieManager;
}
}

bool YouTubeAppDock::IsYTServiceSelected()
{
if (!cef_js_avail)
Expand Down Expand Up @@ -78,9 +69,12 @@ void YouTubeAppDock::SettingsUpdated(bool cleanup)

// definitely cleanup if YT switched off
if (!ytservice || cleanup) {
if (cookieManager)
cookieManager->DeleteCookies("", "");
if (panel_cookies) {
panel_cookies->DeleteCookies("youtube.com", "");
panel_cookies->DeleteCookies("google.com", "");
}
}

if (ytservice)
Update();
}
Expand Down Expand Up @@ -135,16 +129,9 @@ void YouTubeAppDock::AddYouTubeAppDock()

void YouTubeAppDock::CreateBrowserWidget(const std::string &url)
{
std::string dir_name = std::string("obs_profile_cookies_youtube/") +
config_get_string(OBSBasic::Get()->Config(),
"Panels", "CookieId");
if (cookieManager)
delete cookieManager;
cookieManager = cef->create_cookie_manager(dir_name, true);

if (dockBrowser)
delete dockBrowser;
dockBrowser = cef->create_widget(this, url, cookieManager);
dockBrowser = cef->create_widget(this, url, panel_cookies);
if (!dockBrowser)
return;

Expand Down
2 changes: 0 additions & 2 deletions UI/window-dock-youtube-app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class YouTubeAppDock : public BrowserDock {

public:
YouTubeAppDock(const QString &title);
~YouTubeAppDock();

enum streaming_mode_t { YTSM_ACCOUNT, YTSM_STREAM_KEY };

Expand Down Expand Up @@ -49,5 +48,4 @@ class YouTubeAppDock : public BrowserDock {

QString channelId;
QPointer<QCefWidget> dockBrowser;
QCefCookieManager *cookieManager; // is not a Qt object
};

0 comments on commit e7cfada

Please sign in to comment.