summaryrefslogtreecommitdiffstats
path: root/chrome/common/secure_origin_whitelist.cc
blob: 030151272b9d090e16cfa72953b54621d53c60f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2015 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/common/secure_origin_whitelist.h"

#include <vector>

#include "base/command_line.h"
#include "base/strings/string_split.h"
#include "chrome/common/chrome_switches.h"
#include "extensions/common/constants.h"

void GetSecureOriginWhitelist(std::set<GURL>* origins) {
  // If kUnsafelyTreatInsecureOriginAsSecure option is given and
  // kUserDataDir is present, add the given origins as trustworthy
  // for whitelisting.
  const base::CommandLine& command_line =
      *base::CommandLine::ForCurrentProcess();
  if (command_line.HasSwitch(switches::kUnsafelyTreatInsecureOriginAsSecure) &&
      command_line.HasSwitch(switches::kUserDataDir)) {
    std::string origins_str = command_line.GetSwitchValueASCII(
        switches::kUnsafelyTreatInsecureOriginAsSecure);
    for (const std::string& origin : base::SplitString(
             origins_str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL))
      origins->insert(GURL(origin));
  }
}

void GetSchemesBypassingSecureContextCheckWhitelist(
    std::set<std::string>* schemes) {
  schemes->insert(extensions::kExtensionScheme);
}