chromium/chrome/browser/ui/webui/print_preview/parse_data_path.h

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

#ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PARSE_DATA_PATH_H_
#define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PARSE_DATA_PATH_H_

#include <optional>
#include <string>

namespace printing {

// Result of `ParseDataPath()`.
struct PrintPreviewIdAndPageIndex {};

// Parses a preview PDF data path (i.e., what comes after
// chrome-untrusted://print/).
//
// The format for requesting preview PDF data is as follows:
//   chrome-untrusted://print/<ui_id>/<page_index>/print.pdf
//
// Example:
//   chrome-untrusted://print/123/10/print.pdf
std::optional<PrintPreviewIdAndPageIndex> ParseDataPath(
    const std::string& path);

}  // namespace printing

#endif  // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PARSE_DATA_PATH_H_