0
Files
src/pdf/parsed_params.cc
Arthur Sonzogni 59ac8227c5 Rename {absl => std}::optional in minor top-level dirs
Automated patch, intended to be effectively a no-op.

This patch gather the changes for every top-level directories with less
than 150 files modified:
 #  directory
--- ---------------
150 remoting
98  gpu
87  chromecast
79  mojo
70  storage
65  fuchsia_web
46  sandbox
44  android_webview
38  google_apis
27  pdf
25  printing
20  headless
13  ipc
11  crypto
10  sql
3   dbus
2   testing
2   skia
2   gin
2   apps
1   rlz
1   codelabs

Context:
https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer

As of https://crrev.com/1204351, absl::optional is now a type alias for
std::optional. We should migrate toward it.

Script:
```

function replace {
  echo "Replacing $1 by $2"
  git grep -l "$1" \
		| cut -f1 -d: \
		| grep \
			-e "^codelabs" \
			-e "^rlz" \
			-e "^apps" \
			-e "^gin" \
			-e "^skia" \
			-e "^testing" \
			-e "^dbus" \
			-e "^sql" \
			-e "^crypto" \
			-e "^ipc" \
			-e "^headless" \
			-e "^printing" \
			-e "^pdf" \
			-e "^google_apis" \
			-e "^android_webview" \
			-e "^sandbox" \
			-e "^fuchsia_web" \
			-e "^storage" \
			-e "^mojo" \
			-e "^chromecast" \
			-e "^gpu" \
			-e "^remoting" \
		| sort \
		| uniq \
		| grep \
			-e "\.h" \
			-e "\.cc" \
			-e "\.mm" \
			-e "\.py" \
	  | xargs sed -i "s/$1/$2/g"
}

replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place" "std::in_place"
replace "absl::in_place_t" "std::in_place_t"
replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>"
git cl format
```

CQ_INCLUDE_TRYBOTS=luci.chrome.try:chromeos-betty-pi-arc-chrome

Bug: chromium:1500249
Change-Id: I0eca8ff96f5712ba746ac8d8da93d03a86d8292c
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5009410
Reviewed-by: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1222826}
2023-11-10 09:46:54 +00:00

64 lines
2.2 KiB
C++

// 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.
#include "pdf/parsed_params.h"
#include <string>
#include "base/strings/string_number_conversions.h"
#include "pdf/pdfium/pdfium_form_filler.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_plugin_params.h"
namespace chrome_pdf {
ParsedParams::ParsedParams() = default;
ParsedParams::ParsedParams(const ParsedParams& other) = default;
ParsedParams& ParsedParams::operator=(const ParsedParams& other) = default;
ParsedParams::ParsedParams(ParsedParams&& other) = default;
ParsedParams& ParsedParams::operator=(ParsedParams&& other) = default;
ParsedParams::~ParsedParams() = default;
std::optional<ParsedParams> ParseWebPluginParams(
const blink::WebPluginParams& params) {
ParsedParams result;
for (size_t i = 0; i < params.attribute_names.size(); ++i) {
if (params.attribute_names[i] == "src") {
result.src_url = params.attribute_values[i].Utf8();
} else if (params.attribute_names[i] == "original-url") {
result.original_url = params.attribute_values[i].Utf8();
} else if (params.attribute_names[i] == "top-level-url") {
result.top_level_url = params.attribute_values[i].Utf8();
} else if (params.attribute_names[i] == "full-frame") {
result.full_frame = true;
} else if (params.attribute_names[i] == "background-color") {
if (!base::StringToUint(params.attribute_values[i].Utf8(),
&result.background_color)) {
return std::nullopt;
}
} else if (params.attribute_names[i] == "javascript") {
if (params.attribute_values[i] != "allow")
result.script_option = PDFiumFormFiller::ScriptOption::kNoJavaScript;
} else if (params.attribute_names[i] == "has-edits") {
result.has_edits = true;
} else if (params.attribute_names[i] == "use-skia") {
result.use_skia = true;
}
}
if (result.src_url.empty())
return std::nullopt;
if (result.original_url.empty())
result.original_url = result.src_url;
return result;
}
} // namespace chrome_pdf