summaryrefslogtreecommitdiffstats
path: root/chromium/components/aggregation_service/parsing_utils.cc
blob: 27ea0dd6028ec979f3f56b24708f9f75463309e5 (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
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/aggregation_service/parsing_utils.h"

#include <string>

#include "components/aggregation_service/aggregation_coordinator_utils.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace aggregation_service {

absl::optional<url::Origin> ParseAggregationCoordinator(
    const std::string& str) {
  auto origin = url::Origin::Create(GURL(str));
  if (IsAggregationCoordinatorOriginAllowed(origin)) {
    return origin;
  }
  return absl::nullopt;
}

}  // namespace aggregation_service