Index: chrome/browser/media/protected_media_identifier_whitelist.cc |
diff --git a/chrome/browser/media/protected_media_identifier_whitelist.cc b/chrome/browser/media/protected_media_identifier_whitelist.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b489af6e330c186a7dd2f778bbf510b3fe503874 |
--- /dev/null |
+++ b/chrome/browser/media/protected_media_identifier_whitelist.cc |
@@ -0,0 +1,41 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/media/protected_media_identifier_whitelist.h" |
+ |
+#include "base/command_line.h" |
+#include "base/strings/string_split.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "media/base/media_switches.h" |
+ |
+ProtectedMediaIdentifierWhitelist::ProtectedMediaIdentifierWhitelist() {} |
+ |
+ProtectedMediaIdentifierWhitelist::~ProtectedMediaIdentifierWhitelist() {} |
+ |
+ContentSetting ProtectedMediaIdentifierWhitelist::modifySettingFor( |
+ ContentSetting original, |
+ const GURL& requesting_origin) const { |
+ if (original != CONTENT_SETTING_ASK) { |
+ return original; |
+ } |
+ |
+ const base::CommandLine& command_line = |
+ *base::CommandLine::ForCurrentProcess(); |
+ |
+ if (command_line.HasSwitch(switches::kUserDataDir) && |
+ command_line.HasSwitch( |
+ switches::kDisableInfobarForProtectedMediaIdentifierForDomain)) { |
+ std::string whitelist = command_line.GetSwitchValueASCII( |
+ switches::kDisableInfobarForProtectedMediaIdentifierForDomain); |
+ for (const std::string& origin : |
+ base::SplitString(whitelist, ",", base::TRIM_WHITESPACE, |
+ base::SPLIT_WANT_NONEMPTY)) { |
+ if (requesting_origin.DomainIs(origin)) { |
+ return CONTENT_SETTING_ALLOW; |
+ } |
+ } |
+ } |
+ |
+ return original; |
+} |