diff --git a/libcef/browser/alloy/alloy_browser_context.cc b/libcef/browser/alloy/alloy_browser_context.cc index ed619a73a..51ebda2ad 100644 --- a/libcef/browser/alloy/alloy_browser_context.cc +++ b/libcef/browser/alloy/alloy_browser_context.cc @@ -21,6 +21,7 @@ #include "base/logging.h" #include "base/strings/string_util.h" #include "chrome/browser/font_family_cache.h" +#include "chrome/browser/media/media_device_id_salt.h" #include "chrome/browser/plugins/chrome_plugin_service_filter.h" #include "chrome/browser/profiles/profile_key.h" #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" @@ -168,6 +169,8 @@ void AlloyBrowserContext::Initialize() { extension_system_->Init(); ChromePluginServiceFilter::GetInstance()->RegisterProfile(this); + + media_device_id_salt_ = new MediaDeviceIDSalt(pref_service); } void AlloyBrowserContext::Shutdown() { @@ -397,6 +400,10 @@ AlloyBrowserContext::GetBrowsingDataRemoverDelegate() { return nullptr; } +std::string AlloyBrowserContext::GetMediaDeviceIDSalt() { + return media_device_id_salt_->GetSalt(); +} + PrefService* AlloyBrowserContext::GetPrefs() { return pref_service_.get(); } diff --git a/libcef/browser/alloy/alloy_browser_context.h b/libcef/browser/alloy/alloy_browser_context.h index 45c75289d..945808d62 100644 --- a/libcef/browser/alloy/alloy_browser_context.h +++ b/libcef/browser/alloy/alloy_browser_context.h @@ -18,6 +18,7 @@ class CefDownloadManagerDelegate; class CefSSLHostStateDelegate; class CefVisitedLinkListener; +class MediaDeviceIDSalt; class PrefService; namespace extensions { @@ -80,6 +81,7 @@ class AlloyBrowserContext : public ChromeProfileAlloy, content::BackgroundSyncController* GetBackgroundSyncController() override; content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate() override; + std::string GetMediaDeviceIDSalt() override; // Profile overrides. ChromeZoomLevelPrefs* GetZoomLevelPrefs() override; @@ -140,6 +142,8 @@ class AlloyBrowserContext : public ChromeProfileAlloy, std::unique_ptr resource_context_; + scoped_refptr media_device_id_salt_; + DISALLOW_COPY_AND_ASSIGN(AlloyBrowserContext); }; diff --git a/libcef/browser/alloy/alloy_content_browser_client.cc b/libcef/browser/alloy/alloy_content_browser_client.cc index f2e932005..abc5da433 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.cc +++ b/libcef/browser/alloy/alloy_content_browser_client.cc @@ -51,6 +51,7 @@ #include "cef/grit/cef_resources.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_content_browser_client.h" +#include "chrome/browser/content_settings/cookie_settings_factory.h" #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/plugins/plugin_info_host_impl.h" #include "chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.h" @@ -69,6 +70,7 @@ #include "chrome/grit/browser_resources.h" #include "chrome/grit/generated_resources.h" #include "chrome/services/printing/printing_service.h" +#include "components/content_settings/core/browser/cookie_settings.h" #include "components/navigation_interception/intercept_navigation_throttle.h" #include "components/navigation_interception/navigation_params.h" #include "components/spellcheck/common/spellcheck.mojom.h" @@ -1462,6 +1464,17 @@ AlloyContentBrowserClient::GetPluginMimeTypesWithExternalHandlers( return mime_types; } +bool AlloyContentBrowserClient::ArePersistentMediaDeviceIDsAllowed( + content::BrowserContext* browser_context, + const GURL& url, + const GURL& site_for_cookies, + const base::Optional& top_frame_origin) { + // Persistent MediaDevice IDs are allowed if cookies are allowed. + return CookieSettingsFactory::GetForProfile( + Profile::FromBrowserContext(browser_context)) + ->IsCookieAccessAllowed(url, site_for_cookies, top_frame_origin); +} + bool AlloyContentBrowserClient::ShouldAllowPluginCreation( const url::Origin& embedder_origin, const content::PepperPluginInfo& plugin_info) { diff --git a/libcef/browser/alloy/alloy_content_browser_client.h b/libcef/browser/alloy/alloy_content_browser_client.h index 1e8e4828b..a88ce4778 100644 --- a/libcef/browser/alloy/alloy_content_browser_client.h +++ b/libcef/browser/alloy/alloy_content_browser_client.h @@ -206,6 +206,11 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient { blink::UserAgentMetadata GetUserAgentMetadata() override; base::flat_set GetPluginMimeTypesWithExternalHandlers( content::BrowserContext* browser_context) override; + bool ArePersistentMediaDeviceIDsAllowed( + content::BrowserContext* browser_context, + const GURL& scope, + const GURL& site_for_cookies, + const base::Optional& top_frame_origin) override; bool ShouldAllowPluginCreation( const url::Origin& embedder_origin, const content::PepperPluginInfo& plugin_info) override; diff --git a/libcef/browser/prefs/browser_prefs.cc b/libcef/browser/prefs/browser_prefs.cc index a21c63af7..32f4395b5 100644 --- a/libcef/browser/prefs/browser_prefs.cc +++ b/libcef/browser/prefs/browser_prefs.cc @@ -18,6 +18,7 @@ #include "base/values.h" #include "chrome/browser/accessibility/accessibility_ui.h" #include "chrome/browser/download/download_prefs.h" +#include "chrome/browser/media/media_device_id_salt.h" #include "chrome/browser/media/router/media_router_feature.h" #include "chrome/browser/net/prediction_options.h" #include "chrome/browser/net/profile_network_context_service.h" @@ -230,6 +231,7 @@ std::unique_ptr CreatePrefService(Profile* profile, HostContentSettingsMap::RegisterProfilePrefs(registry.get()); language::LanguagePrefs::RegisterProfilePrefs(registry.get()); media_router::RegisterProfilePrefs(registry.get()); + MediaDeviceIDSalt::RegisterProfilePrefs(registry.get()); ProfileNetworkContextService::RegisterProfilePrefs(registry.get()); const std::string& locale =