Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / common / secure_origin_whitelist.cc
blob3715b3b488d1a622f4df6e5b9b3ca58631bf9b63
1 // Copyright 2015 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.
5 #include "chrome/common/secure_origin_whitelist.h"
7 #include <vector>
9 #include "base/command_line.h"
10 #include "base/strings/string_split.h"
11 #include "chrome/common/chrome_switches.h"
13 void GetSecureOriginWhitelist(std::set<GURL>* origins) {
14 // If kUnsafelyTreatInsecureOriginAsSecure option is given and
15 // kUserDataDir is present, add the given origins as trustworthy
16 // for whitelisting.
17 const base::CommandLine& command_line =
18 *base::CommandLine::ForCurrentProcess();
19 if (command_line.HasSwitch(switches::kUnsafelyTreatInsecureOriginAsSecure) &&
20 command_line.HasSwitch(switches::kUserDataDir)) {
21 std::string origins_str = command_line.GetSwitchValueASCII(
22 switches::kUnsafelyTreatInsecureOriginAsSecure);
23 for (const std::string& origin : base::SplitString(
24 origins_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL))
25 origins->insert(GURL(origin));