Index: chrome/browser/media/protected_media_identifier_permission_context.cc |
diff --git a/chrome/browser/media/protected_media_identifier_permission_context.cc b/chrome/browser/media/protected_media_identifier_permission_context.cc |
index 50c2dc51ec53a1f4269eff81c038c44fc6eb40bc..ffae1696a75a9bdc90840990b21ba3623ab69d0d 100644 |
--- a/chrome/browser/media/protected_media_identifier_permission_context.cc |
+++ b/chrome/browser/media/protected_media_identifier_permission_context.cc |
@@ -6,15 +6,19 @@ |
#include "base/command_line.h" |
#include "base/metrics/user_metrics.h" |
+#include "base/strings/string_split.h" |
#include "build/build_config.h" |
#include "chrome/browser/content_settings/tab_specific_content_settings.h" |
#include "chrome/browser/permissions/permission_util.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
#include "components/prefs/pref_service.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/render_frame_host.h" |
#include "content/public/browser/web_contents.h" |
+#include "media/base/media_switches.h" |
+#include "net/base/url_util.h" |
#if defined(OS_CHROMEOS) |
#include <utility> |
@@ -101,9 +105,39 @@ ProtectedMediaIdentifierPermissionContext::GetPermissionStatusInternal( |
content_setting == CONTENT_SETTING_BLOCK || |
content_setting == CONTENT_SETTING_ASK); |
+ // For automated testing of protected content - having a prompt that |
+ // requires user intervention is problematic. If the domain has been |
+ // whitelisted as safe - suppress the request and allow. |
+ if (content_setting == CONTENT_SETTING_ASK && |
+ IsDomainWhitelisted(requesting_origin)) { |
+ content_setting = CONTENT_SETTING_ALLOW; |
+ } |
+ |
return content_setting; |
} |
+bool ProtectedMediaIdentifierPermissionContext::IsDomainWhitelisted( |
+ const GURL& requesting_domain) { |
xhwang
2017/05/08 17:21:37
This should still be "origin" (see the callsite).
Vaage
2017/05/08 18:10:36
Done.
|
+ const base::CommandLine& command_line = |
+ *base::CommandLine::ForCurrentProcess(); |
+ |
+ if (command_line.GetSwitchValueASCII(switches::kUserDataDir).empty()) { |
+ return false; |
+ } |
+ |
+ const std::string whitelist = command_line.GetSwitchValueASCII( |
+ switches::kDisableInfobarForProtectedMediaIdentifierForDomain); |
+ |
+ for (const std::string& domain : base::SplitString( |
+ whitelist, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) { |
+ if (requesting_domain.DomainIs(domain)) { |
+ return true; |
+ } |
+ } |
+ |
+ return false; |
+} |
+ |
void ProtectedMediaIdentifierPermissionContext::CancelPermissionRequest( |
content::WebContents* web_contents, |
const PermissionRequestID& id) { |