chromium/content/public/test/web_ui_browsertest_util.h

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_TEST_WEB_UI_BROWSERTEST_UTIL_H_
#define CONTENT_PUBLIC_TEST_WEB_UI_BROWSERTEST_UTIL_H_

#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>

#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/browser/webui_config.h"
#include "content/public/common/bindings_policy.h"
#include "services/network/public/mojom/cross_origin_opener_policy.mojom.h"

namespace content {

struct TestUntrustedDataSourceHeaders {};

// Adds a DataSource for chrome-untrusted://|host| URLs.
void AddUntrustedDataSource(
    BrowserContext* browser_context,
    const std::string& host,
    std::optional<TestUntrustedDataSourceHeaders> headers = std::nullopt);

// Returns chrome-untrusted://|host_and_path| as a GURL.
GURL GetChromeUntrustedUIURL(const std::string& host_and_path);

class TestWebUIConfig : public content::WebUIConfig {};

// Returns WebUIControllers whose CSPs and headers can be controlled through
// query parameters.
// - "bindings" controls the bindings e.g. Mojo, chrome.send() or both, with
//   which the WebUIController will be created.
// - "noxfo" controls whether the "X-Frame-Options: DENY" header, which is
//   added by default, will be removed. Set to true to remove the header.
// - "childsrc" controls the child-src CSP. It's value is
//   "child-src 'self' chrome://web-ui-subframe/;" by default.
class TestWebUIControllerFactory : public WebUIControllerFactory {};

}  // namespace content

#endif  // CONTENT_PUBLIC_TEST_WEB_UI_BROWSERTEST_UTIL_H_