chore: replace absl::optional<T> with std::optional<T> (#40928)
* chore: replace absl::optional<T> with std::optional<T> * IWYU
This commit is contained in:
parent
fac964ac0d
commit
892c9d78a3
129 changed files with 419 additions and 397 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "shell/browser/api/electron_api_app.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -75,7 +76,6 @@
|
|||
#include "shell/common/platform_util.h"
|
||||
#include "shell/common/thread_restrictions.h"
|
||||
#include "shell/common/v8_value_serializer.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
@ -927,7 +927,7 @@ void App::SetAppPath(const base::FilePath& app_path) {
|
|||
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
|
||||
absl::optional<base::FilePath> custom_path) {
|
||||
std::optional<base::FilePath> custom_path) {
|
||||
if (custom_path.has_value()) {
|
||||
if (!custom_path->IsAbsolute()) {
|
||||
thrower.ThrowError("Path must be absolute");
|
||||
|
@ -1604,7 +1604,7 @@ void ConfigureHostResolver(v8::Isolate* isolate,
|
|||
// doh_config.
|
||||
std::vector<net::DnsOverHttpsServerConfig> servers;
|
||||
for (const std::string& server_template : secure_dns_server_strings) {
|
||||
absl::optional<net::DnsOverHttpsServerConfig> server_config =
|
||||
std::optional<net::DnsOverHttpsServerConfig> server_config =
|
||||
net::DnsOverHttpsServerConfig::FromString(server_template);
|
||||
if (!server_config.has_value()) {
|
||||
thrower.ThrowTypeError(std::string("not a valid DoH template: ") +
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_APP_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -180,7 +181,7 @@ class App : public ElectronBrowserClient::Delegate,
|
|||
void ChildProcessDisconnected(int pid);
|
||||
|
||||
void SetAppLogsPath(gin_helper::ErrorThrower thrower,
|
||||
absl::optional<base::FilePath> custom_path);
|
||||
std::optional<base::FilePath> custom_path);
|
||||
|
||||
// Get/Set the pre-defined path in PathService.
|
||||
base::FilePath GetPath(gin_helper::ErrorThrower thrower,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace electron::api {
|
||||
|
||||
void App::SetAppLogsPath(gin_helper::ErrorThrower thrower,
|
||||
absl::optional<base::FilePath> custom_path) {
|
||||
std::optional<base::FilePath> custom_path) {
|
||||
if (custom_path.has_value()) {
|
||||
if (!custom_path->IsAbsolute()) {
|
||||
thrower.ThrowError("Path must be absolute");
|
||||
|
|
|
@ -826,11 +826,11 @@ bool BaseWindow::GetWindowButtonVisibility() const {
|
|||
return window_->GetWindowButtonVisibility();
|
||||
}
|
||||
|
||||
void BaseWindow::SetWindowButtonPosition(absl::optional<gfx::Point> position) {
|
||||
void BaseWindow::SetWindowButtonPosition(std::optional<gfx::Point> position) {
|
||||
window_->SetWindowButtonPosition(std::move(position));
|
||||
}
|
||||
|
||||
absl::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const {
|
||||
std::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const {
|
||||
return window_->GetWindowButtonPosition();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -187,8 +188,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
|||
std::string GetAlwaysOnTopLevel() const;
|
||||
void SetWindowButtonVisibility(bool visible);
|
||||
bool GetWindowButtonVisibility() const;
|
||||
void SetWindowButtonPosition(absl::optional<gfx::Point> position);
|
||||
absl::optional<gfx::Point> GetWindowButtonPosition() const;
|
||||
void SetWindowButtonPosition(std::optional<gfx::Point> position);
|
||||
std::optional<gfx::Point> GetWindowButtonPosition() const;
|
||||
|
||||
bool IsHiddenInMissionControl();
|
||||
void SetHiddenInMissionControl(bool hidden);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/promise.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
using content::TracingController;
|
||||
|
||||
|
@ -58,18 +58,18 @@ namespace {
|
|||
|
||||
using CompletionCallback = base::OnceCallback<void(const base::FilePath&)>;
|
||||
|
||||
absl::optional<base::FilePath> CreateTemporaryFileOnIO() {
|
||||
std::optional<base::FilePath> CreateTemporaryFileOnIO() {
|
||||
base::FilePath temp_file_path;
|
||||
if (!base::CreateTemporaryFile(&temp_file_path))
|
||||
return absl::nullopt;
|
||||
return absl::make_optional(std::move(temp_file_path));
|
||||
return std::nullopt;
|
||||
return std::make_optional(std::move(temp_file_path));
|
||||
}
|
||||
|
||||
void StopTracing(gin_helper::Promise<base::FilePath> promise,
|
||||
absl::optional<base::FilePath> file_path) {
|
||||
std::optional<base::FilePath> file_path) {
|
||||
auto resolve_or_reject = base::BindOnce(
|
||||
[](gin_helper::Promise<base::FilePath> promise,
|
||||
const base::FilePath& path, absl::optional<std::string> error) {
|
||||
const base::FilePath& path, std::optional<std::string> error) {
|
||||
if (error) {
|
||||
promise.RejectWithErrorMessage(error.value());
|
||||
} else {
|
||||
|
@ -81,20 +81,20 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise,
|
|||
auto* instance = TracingController::GetInstance();
|
||||
if (!instance->IsTracing()) {
|
||||
std::move(resolve_or_reject)
|
||||
.Run(absl::make_optional(
|
||||
.Run(std::make_optional(
|
||||
"Failed to stop tracing - no trace in progress"));
|
||||
} else if (file_path) {
|
||||
auto split_callback = base::SplitOnceCallback(std::move(resolve_or_reject));
|
||||
auto endpoint = TracingController::CreateFileEndpoint(
|
||||
*file_path,
|
||||
base::BindOnce(std::move(split_callback.first), absl::nullopt));
|
||||
base::BindOnce(std::move(split_callback.first), std::nullopt));
|
||||
if (!instance->StopTracing(endpoint)) {
|
||||
std::move(split_callback.second)
|
||||
.Run(absl::make_optional("Failed to stop tracing"));
|
||||
.Run(std::make_optional("Failed to stop tracing"));
|
||||
}
|
||||
} else {
|
||||
std::move(resolve_or_reject)
|
||||
.Run(absl::make_optional(
|
||||
.Run(std::make_optional(
|
||||
"Failed to create temporary file for trace data"));
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) {
|
|||
|
||||
base::FilePath path;
|
||||
if (args->GetNext(&path) && !path.empty()) {
|
||||
StopTracing(std::move(promise), absl::make_optional(path));
|
||||
StopTracing(std::move(promise), std::make_optional(path));
|
||||
} else {
|
||||
// use a temporary file.
|
||||
base::ThreadPool::PostTaskAndReplyWithResult(
|
||||
|
|
|
@ -127,13 +127,13 @@ bool MatchesCookie(const base::Value::Dict& filter,
|
|||
if ((str = filter.FindString("domain")) &&
|
||||
!MatchesDomain(*str, cookie.Domain()))
|
||||
return false;
|
||||
absl::optional<bool> secure_filter = filter.FindBool("secure");
|
||||
std::optional<bool> secure_filter = filter.FindBool("secure");
|
||||
if (secure_filter && *secure_filter != cookie.IsSecure())
|
||||
return false;
|
||||
absl::optional<bool> session_filter = filter.FindBool("session");
|
||||
std::optional<bool> session_filter = filter.FindBool("session");
|
||||
if (session_filter && *session_filter == cookie.IsPersistent())
|
||||
return false;
|
||||
absl::optional<bool> httpOnly_filter = filter.FindBool("httpOnly");
|
||||
std::optional<bool> httpOnly_filter = filter.FindBool("httpOnly");
|
||||
if (httpOnly_filter && *httpOnly_filter != cookie.IsHttpOnly())
|
||||
return false;
|
||||
return true;
|
||||
|
@ -161,7 +161,7 @@ void FilterCookieWithStatuses(
|
|||
}
|
||||
|
||||
// Parse dictionary property to CanonicalCookie time correctly.
|
||||
base::Time ParseTimeProperty(const absl::optional<double>& value) {
|
||||
base::Time ParseTimeProperty(const std::optional<double>& value) {
|
||||
if (!value) // empty time means ignoring the parameter
|
||||
return base::Time();
|
||||
if (*value == 0) // FromSecondsSinceUnixEpoch would convert 0 to empty Time
|
||||
|
@ -321,7 +321,7 @@ v8::Local<v8::Promise> Cookies::Set(v8::Isolate* isolate,
|
|||
path ? *path : "", ParseTimeProperty(details.FindDouble("creationDate")),
|
||||
ParseTimeProperty(details.FindDouble("expirationDate")),
|
||||
ParseTimeProperty(details.FindDouble("lastAccessDate")), secure,
|
||||
http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, absl::nullopt,
|
||||
http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, std::nullopt,
|
||||
&status);
|
||||
|
||||
if (!canonical_cookie || !canonical_cookie->IsCanonical()) {
|
||||
|
|
|
@ -44,12 +44,12 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
|||
|
||||
base::StringPiece message_str(reinterpret_cast<const char*>(message.data()),
|
||||
message.size());
|
||||
absl::optional<base::Value> parsed_message = base::JSONReader::Read(
|
||||
std::optional<base::Value> parsed_message = base::JSONReader::Read(
|
||||
message_str, base::JSON_REPLACE_INVALID_CHARACTERS);
|
||||
if (!parsed_message || !parsed_message->is_dict())
|
||||
return;
|
||||
base::Value::Dict& dict = parsed_message->GetDict();
|
||||
absl::optional<int> id = dict.FindInt("id");
|
||||
std::optional<int> id = dict.FindInt("id");
|
||||
if (!id) {
|
||||
std::string* method = dict.FindString("method");
|
||||
if (!method)
|
||||
|
|
|
@ -25,7 +25,7 @@ static NSMenu* __strong applicationMenu_;
|
|||
ui::Accelerator GetAcceleratorFromKeyEquivalentAndModifierMask(
|
||||
NSString* key_equivalent,
|
||||
NSUInteger modifier_mask) {
|
||||
absl::optional<char16_t> shifted_char;
|
||||
std::optional<char16_t> shifted_char;
|
||||
ui::KeyboardCode code = electron::KeyboardCodeFromStr(
|
||||
base::SysNSStringToUTF8(key_equivalent), &shifted_char);
|
||||
int modifiers = 0;
|
||||
|
|
|
@ -125,7 +125,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
|||
}
|
||||
|
||||
pending_start_promise_ =
|
||||
absl::make_optional<gin_helper::Promise<void>>(args->isolate());
|
||||
std::make_optional<gin_helper::Promise<void>>(args->isolate());
|
||||
v8::Local<v8::Promise> handle = pending_start_promise_->GetHandle();
|
||||
|
||||
auto command_line_string =
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
|
||||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
|
@ -16,7 +18,6 @@
|
|||
#include "net/log/net_log_capture_mode.h"
|
||||
#include "services/network/public/mojom/net_log.mojom.h"
|
||||
#include "shell/common/gin_helper/promise.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
namespace gin {
|
||||
class Arguments;
|
||||
|
@ -67,7 +68,7 @@ class NetLog : public gin::Wrappable<NetLog> {
|
|||
|
||||
mojo::Remote<network::mojom::NetLogExporter> net_log_exporter_;
|
||||
|
||||
absl::optional<gin_helper::Promise<void>> pending_start_promise_;
|
||||
std::optional<gin_helper::Promise<void>> pending_start_promise_;
|
||||
|
||||
scoped_refptr<base::TaskRunner> file_task_runner_;
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
|||
url_chain, GURL(),
|
||||
content::StoragePartitionConfig::CreateDefault(
|
||||
download_manager->GetBrowserContext()),
|
||||
GURL(), GURL(), absl::nullopt, mime_type, mime_type, start_time,
|
||||
GURL(), GURL(), std::nullopt, mime_type, mime_type, start_time,
|
||||
base::Time(), etag, last_modified, offset, length, std::string(),
|
||||
download::DownloadItem::INTERRUPTED,
|
||||
download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||
|
@ -432,7 +432,7 @@ v8::Local<v8::Promise> Session::ResolveProxy(gin::Arguments* args) {
|
|||
|
||||
v8::Local<v8::Promise> Session::ResolveHost(
|
||||
std::string host,
|
||||
absl::optional<network::mojom::ResolveHostParametersPtr> params) {
|
||||
std::optional<network::mojom::ResolveHostParametersPtr> params) {
|
||||
gin_helper::Promise<gin_helper::Dictionary> promise(isolate_);
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
|
@ -441,7 +441,7 @@ v8::Local<v8::Promise> Session::ResolveHost(
|
|||
params ? std::move(params.value()) : nullptr,
|
||||
base::BindOnce(
|
||||
[](gin_helper::Promise<gin_helper::Dictionary> promise,
|
||||
int64_t net_error, const absl::optional<net::AddressList>& addrs) {
|
||||
int64_t net_error, const std::optional<net::AddressList>& addrs) {
|
||||
if (net_error < 0) {
|
||||
promise.RejectWithErrorMessage(net::ErrorToString(net_error));
|
||||
} else {
|
||||
|
@ -1271,7 +1271,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
// static
|
||||
absl::optional<gin::Handle<Session>> Session::FromPath(
|
||||
std::optional<gin::Handle<Session>> Session::FromPath(
|
||||
v8::Isolate* isolate,
|
||||
const base::FilePath& path,
|
||||
base::Value::Dict options) {
|
||||
|
@ -1280,12 +1280,12 @@ absl::optional<gin::Handle<Session>> Session::FromPath(
|
|||
if (path.empty()) {
|
||||
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
|
||||
promise.RejectWithErrorMessage("An empty path was specified");
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
if (!path.IsAbsolute()) {
|
||||
gin_helper::Promise<v8::Local<v8::Value>> promise(isolate);
|
||||
promise.RejectWithErrorMessage("An absolute path was not provided");
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
browser_context =
|
||||
|
@ -1410,7 +1410,7 @@ v8::Local<v8::Value> FromPath(const base::FilePath& path,
|
|||
}
|
||||
base::Value::Dict options;
|
||||
args->GetNext(&options);
|
||||
absl::optional<gin::Handle<Session>> session_handle =
|
||||
std::optional<gin::Handle<Session>> session_handle =
|
||||
Session::FromPath(args->isolate(), path, std::move(options));
|
||||
|
||||
if (session_handle)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_
|
||||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -85,7 +86,7 @@ class Session : public gin::Wrappable<Session>,
|
|||
base::Value::Dict options = {});
|
||||
|
||||
// Gets the Session based on |path|.
|
||||
static absl::optional<gin::Handle<Session>> FromPath(
|
||||
static std::optional<gin::Handle<Session>> FromPath(
|
||||
v8::Isolate* isolate,
|
||||
const base::FilePath& path,
|
||||
base::Value::Dict options = {});
|
||||
|
@ -101,7 +102,7 @@ class Session : public gin::Wrappable<Session>,
|
|||
// Methods.
|
||||
v8::Local<v8::Promise> ResolveHost(
|
||||
std::string host,
|
||||
absl::optional<network::mojom::ResolveHostParametersPtr> params);
|
||||
std::optional<network::mojom::ResolveHostParametersPtr> params);
|
||||
v8::Local<v8::Promise> ResolveProxy(gin::Arguments* args);
|
||||
v8::Local<v8::Promise> GetCacheSize();
|
||||
v8::Local<v8::Promise> ClearCache();
|
||||
|
|
|
@ -51,7 +51,7 @@ gin::WrapperInfo Tray::kWrapperInfo = {gin::kEmbedderNativeGin};
|
|||
|
||||
Tray::Tray(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> image,
|
||||
absl::optional<UUID> guid)
|
||||
std::optional<UUID> guid)
|
||||
: tray_icon_(TrayIcon::Create(guid)) {
|
||||
SetImage(isolate, image);
|
||||
tray_icon_->AddObserver(this);
|
||||
|
@ -62,7 +62,7 @@ Tray::~Tray() = default;
|
|||
// static
|
||||
gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> image,
|
||||
absl::optional<UUID> guid,
|
||||
std::optional<UUID> guid,
|
||||
gin::Arguments* args) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
thrower.ThrowError("Cannot create Tray before app is ready");
|
||||
|
@ -232,7 +232,7 @@ void Tray::SetToolTip(const std::string& tool_tip) {
|
|||
}
|
||||
|
||||
void Tray::SetTitle(const std::string& title,
|
||||
const absl::optional<gin_helper::Dictionary>& options,
|
||||
const std::optional<gin_helper::Dictionary>& options,
|
||||
gin::Arguments* args) {
|
||||
if (!CheckAlive())
|
||||
return;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_TRAY_H_
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -43,7 +44,7 @@ class Tray : public gin::Wrappable<Tray>,
|
|||
// gin_helper::Constructible
|
||||
static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower,
|
||||
v8::Local<v8::Value> image,
|
||||
absl::optional<UUID> guid,
|
||||
std::optional<UUID> guid,
|
||||
gin::Arguments* args);
|
||||
|
||||
static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>);
|
||||
|
@ -60,7 +61,7 @@ class Tray : public gin::Wrappable<Tray>,
|
|||
private:
|
||||
Tray(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> image,
|
||||
absl::optional<UUID> guid);
|
||||
std::optional<UUID> guid);
|
||||
~Tray() override;
|
||||
|
||||
// TrayIconObserver:
|
||||
|
@ -92,7 +93,7 @@ class Tray : public gin::Wrappable<Tray>,
|
|||
void SetPressedImage(v8::Isolate* isolate, v8::Local<v8::Value> image);
|
||||
void SetToolTip(const std::string& tool_tip);
|
||||
void SetTitle(const std::string& title,
|
||||
const absl::optional<gin_helper::Dictionary>& options,
|
||||
const std::optional<gin_helper::Dictionary>& options,
|
||||
gin::Arguments* args);
|
||||
std::string GetTitle();
|
||||
void SetIgnoreDoubleClickEvents(bool ignore);
|
||||
|
|
|
@ -182,7 +182,7 @@ View::~View() {
|
|||
}
|
||||
|
||||
void View::AddChildViewAt(gin::Handle<View> child,
|
||||
absl::optional<size_t> maybe_index) {
|
||||
std::optional<size_t> maybe_index) {
|
||||
// TODO(nornagon): !view_ is only for supporting the weird case of
|
||||
// WebContentsView's view being deleted when the underlying WebContents is
|
||||
// destroyed (on non-Mac). We should fix that so that WebContentsView always
|
||||
|
@ -292,7 +292,7 @@ std::vector<v8::Local<v8::Value>> View::GetChildren() {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void View::SetBackgroundColor(absl::optional<WrappedSkColor> color) {
|
||||
void View::SetBackgroundColor(std::optional<WrappedSkColor> color) {
|
||||
if (!view_)
|
||||
return;
|
||||
view_->SetBackground(color ? views::CreateSolidBackground(*color) : nullptr);
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
|
||||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "gin/handle.h"
|
||||
#include "shell/common/color_util.h"
|
||||
|
@ -26,14 +28,14 @@ class View : public gin_helper::EventEmitter<View>, public views::ViewObserver {
|
|||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
void AddChildViewAt(gin::Handle<View> child, absl::optional<size_t> index);
|
||||
void AddChildViewAt(gin::Handle<View> child, std::optional<size_t> index);
|
||||
void RemoveChildView(gin::Handle<View> child);
|
||||
|
||||
void SetBounds(const gfx::Rect& bounds);
|
||||
gfx::Rect GetBounds();
|
||||
void SetLayout(v8::Isolate* isolate, v8::Local<v8::Object> value);
|
||||
std::vector<v8::Local<v8::Value>> GetChildren();
|
||||
void SetBackgroundColor(absl::optional<WrappedSkColor> color);
|
||||
void SetBackgroundColor(std::optional<WrappedSkColor> color);
|
||||
void SetVisible(bool visible);
|
||||
|
||||
// views::ViewObserver
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
@ -128,7 +129,6 @@
|
|||
#include "shell/common/thread_restrictions.h"
|
||||
#include "shell/common/v8_value_serializer.h"
|
||||
#include "storage/browser/file_system/isolated_context.h"
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
#include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h"
|
||||
|
@ -496,9 +496,9 @@ void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise,
|
|||
capture_handle.RunAndReset();
|
||||
}
|
||||
|
||||
absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
|
||||
std::optional<base::TimeDelta> GetCursorBlinkInterval() {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
absl::optional<base::TimeDelta> system_value(
|
||||
std::optional<base::TimeDelta> system_value(
|
||||
ui::TextInsertionCaretBlinkPeriodFromDefaults());
|
||||
if (system_value)
|
||||
return *system_value;
|
||||
|
@ -512,7 +512,7 @@ absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
|
|||
: base::Milliseconds(system_msec);
|
||||
}
|
||||
#endif
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
|
@ -1104,7 +1104,7 @@ void WebContents::Destroy() {
|
|||
}
|
||||
}
|
||||
|
||||
void WebContents::Close(absl::optional<gin_helper::Dictionary> options) {
|
||||
void WebContents::Close(std::optional<gin_helper::Dictionary> options) {
|
||||
bool dispatch_beforeunload = false;
|
||||
if (options)
|
||||
options->Get("waitForBeforeUnload", &dispatch_beforeunload);
|
||||
|
@ -1675,7 +1675,7 @@ void WebContents::HandleNewRenderFrame(
|
|||
}
|
||||
|
||||
void WebContents::OnBackgroundColorChanged() {
|
||||
absl::optional<SkColor> color = web_contents()->GetBackgroundColor();
|
||||
std::optional<SkColor> color = web_contents()->GetBackgroundColor();
|
||||
if (color.has_value()) {
|
||||
auto* const view = web_contents()->GetRenderWidgetHostView();
|
||||
static_cast<content::RenderWidgetHostViewBase*>(view)
|
||||
|
@ -2266,7 +2266,7 @@ void WebContents::SetOwnerWindow(NativeWindow* owner_window) {
|
|||
SetOwnerWindow(GetWebContents(), owner_window);
|
||||
}
|
||||
|
||||
void WebContents::SetOwnerBaseWindow(absl::optional<BaseWindow*> owner_window) {
|
||||
void WebContents::SetOwnerBaseWindow(std::optional<BaseWindow*> owner_window) {
|
||||
SetOwnerWindow(GetWebContents(),
|
||||
owner_window ? (*owner_window)->window() : nullptr);
|
||||
}
|
||||
|
@ -3169,8 +3169,8 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) {
|
|||
web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(),
|
||||
landscape, display_header_footer, print_background, scale,
|
||||
paper_width, paper_height, margin_top, margin_bottom, margin_left,
|
||||
margin_right, absl::make_optional(header_template),
|
||||
absl::make_optional(footer_template), prefer_css_page_size,
|
||||
margin_right, std::make_optional(header_template),
|
||||
std::make_optional(footer_template), prefer_css_page_size,
|
||||
generate_tagged_pdf, generate_document_outline);
|
||||
|
||||
if (absl::holds_alternative<std::string>(print_pages_params)) {
|
||||
|
@ -3780,7 +3780,7 @@ void WebContents::SetImageAnimationPolicy(const std::string& new_policy) {
|
|||
web_contents()->OnWebPreferencesChanged();
|
||||
}
|
||||
|
||||
void WebContents::SetBackgroundColor(absl::optional<SkColor> maybe_color) {
|
||||
void WebContents::SetBackgroundColor(std::optional<SkColor> maybe_color) {
|
||||
SkColor color = maybe_color.value_or((IsGuest() && guest_transparent_) ||
|
||||
type_ == Type::kBrowserView
|
||||
? SK_ColorTRANSPARENT
|
||||
|
@ -4124,7 +4124,7 @@ void WebContents::DevToolsIndexPath(
|
|||
if (devtools_indexing_jobs_.count(request_id) != 0)
|
||||
return;
|
||||
std::vector<std::string> excluded_folders;
|
||||
absl::optional<base::Value> parsed_excluded_folders =
|
||||
std::optional<base::Value> parsed_excluded_folders =
|
||||
base::JSONReader::Read(excluded_folders_message);
|
||||
if (parsed_excluded_folders && parsed_excluded_folders->is_list()) {
|
||||
for (const base::Value& folder_path : parsed_excluded_folders->GetList()) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -164,7 +165,7 @@ class WebContents : public ExclusiveAccessContext,
|
|||
const char* GetTypeName() override;
|
||||
|
||||
void Destroy();
|
||||
void Close(absl::optional<gin_helper::Dictionary> options);
|
||||
void Close(std::optional<gin_helper::Dictionary> options);
|
||||
base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
|
||||
|
||||
bool GetBackgroundThrottling() const override;
|
||||
|
@ -403,7 +404,7 @@ class WebContents : public ExclusiveAccessContext,
|
|||
void SetOwnerWindow(NativeWindow* owner_window);
|
||||
void SetOwnerWindow(content::WebContents* web_contents,
|
||||
NativeWindow* owner_window);
|
||||
void SetOwnerBaseWindow(absl::optional<BaseWindow*> owner_window);
|
||||
void SetOwnerBaseWindow(std::optional<BaseWindow*> owner_window);
|
||||
|
||||
// Returns the WebContents managed by this delegate.
|
||||
content::WebContents* GetWebContents() const;
|
||||
|
@ -474,7 +475,7 @@ class WebContents : public ExclusiveAccessContext,
|
|||
void CancelDialogs(content::WebContents* web_contents,
|
||||
bool reset_state) override;
|
||||
|
||||
void SetBackgroundColor(absl::optional<SkColor> color);
|
||||
void SetBackgroundColor(std::optional<SkColor> color);
|
||||
|
||||
SkRegion* draggable_region() {
|
||||
return force_non_draggable_ ? nullptr : draggable_region_.get();
|
||||
|
|
|
@ -66,7 +66,7 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
|
|||
return gin::Handle<WebContents>();
|
||||
}
|
||||
|
||||
void WebContentsView::SetBackgroundColor(absl::optional<WrappedSkColor> color) {
|
||||
void WebContentsView::SetBackgroundColor(std::optional<WrappedSkColor> color) {
|
||||
View::SetBackgroundColor(color);
|
||||
if (api_web_contents_) {
|
||||
api_web_contents_->SetBackgroundColor(color);
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_
|
||||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "shell/browser/api/electron_api_view.h"
|
||||
|
@ -36,7 +38,7 @@ class WebContentsView : public View,
|
|||
|
||||
// Public APIs.
|
||||
gin::Handle<WebContents> GetWebContents(v8::Isolate* isolate);
|
||||
void SetBackgroundColor(absl::optional<WrappedSkColor> color);
|
||||
void SetBackgroundColor(std::optional<WrappedSkColor> color);
|
||||
|
||||
int NonClientHitTest(const gfx::Point& point) override;
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ void WebFrameMain::OnRendererConnectionError() {
|
|||
void WebFrameMain::PostMessage(v8::Isolate* isolate,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> message_value,
|
||||
absl::optional<v8::Local<v8::Value>> transfer) {
|
||||
std::optional<v8::Local<v8::Value>> transfer) {
|
||||
blink::TransferableMessage transferable_message;
|
||||
if (!electron::SerializeV8Value(isolate, message_value,
|
||||
&transferable_message)) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
|
||||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -103,7 +104,7 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
|
|||
void PostMessage(v8::Isolate* isolate,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> message_value,
|
||||
absl::optional<v8::Local<v8::Value>> transfer);
|
||||
std::optional<v8::Local<v8::Value>> transfer);
|
||||
|
||||
int FrameTreeNodeID() const;
|
||||
std::string Name() const;
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
#include "shell/browser/api/process_metric.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
|
||||
#include "third_party/abseil-cpp/absl/types/optional.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <windows.h>
|
||||
|
||||
|
@ -34,14 +33,14 @@ mach_port_t TaskForPid(pid_t pid) {
|
|||
return task;
|
||||
}
|
||||
|
||||
absl::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
|
||||
std::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) {
|
||||
if (task == MACH_PORT_NULL)
|
||||
return absl::nullopt;
|
||||
return std::nullopt;
|
||||
mach_task_basic_info_data_t info = {};
|
||||
mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT;
|
||||
kern_return_t kr = task_info(task, MACH_TASK_BASIC_INFO,
|
||||
reinterpret_cast<task_info_t>(&info), &count);
|
||||
return (kr == KERN_SUCCESS) ? absl::make_optional(info) : absl::nullopt;
|
||||
return (kr == KERN_SUCCESS) ? std::make_optional(info) : std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue