0
Files
src/content/browser/utility_sandbox_delegate.h
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

86 lines
2.8 KiB
C++

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_UTILITY_SANDBOX_DELEGATE_H_
#define CONTENT_BROWSER_UTILITY_SANDBOX_DELEGATE_H_
#include <optional>
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "build/build_config.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "content/public/common/zygote/zygote_buildflags.h"
#include "sandbox/policy/mojom/sandbox.mojom.h"
#if BUILDFLAG(USE_ZYGOTE)
#include "content/public/common/zygote/zygote_handle.h"
#endif // BUILDFLAG(USE_ZYGOTE)
#if BUILDFLAG(IS_WIN)
#include "sandbox/win/src/sandbox_policy.h"
#endif // BUILDFLAG(IS_WIN)
namespace content {
class UtilitySandboxedProcessLauncherDelegate
: public SandboxedProcessLauncherDelegate {
public:
UtilitySandboxedProcessLauncherDelegate(sandbox::mojom::Sandbox sandbox_type,
const base::EnvironmentMap& env,
const base::CommandLine& cmd_line);
~UtilitySandboxedProcessLauncherDelegate() override;
sandbox::mojom::Sandbox GetSandboxType() override;
#if BUILDFLAG(IS_WIN)
std::string GetSandboxTag() override;
bool GetAppContainerId(std::string* appcontainer_id) override;
bool DisableDefaultPolicy() override;
bool ShouldLaunchElevated() override;
bool InitializeConfig(sandbox::TargetConfig* config) override;
bool ShouldUnsandboxedRunInJob() override;
bool CetCompatible() override;
bool AllowWindowsFontsDir() override;
bool PreSpawnTarget(sandbox::TargetPolicy* policy) override;
// Set preload libraries to transfer as part of the sandbox delegate data,
// which will used in utility_main to preload these libraries before lockdown.
void SetPreloadLibraries(const std::vector<base::FilePath>& preloads) {
preload_libraries_ = preloads;
}
void SetPinUser32() { pin_user32_ = true; }
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(USE_ZYGOTE)
ZygoteCommunication* GetZygote() override;
#endif // BUILDFLAG(USE_ZYGOTE)
#if BUILDFLAG(IS_POSIX)
base::EnvironmentMap GetEnvironment() override;
#endif // BUILDFLAG(IS_POSIX)
#if BUILDFLAG(USE_ZYGOTE)
void SetZygote(ZygoteCommunication* handle);
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
private:
#if BUILDFLAG(IS_POSIX)
base::EnvironmentMap env_;
#endif // BUILDFLAG(IS_POSIX)
#if BUILDFLAG(IS_WIN)
std::vector<base::FilePath> preload_libraries_;
bool pin_user32_;
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(USE_ZYGOTE)
std::optional<raw_ptr<ZygoteCommunication>> zygote_;
#endif // BUILDFLAG(USE_ZYGOTE)
sandbox::mojom::Sandbox sandbox_type_;
base::CommandLine cmd_line_;
};
} // namespace content
#endif // CONTENT_BROWSER_UTILITY_SANDBOX_DELEGATE_H_