chromium/third_party/blink/public/common/page_state/page_state_serialization.h

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

#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_PAGE_STATE_PAGE_STATE_SERIALIZATION_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_PAGE_STATE_PAGE_STATE_SERIALIZATION_H_

#include <stdint.h>

#include <optional>
#include <string>
#include <vector>

#include "build/build_config.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/mojom/referrer_policy.mojom.h"
#include "third_party/blink/public/mojom/page_state/page_state.mojom.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace blink {

constexpr int kMaxScrollAnchorSelectorLength =;

struct BLINK_COMMON_EXPORT ExplodedHttpBody {};

struct BLINK_COMMON_EXPORT ExplodedFrameState {};

struct BLINK_COMMON_EXPORT ExplodedPageState {};

BLINK_COMMON_EXPORT bool DecodePageState(const std::string& encoded,
                                         ExplodedPageState* exploded);
// Similar to |DecodePageState()|, but returns an int indicating the original
// version number of the encoded state. Returns -1 on failure.
BLINK_COMMON_EXPORT int DecodePageStateForTesting(const std::string& encoded,
                                                  ExplodedPageState* exploded);
BLINK_COMMON_EXPORT void EncodePageState(const ExplodedPageState& exploded,
                                         std::string* encoded);
BLINK_COMMON_EXPORT void LegacyEncodePageStateForTesting(
    const ExplodedPageState& exploded,
    int version,
    std::string* encoded);

#if BUILDFLAG(IS_ANDROID)
BLINK_COMMON_EXPORT bool DecodePageStateWithDeviceScaleFactorForTesting(
    const std::string& encoded,
    float device_scale_factor,
    ExplodedPageState* exploded);

// Converts results of EncodeResourceRequestBody (passed in as a pair of |data|
// + |size|) back into a ResourceRequestBody.  Returns nullptr if the
// decoding fails (e.g. if |data| is malformed).
BLINK_COMMON_EXPORT scoped_refptr<network::ResourceRequestBody>
DecodeResourceRequestBody(const char* data, size_t size);

// Encodes |resource_request_body| into |encoded|.
BLINK_COMMON_EXPORT std::string EncodeResourceRequestBody(
    const network::ResourceRequestBody& resource_request_body);
#endif

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_PAGE_STATE_PAGE_STATE_SERIALIZATION_H_