blob: eb95c848f07f4abddc045839b96c18b46b02ca13 [file] [log] [blame]
// Copyright 2017 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 <memory>
#include <string>
#include "base/macros.h"
#include "content/public/browser/navigation_throttle.h"
namespace content {
class NavigationHandle;
// A FormSubmissionThrottle is responsible for enforcing the 'form-action' CSP
// directive, blocking requests which violate them.
// The form-action CSP is enforced here only for redirects. Blink is enforcing
// it for the initial URL.
// TODO(arthursonzogni): Depending on specification
// clarification, we might be able to delete FormSubmissionThrottle altogether.
// It will be deleted if the final specification clarifies that form-action
// should NOT be enforced on redirects.
class CONTENT_EXPORT FormSubmissionThrottle : public NavigationThrottle {
static std::unique_ptr<NavigationThrottle> MaybeCreateThrottleFor(
NavigationHandle* handle);
~FormSubmissionThrottle() override;
NavigationThrottle::ThrottleCheckResult WillStartRequest() override;
NavigationThrottle::ThrottleCheckResult WillRedirectRequest() override;
const char* GetNameForLogging() override;
explicit FormSubmissionThrottle(NavigationHandle* handle);
NavigationThrottle::ThrottleCheckResult CheckContentSecurityPolicyFormAction(
bool was_server_redirect);
} // namespace content