Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1623)

Unified Diff: chrome/browser/media/protected_media_identifier_whitelist.cc

Issue 2816773002: Added switch for bypassing protected media identifier permission (Closed)
Patch Set: Added switch for bypassing permissions Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cd65dbbfcbccc665d5c6c1ddcd836e5998d24144
--- /dev/null
+++ b/chrome/browser/media/protected_media_identifier_whitelist.cc
@@ -0,0 +1,44 @@
+// 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() {}
+
+bool ProtectedMediaIdentifierWhitelist::IsOriginWhitelisted(
+ const GURL& requesting_origin) const {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+
+ const std::string userDataDir =
+ command_line.HasSwitch(switches::kUserDataDir)
+ ? command_line.GetSwitchValueASCII(switches::kUserDataDir)
xhwang 2017/05/04 22:10:59 GetSwitchValueASCII() returns empty string when th
Vaage 2017/05/05 16:10:03 Done.
+ : "";
+
+ const std::string whitelist =
+ command_line.HasSwitch(
+ switches::kDisableInfobarForProtectedMediaIdentifierForDomain)
+ ? command_line.GetSwitchValueASCII(
+ switches::kDisableInfobarForProtectedMediaIdentifierForDomain)
+ : "";
+
+ bool found = false;
+
+ if (userDataDir != "" && whitelist != "") {
+ for (const std::string& origin :
+ base::SplitString(whitelist, ",", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY)) {
+ found = found || requesting_origin.DomainIs(origin);
+ }
+ }
+
+ return found;
+}
xhwang 2017/05/04 22:10:59 In Chromium, we like to return early so that reade

Powered by Google App Engine
This is Rietveld 408576698