Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/media/protected_media_identifier_whitelist.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/strings/string_split.h" | |
| 9 #include "chrome/common/chrome_switches.h" | |
| 10 #include "media/base/media_switches.h" | |
| 11 | |
| 12 ProtectedMediaIdentifierWhitelist::ProtectedMediaIdentifierWhitelist() {} | |
| 13 | |
| 14 ProtectedMediaIdentifierWhitelist::~ProtectedMediaIdentifierWhitelist() {} | |
| 15 | |
| 16 bool ProtectedMediaIdentifierWhitelist::IsOriginWhitelisted( | |
| 17 const GURL& requesting_origin) const { | |
| 18 const base::CommandLine& command_line = | |
| 19 *base::CommandLine::ForCurrentProcess(); | |
| 20 | |
| 21 const std::string userDataDir = | |
| 22 command_line.HasSwitch(switches::kUserDataDir) | |
| 23 ? 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.
| |
| 24 : ""; | |
| 25 | |
| 26 const std::string whitelist = | |
| 27 command_line.HasSwitch( | |
| 28 switches::kDisableInfobarForProtectedMediaIdentifierForDomain) | |
| 29 ? command_line.GetSwitchValueASCII( | |
| 30 switches::kDisableInfobarForProtectedMediaIdentifierForDomain) | |
| 31 : ""; | |
| 32 | |
| 33 bool found = false; | |
| 34 | |
| 35 if (userDataDir != "" && whitelist != "") { | |
| 36 for (const std::string& origin : | |
| 37 base::SplitString(whitelist, ",", base::TRIM_WHITESPACE, | |
| 38 base::SPLIT_WANT_NONEMPTY)) { | |
| 39 found = found || requesting_origin.DomainIs(origin); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 return found; | |
| 44 } | |
|
xhwang
2017/05/04 22:10:59
In Chromium, we like to return early so that reade
| |
| OLD | NEW |