parsed_params.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef PDF_PARSED_PARAMS_H_
  5. #define PDF_PARSED_PARAMS_H_
  6. #include <string>
  7. #include "pdf/pdfium/pdfium_form_filler.h"
  8. #include "third_party/abseil-cpp/absl/types/optional.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. namespace blink {
  11. struct WebPluginParams;
  12. } // namespace blink
  13. namespace chrome_pdf {
  14. struct ParsedParams {
  15. ParsedParams();
  16. ParsedParams(const ParsedParams& other);
  17. ParsedParams& operator=(const ParsedParams& other);
  18. ParsedParams(ParsedParams&& other);
  19. ParsedParams& operator=(ParsedParams&& other);
  20. ~ParsedParams();
  21. // The plugin source URL. Must not be empty.
  22. std::string src_url;
  23. // The document original URL. Must not be empty.
  24. std::string original_url;
  25. // The top-level URL.
  26. std::string top_level_url;
  27. // Whether the plugin should occupy the entire frame.
  28. bool full_frame = false;
  29. // The background color for the PDF viewer.
  30. SkColor background_color = SK_ColorTRANSPARENT;
  31. // Whether to execute JavaScript and maybe XFA.
  32. PDFiumFormFiller::ScriptOption script_option =
  33. PDFiumFormFiller::DefaultScriptOption();
  34. // Whether the PDF was edited previously in annotation mode.
  35. bool has_edits = false;
  36. };
  37. // Creates an `ParsedParams` by parsing a `blink::WebPluginParams`. If
  38. // `blink::WebPluginParams` is invalid, returns absl::nullopt.
  39. absl::optional<ParsedParams> ParseWebPluginParams(
  40. const blink::WebPluginParams& params);
  41. } // namespace chrome_pdf
  42. #endif // PDF_PARSED_PARAMS_H_