diff --git a/shell/app/electron_main_delegate.cc b/shell/app/electron_main_delegate.cc index ad771f290054..19d01f471e87 100644 --- a/shell/app/electron_main_delegate.cc +++ b/shell/app/electron_main_delegate.cc @@ -238,7 +238,7 @@ const char* const ElectronMainDelegate::kNonWildcardDomainNonPortSchemes[] = { const size_t ElectronMainDelegate::kNonWildcardDomainNonPortSchemesSize = std::size(kNonWildcardDomainNonPortSchemes); -absl::optional ElectronMainDelegate::BasicStartupComplete() { +std::optional ElectronMainDelegate::BasicStartupComplete() { auto* command_line = base::CommandLine::ForCurrentProcess(); #if BUILDFLAG(IS_WIN) @@ -311,7 +311,7 @@ absl::optional ElectronMainDelegate::BasicStartupComplete() { ::switches::kDisableGpuMemoryBufferCompositorResources); #endif - return absl::nullopt; + return std::nullopt; } void ElectronMainDelegate::PreSandboxStartup() { @@ -398,7 +398,7 @@ void ElectronMainDelegate::SandboxInitialized(const std::string& process_type) { #endif } -absl::optional ElectronMainDelegate::PreBrowserMain() { +std::optional ElectronMainDelegate::PreBrowserMain() { // This is initialized early because the service manager reads some feature // flags and we need to make sure the feature list is initialized before the // service manager reads the features. @@ -408,7 +408,7 @@ absl::optional ElectronMainDelegate::PreBrowserMain() { #if BUILDFLAG(IS_MAC) RegisterAtomCrApp(); #endif - return absl::nullopt; + return std::nullopt; } base::StringPiece ElectronMainDelegate::GetBrowserV8SnapshotFilename() { diff --git a/shell/app/electron_main_delegate.h b/shell/app/electron_main_delegate.h index 15cff1cc76ce..ccac19187de2 100644 --- a/shell/app/electron_main_delegate.h +++ b/shell/app/electron_main_delegate.h @@ -34,10 +34,10 @@ class ElectronMainDelegate : public content::ContentMainDelegate { protected: // content::ContentMainDelegate: - absl::optional BasicStartupComplete() override; + std::optional BasicStartupComplete() override; void PreSandboxStartup() override; void SandboxInitialized(const std::string& process_type) override; - absl::optional PreBrowserMain() override; + std::optional PreBrowserMain() override; content::ContentClient* CreateContentClient() override; content::ContentBrowserClient* CreateContentBrowserClient() override; content::ContentGpuClient* CreateContentGpuClient() override; diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index ee434db91729..1b3f213ff60a 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -5,6 +5,7 @@ #include "shell/browser/api/electron_api_app.h" #include +#include #include #include #include @@ -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 custom_path) { + std::optional 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 servers; for (const std::string& server_template : secure_dns_server_strings) { - absl::optional server_config = + std::optional server_config = net::DnsOverHttpsServerConfig::FromString(server_template); if (!server_config.has_value()) { thrower.ThrowTypeError(std::string("not a valid DoH template: ") + diff --git a/shell/browser/api/electron_api_app.h b/shell/browser/api/electron_api_app.h index 082dc94152a2..c2f5eae50b10 100644 --- a/shell/browser/api/electron_api_app.h +++ b/shell/browser/api/electron_api_app.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_APP_H_ #include +#include #include #include @@ -180,7 +181,7 @@ class App : public ElectronBrowserClient::Delegate, void ChildProcessDisconnected(int pid); void SetAppLogsPath(gin_helper::ErrorThrower thrower, - absl::optional custom_path); + std::optional custom_path); // Get/Set the pre-defined path in PathService. base::FilePath GetPath(gin_helper::ErrorThrower thrower, diff --git a/shell/browser/api/electron_api_app_mac.mm b/shell/browser/api/electron_api_app_mac.mm index 90ca396fe80a..5415c8cfacc3 100644 --- a/shell/browser/api/electron_api_app_mac.mm +++ b/shell/browser/api/electron_api_app_mac.mm @@ -17,7 +17,7 @@ namespace electron::api { void App::SetAppLogsPath(gin_helper::ErrorThrower thrower, - absl::optional custom_path) { + std::optional custom_path) { if (custom_path.has_value()) { if (!custom_path->IsAbsolute()) { thrower.ThrowError("Path must be absolute"); diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index c05837938a3b..7b040f8cadd4 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -826,11 +826,11 @@ bool BaseWindow::GetWindowButtonVisibility() const { return window_->GetWindowButtonVisibility(); } -void BaseWindow::SetWindowButtonPosition(absl::optional position) { +void BaseWindow::SetWindowButtonPosition(std::optional position) { window_->SetWindowButtonPosition(std::move(position)); } -absl::optional BaseWindow::GetWindowButtonPosition() const { +std::optional BaseWindow::GetWindowButtonPosition() const { return window_->GetWindowButtonPosition(); } #endif diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index 42771d622fab..2c2d0fdf5749 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -187,8 +188,8 @@ class BaseWindow : public gin_helper::TrackableObject, std::string GetAlwaysOnTopLevel() const; void SetWindowButtonVisibility(bool visible); bool GetWindowButtonVisibility() const; - void SetWindowButtonPosition(absl::optional position); - absl::optional GetWindowButtonPosition() const; + void SetWindowButtonPosition(std::optional position); + std::optional GetWindowButtonPosition() const; bool IsHiddenInMissionControl(); void SetHiddenInMissionControl(bool hidden); diff --git a/shell/browser/api/electron_api_content_tracing.cc b/shell/browser/api/electron_api_content_tracing.cc index 4a5f373b69c6..384a16e1b3a7 100644 --- a/shell/browser/api/electron_api_content_tracing.cc +++ b/shell/browser/api/electron_api_content_tracing.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +#include #include #include #include @@ -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; -absl::optional CreateTemporaryFileOnIO() { +std::optional 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 promise, - absl::optional file_path) { + std::optional file_path) { auto resolve_or_reject = base::BindOnce( [](gin_helper::Promise promise, - const base::FilePath& path, absl::optional error) { + const base::FilePath& path, std::optional error) { if (error) { promise.RejectWithErrorMessage(error.value()); } else { @@ -81,20 +81,20 @@ void StopTracing(gin_helper::Promise 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 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( diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index 0606776e73aa..d166af491aec 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -127,13 +127,13 @@ bool MatchesCookie(const base::Value::Dict& filter, if ((str = filter.FindString("domain")) && !MatchesDomain(*str, cookie.Domain())) return false; - absl::optional secure_filter = filter.FindBool("secure"); + std::optional secure_filter = filter.FindBool("secure"); if (secure_filter && *secure_filter != cookie.IsSecure()) return false; - absl::optional session_filter = filter.FindBool("session"); + std::optional session_filter = filter.FindBool("session"); if (session_filter && *session_filter == cookie.IsPersistent()) return false; - absl::optional httpOnly_filter = filter.FindBool("httpOnly"); + std::optional 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& value) { +base::Time ParseTimeProperty(const std::optional& 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 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()) { diff --git a/shell/browser/api/electron_api_debugger.cc b/shell/browser/api/electron_api_debugger.cc index 3e731a25adcb..1148b84aa222 100755 --- a/shell/browser/api/electron_api_debugger.cc +++ b/shell/browser/api/electron_api_debugger.cc @@ -44,12 +44,12 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host, base::StringPiece message_str(reinterpret_cast(message.data()), message.size()); - absl::optional parsed_message = base::JSONReader::Read( + std::optional 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 id = dict.FindInt("id"); + std::optional id = dict.FindInt("id"); if (!id) { std::string* method = dict.FindString("method"); if (!method) diff --git a/shell/browser/api/electron_api_menu_mac.mm b/shell/browser/api/electron_api_menu_mac.mm index 9bb7ddf2383a..2473953ddd9b 100644 --- a/shell/browser/api/electron_api_menu_mac.mm +++ b/shell/browser/api/electron_api_menu_mac.mm @@ -25,7 +25,7 @@ static NSMenu* __strong applicationMenu_; ui::Accelerator GetAcceleratorFromKeyEquivalentAndModifierMask( NSString* key_equivalent, NSUInteger modifier_mask) { - absl::optional shifted_char; + std::optional shifted_char; ui::KeyboardCode code = electron::KeyboardCodeFromStr( base::SysNSStringToUTF8(key_equivalent), &shifted_char); int modifiers = 0; diff --git a/shell/browser/api/electron_api_net_log.cc b/shell/browser/api/electron_api_net_log.cc index 24ebc6e29bd3..45c21384c152 100644 --- a/shell/browser/api/electron_api_net_log.cc +++ b/shell/browser/api/electron_api_net_log.cc @@ -125,7 +125,7 @@ v8::Local NetLog::StartLogging(base::FilePath log_path, } pending_start_promise_ = - absl::make_optional>(args->isolate()); + std::make_optional>(args->isolate()); v8::Local handle = pending_start_promise_->GetHandle(); auto command_line_string = diff --git a/shell/browser/api/electron_api_net_log.h b/shell/browser/api/electron_api_net_log.h index e715e0e241c3..3a745ca69519 100644 --- a/shell/browser/api/electron_api_net_log.h +++ b/shell/browser/api/electron_api_net_log.h @@ -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 + #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 { mojo::Remote net_log_exporter_; - absl::optional> pending_start_promise_; + std::optional> pending_start_promise_; scoped_refptr file_task_runner_; diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index f1e14449ae3a..93666811ac19 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -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 Session::ResolveProxy(gin::Arguments* args) { v8::Local Session::ResolveHost( std::string host, - absl::optional params) { + std::optional params) { gin_helper::Promise promise(isolate_); v8::Local handle = promise.GetHandle(); @@ -441,7 +441,7 @@ v8::Local Session::ResolveHost( params ? std::move(params.value()) : nullptr, base::BindOnce( [](gin_helper::Promise promise, - int64_t net_error, const absl::optional& addrs) { + int64_t net_error, const std::optional& addrs) { if (net_error < 0) { promise.RejectWithErrorMessage(net::ErrorToString(net_error)); } else { @@ -1271,7 +1271,7 @@ gin::Handle Session::FromPartition(v8::Isolate* isolate, } // static -absl::optional> Session::FromPath( +std::optional> Session::FromPath( v8::Isolate* isolate, const base::FilePath& path, base::Value::Dict options) { @@ -1280,12 +1280,12 @@ absl::optional> Session::FromPath( if (path.empty()) { gin_helper::Promise> promise(isolate); promise.RejectWithErrorMessage("An empty path was specified"); - return absl::nullopt; + return std::nullopt; } if (!path.IsAbsolute()) { gin_helper::Promise> promise(isolate); promise.RejectWithErrorMessage("An absolute path was not provided"); - return absl::nullopt; + return std::nullopt; } browser_context = @@ -1410,7 +1410,7 @@ v8::Local FromPath(const base::FilePath& path, } base::Value::Dict options; args->GetNext(&options); - absl::optional> session_handle = + std::optional> session_handle = Session::FromPath(args->isolate(), path, std::move(options)); if (session_handle) diff --git a/shell/browser/api/electron_api_session.h b/shell/browser/api/electron_api_session.h index a71609273cba..a6ad55fa3c8f 100644 --- a/shell/browser/api/electron_api_session.h +++ b/shell/browser/api/electron_api_session.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_ +#include #include #include @@ -85,7 +86,7 @@ class Session : public gin::Wrappable, base::Value::Dict options = {}); // Gets the Session based on |path|. - static absl::optional> FromPath( + static std::optional> FromPath( v8::Isolate* isolate, const base::FilePath& path, base::Value::Dict options = {}); @@ -101,7 +102,7 @@ class Session : public gin::Wrappable, // Methods. v8::Local ResolveHost( std::string host, - absl::optional params); + std::optional params); v8::Local ResolveProxy(gin::Arguments* args); v8::Local GetCacheSize(); v8::Local ClearCache(); diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index 822ed7acdc4d..5ecb4b851ac1 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -51,7 +51,7 @@ gin::WrapperInfo Tray::kWrapperInfo = {gin::kEmbedderNativeGin}; Tray::Tray(v8::Isolate* isolate, v8::Local image, - absl::optional guid) + std::optional guid) : tray_icon_(TrayIcon::Create(guid)) { SetImage(isolate, image); tray_icon_->AddObserver(this); @@ -62,7 +62,7 @@ Tray::~Tray() = default; // static gin::Handle Tray::New(gin_helper::ErrorThrower thrower, v8::Local image, - absl::optional guid, + std::optional 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& options, + const std::optional& options, gin::Arguments* args) { if (!CheckAlive()) return; diff --git a/shell/browser/api/electron_api_tray.h b/shell/browser/api/electron_api_tray.h index 5b6b1b575203..26429e9ee823 100644 --- a/shell/browser/api/electron_api_tray.h +++ b/shell/browser/api/electron_api_tray.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_TRAY_H_ #include +#include #include #include @@ -43,7 +44,7 @@ class Tray : public gin::Wrappable, // gin_helper::Constructible static gin::Handle New(gin_helper::ErrorThrower thrower, v8::Local image, - absl::optional guid, + std::optional guid, gin::Arguments* args); static void FillObjectTemplate(v8::Isolate*, v8::Local); @@ -60,7 +61,7 @@ class Tray : public gin::Wrappable, private: Tray(v8::Isolate* isolate, v8::Local image, - absl::optional guid); + std::optional guid); ~Tray() override; // TrayIconObserver: @@ -92,7 +93,7 @@ class Tray : public gin::Wrappable, void SetPressedImage(v8::Isolate* isolate, v8::Local image); void SetToolTip(const std::string& tool_tip); void SetTitle(const std::string& title, - const absl::optional& options, + const std::optional& options, gin::Arguments* args); std::string GetTitle(); void SetIgnoreDoubleClickEvents(bool ignore); diff --git a/shell/browser/api/electron_api_view.cc b/shell/browser/api/electron_api_view.cc index f5a8aa2ec23a..eea9c8098baa 100644 --- a/shell/browser/api/electron_api_view.cc +++ b/shell/browser/api/electron_api_view.cc @@ -182,7 +182,7 @@ View::~View() { } void View::AddChildViewAt(gin::Handle child, - absl::optional maybe_index) { + std::optional 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> View::GetChildren() { return ret; } -void View::SetBackgroundColor(absl::optional color) { +void View::SetBackgroundColor(std::optional color) { if (!view_) return; view_->SetBackground(color ? views::CreateSolidBackground(*color) : nullptr); diff --git a/shell/browser/api/electron_api_view.h b/shell/browser/api/electron_api_view.h index 3a90d79118de..1080333c2f5f 100644 --- a/shell/browser/api/electron_api_view.h +++ b/shell/browser/api/electron_api_view.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_ +#include + #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, public views::ViewObserver { static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); - void AddChildViewAt(gin::Handle child, absl::optional index); + void AddChildViewAt(gin::Handle child, std::optional index); void RemoveChildView(gin::Handle child); void SetBounds(const gfx::Rect& bounds); gfx::Rect GetBounds(); void SetLayout(v8::Isolate* isolate, v8::Local value); std::vector> GetChildren(); - void SetBackgroundColor(absl::optional color); + void SetBackgroundColor(std::optional color); void SetVisible(bool visible); // views::ViewObserver diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index c24d3288831f..893f51e7ba5e 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -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 promise, capture_handle.RunAndReset(); } -absl::optional GetCursorBlinkInterval() { +std::optional GetCursorBlinkInterval() { #if BUILDFLAG(IS_MAC) - absl::optional system_value( + std::optional system_value( ui::TextInsertionCaretBlinkPeriodFromDefaults()); if (system_value) return *system_value; @@ -512,7 +512,7 @@ absl::optional 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 options) { +void WebContents::Close(std::optional options) { bool dispatch_beforeunload = false; if (options) options->Get("waitForBeforeUnload", &dispatch_beforeunload); @@ -1675,7 +1675,7 @@ void WebContents::HandleNewRenderFrame( } void WebContents::OnBackgroundColorChanged() { - absl::optional color = web_contents()->GetBackgroundColor(); + std::optional color = web_contents()->GetBackgroundColor(); if (color.has_value()) { auto* const view = web_contents()->GetRenderWidgetHostView(); static_cast(view) @@ -2266,7 +2266,7 @@ void WebContents::SetOwnerWindow(NativeWindow* owner_window) { SetOwnerWindow(GetWebContents(), owner_window); } -void WebContents::SetOwnerBaseWindow(absl::optional owner_window) { +void WebContents::SetOwnerBaseWindow(std::optional owner_window) { SetOwnerWindow(GetWebContents(), owner_window ? (*owner_window)->window() : nullptr); } @@ -3169,8 +3169,8 @@ v8::Local 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(print_pages_params)) { @@ -3780,7 +3780,7 @@ void WebContents::SetImageAnimationPolicy(const std::string& new_policy) { web_contents()->OnWebPreferencesChanged(); } -void WebContents::SetBackgroundColor(absl::optional maybe_color) { +void WebContents::SetBackgroundColor(std::optional 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 excluded_folders; - absl::optional parsed_excluded_folders = + std::optional 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()) { diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 00c3ad8648c7..27f6d2764074 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -164,7 +165,7 @@ class WebContents : public ExclusiveAccessContext, const char* GetTypeName() override; void Destroy(); - void Close(absl::optional options); + void Close(std::optional options); base::WeakPtr 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 owner_window); + void SetOwnerBaseWindow(std::optional 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 color); + void SetBackgroundColor(std::optional color); SkRegion* draggable_region() { return force_non_draggable_ ? nullptr : draggable_region_.get(); diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index 6a85727a3aae..aabda22ff9dd 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -66,7 +66,7 @@ gin::Handle WebContentsView::GetWebContents(v8::Isolate* isolate) { return gin::Handle(); } -void WebContentsView::SetBackgroundColor(absl::optional color) { +void WebContentsView::SetBackgroundColor(std::optional color) { View::SetBackgroundColor(color); if (api_web_contents_) { api_web_contents_->SetBackgroundColor(color); diff --git a/shell/browser/api/electron_api_web_contents_view.h b/shell/browser/api/electron_api_web_contents_view.h index 6852f6becb38..353086427ba6 100644 --- a/shell/browser/api/electron_api_web_contents_view.h +++ b/shell/browser/api/electron_api_web_contents_view.h @@ -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 + #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 GetWebContents(v8::Isolate* isolate); - void SetBackgroundColor(absl::optional color); + void SetBackgroundColor(std::optional color); int NonClientHitTest(const gfx::Point& point) override; diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index 24952767db2d..da0e9ca50c60 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -229,7 +229,7 @@ void WebFrameMain::OnRendererConnectionError() { void WebFrameMain::PostMessage(v8::Isolate* isolate, const std::string& channel, v8::Local message_value, - absl::optional> transfer) { + std::optional> transfer) { blink::TransferableMessage transferable_message; if (!electron::SerializeV8Value(isolate, message_value, &transferable_message)) { diff --git a/shell/browser/api/electron_api_web_frame_main.h b/shell/browser/api/electron_api_web_frame_main.h index d3ac3914d64c..ddf7bdd63096 100644 --- a/shell/browser/api/electron_api_web_frame_main.h +++ b/shell/browser/api/electron_api_web_frame_main.h @@ -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 #include #include @@ -103,7 +104,7 @@ class WebFrameMain : public gin::Wrappable, void PostMessage(v8::Isolate* isolate, const std::string& channel, v8::Local message_value, - absl::optional> transfer); + std::optional> transfer); int FrameTreeNodeID() const; std::string Name() const; diff --git a/shell/browser/api/process_metric.cc b/shell/browser/api/process_metric.cc index a7d628e691a9..75c0f04cd812 100644 --- a/shell/browser/api/process_metric.cc +++ b/shell/browser/api/process_metric.cc @@ -5,10 +5,9 @@ #include "shell/browser/api/process_metric.h" #include +#include #include -#include "third_party/abseil-cpp/absl/types/optional.h" - #if BUILDFLAG(IS_WIN) #include @@ -34,14 +33,14 @@ mach_port_t TaskForPid(pid_t pid) { return task; } -absl::optional GetTaskInfo(mach_port_t task) { +std::optional 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(&info), &count); - return (kr == KERN_SUCCESS) ? absl::make_optional(info) : absl::nullopt; + return (kr == KERN_SUCCESS) ? std::make_optional(info) : std::nullopt; } } // namespace diff --git a/shell/browser/badging/badge_manager.cc b/shell/browser/badging/badge_manager.cc index 16c1a697011e..3de1482bfb79 100755 --- a/shell/browser/badging/badge_manager.cc +++ b/shell/browser/badging/badge_manager.cc @@ -67,7 +67,7 @@ void BadgeManager::BindServiceWorkerReceiver( std::move(context)); } -std::string BadgeManager::GetBadgeString(absl::optional badge_content) { +std::string BadgeManager::GetBadgeString(std::optional badge_content) { if (!badge_content) return "•"; @@ -87,9 +87,9 @@ void BadgeManager::SetBadge(blink::mojom::BadgeValuePtr mojo_value) { return; } - absl::optional value = - mojo_value->is_flag() ? absl::nullopt - : absl::make_optional(mojo_value->get_number()); + std::optional value = mojo_value->is_flag() + ? std::nullopt + : std::make_optional(mojo_value->get_number()); electron::Browser::Get()->SetBadgeCount(value); } diff --git a/shell/browser/badging/badge_manager.h b/shell/browser/badging/badge_manager.h index 0db3e53fb2dd..1fc523ce7c8e 100644 --- a/shell/browser/badging/badge_manager.h +++ b/shell/browser/badging/badge_manager.h @@ -6,11 +6,11 @@ #define ELECTRON_SHELL_BROWSER_BADGING_BADGE_MANAGER_H_ #include +#include #include #include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/receiver_set.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/badging/badging.mojom.h" #include "url/gurl.h" @@ -44,7 +44,7 @@ class BadgeManager : public KeyedService, public blink::mojom::BadgeService { mojo::PendingReceiver receiver); // Determines the text to put on the badge based on some badge_content. - static std::string GetBadgeString(absl::optional badge_content); + static std::string GetBadgeString(std::optional badge_content); private: // The BindingContext of a mojo request. Allows mojo calls to be tied back diff --git a/shell/browser/bluetooth/electron_bluetooth_delegate.cc b/shell/browser/bluetooth/electron_bluetooth_delegate.cc index 94e7a3b2a6e2..3616c55b03e3 100644 --- a/shell/browser/bluetooth/electron_bluetooth_delegate.cc +++ b/shell/browser/bluetooth/electron_bluetooth_delegate.cc @@ -161,7 +161,7 @@ void ElectronBluetoothDelegate::ShowDevicePairPrompt( const std::u16string& device_identifier, PairPromptCallback callback, PairingKind pairing_kind, - const absl::optional& pin) { + const std::optional& pin) { auto* web_contents = content::WebContents::FromRenderFrameHost(frame); if (web_contents) { auto* permission_manager = static_cast( diff --git a/shell/browser/bluetooth/electron_bluetooth_delegate.h b/shell/browser/bluetooth/electron_bluetooth_delegate.h index 8328f45636ad..f0fef90e0124 100644 --- a/shell/browser/bluetooth/electron_bluetooth_delegate.h +++ b/shell/browser/bluetooth/electron_bluetooth_delegate.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_BLUETOOTH_ELECTRON_BLUETOOTH_DELEGATE_H_ #include +#include #include #include @@ -57,7 +58,7 @@ class ElectronBluetoothDelegate : public content::BluetoothDelegate { const std::u16string& device_identifier, PairPromptCallback callback, PairingKind pairing_kind, - const absl::optional& pin) override; + const std::optional& pin) override; blink::WebBluetoothDeviceId GetWebBluetoothDeviceId( content::RenderFrameHost* frame, const std::string& device_address) override; diff --git a/shell/browser/browser.h b/shell/browser/browser.h index 1e7123773ca1..8b0434cf06fe 100644 --- a/shell/browser/browser.h +++ b/shell/browser/browser.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_BROWSER_H_ #include +#include #include #include @@ -108,7 +109,7 @@ class Browser : public WindowListObserver { #endif // Set/Get the badge count. - bool SetBadgeCount(absl::optional count); + bool SetBadgeCount(std::optional count); int GetBadgeCount(); #if BUILDFLAG(IS_WIN) @@ -374,7 +375,7 @@ class Browser : public WindowListObserver { #if BUILDFLAG(IS_WIN) void UpdateBadgeContents(HWND hwnd, - const absl::optional& badge_content, + const std::optional& badge_content, const std::string& badge_alt_string); // In charge of running taskbar related APIs. diff --git a/shell/browser/browser_linux.cc b/shell/browser/browser_linux.cc index 1a6f5b40b7de..fc297546c476 100644 --- a/shell/browser/browser_linux.cc +++ b/shell/browser/browser_linux.cc @@ -49,7 +49,7 @@ bool LaunchXdgUtility(const std::vector& argv, int* exit_code) { return process.WaitForExit(exit_code); } -absl::optional GetXdgAppOutput( +std::optional GetXdgAppOutput( const std::vector& argv) { std::string reply; int success_code; @@ -58,9 +58,9 @@ absl::optional GetXdgAppOutput( &success_code); if (!ran_ok || success_code != EXIT_SUCCESS) - return absl::optional(); + return std::optional(); - return absl::make_optional(reply); + return std::make_optional(reply); } bool SetDefaultWebClient(const std::string& protocol) { @@ -126,7 +126,7 @@ std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) { return base::ASCIIToUTF16(GetXdgAppOutput(argv).value_or(std::string())); } -bool Browser::SetBadgeCount(absl::optional count) { +bool Browser::SetBadgeCount(std::optional count) { if (IsUnityRunning() && count.has_value()) { unity::SetDownloadCount(count.value()); badge_count_ = count.value(); diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index c35ccc1afe41..3745a2e2d3d5 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -266,7 +266,7 @@ std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) { return app_display_name; } -bool Browser::SetBadgeCount(absl::optional count) { +bool Browser::SetBadgeCount(std::optional count) { DockSetBadgeText(!count.has_value() || count.value() != 0 ? badging::BadgeManager::GetBadgeString(count) : ""); diff --git a/shell/browser/browser_win.cc b/shell/browser/browser_win.cc index a585882eaca1..a7379fe921a4 100644 --- a/shell/browser/browser_win.cc +++ b/shell/browser/browser_win.cc @@ -516,10 +516,10 @@ v8::Local Browser::GetApplicationInfoForProtocol( return handle; } -bool Browser::SetBadgeCount(absl::optional count) { - absl::optional badge_content; +bool Browser::SetBadgeCount(std::optional count) { + std::optional badge_content; if (count.has_value() && count.value() == 0) { - badge_content = absl::nullopt; + badge_content = std::nullopt; } else { badge_content = badging::BadgeManager::GetBadgeString(count); } @@ -560,7 +560,7 @@ bool Browser::SetBadgeCount(absl::optional count) { void Browser::UpdateBadgeContents( HWND hwnd, - const absl::optional& badge_content, + const std::optional& badge_content, const std::string& badge_alt_string) { SkBitmap badge; if (badge_content) { diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 40a25edc335e..71ff54572628 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -924,7 +924,7 @@ bool ElectronBrowserClient::HandleExternalProtocol( network::mojom::WebSandboxFlags sandbox_flags, ui::PageTransition page_transition, bool has_user_gesture, - const absl::optional& initiating_origin, + const std::optional& initiating_origin, content::RenderFrameHost* initiator_document, mojo::PendingRemote* out_factory) { content::GetUIThreadTaskRunner({})->PostTask( @@ -1129,7 +1129,7 @@ class FileURLLoaderFactory : public network::SelfDeletingURLLoaderFactory { void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories( int render_process_id, int render_frame_id, - const absl::optional& request_initiator_origin, + const std::optional& request_initiator_origin, NonNetworkURLLoaderFactoryMap* factories) { auto* render_process_host = content::RenderProcessHost::FromID(render_process_id); @@ -1265,7 +1265,7 @@ void ElectronBrowserClient::CreateWebSocket( WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional& user_agent, + const std::optional& user_agent, mojo::PendingRemote handshake_client) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); @@ -1302,7 +1302,7 @@ bool ElectronBrowserClient::WillCreateURLLoaderFactory( int render_process_id, URLLoaderFactoryType type, const url::Origin& request_initiator, - absl::optional navigation_id, + std::optional navigation_id, ukm::SourceIdObj ukm_source_id, mojo::PendingReceiver* factory_receiver, mojo::PendingRemote* diff --git a/shell/browser/electron_browser_client.h b/shell/browser/electron_browser_client.h index 80131015f3c0..5a4a26ce9861 100644 --- a/shell/browser/electron_browser_client.h +++ b/shell/browser/electron_browser_client.h @@ -201,7 +201,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, void RegisterNonNetworkSubresourceURLLoaderFactories( int render_process_id, int render_frame_id, - const absl::optional& request_initiator_origin, + const std::optional& request_initiator_origin, NonNetworkURLLoaderFactoryMap* factories) override; void RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories( content::BrowserContext* browser_context, @@ -211,7 +211,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional& user_agent, + const std::optional& user_agent, mojo::PendingRemote handshake_client) override; bool WillInterceptWebSocket(content::RenderFrameHost*) override; @@ -221,7 +221,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, int render_process_id, URLLoaderFactoryType type, const url::Origin& request_initiator, - absl::optional navigation_id, + std::optional navigation_id, ukm::SourceIdObj ukm_source_id, mojo::PendingReceiver* factory_receiver, mojo::PendingRemote* @@ -263,7 +263,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, network::mojom::WebSandboxFlags sandbox_flags, ui::PageTransition page_transition, bool has_user_gesture, - const absl::optional& initiating_origin, + const std::optional& initiating_origin, content::RenderFrameHost* initiator_document, mojo::PendingRemote* out_factory) override; diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index 88e937a696f5..4f8b281816b0 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -447,7 +447,7 @@ ElectronBrowserContext::GetURLLoaderFactory() { ->WillCreateURLLoaderFactory( this, nullptr, -1, content::ContentBrowserClient::URLLoaderFactoryType::kNavigation, - url::Origin(), absl::nullopt, ukm::kInvalidSourceIdObj, + url::Origin(), std::nullopt, ukm::kInvalidSourceIdObj, &factory_receiver, &header_client, nullptr, nullptr, nullptr, nullptr); diff --git a/shell/browser/electron_browser_context.h b/shell/browser/electron_browser_context.h index 80581f2d3f54..9ec947e5f693 100644 --- a/shell/browser/electron_browser_context.h +++ b/shell/browser/electron_browser_context.h @@ -7,9 +7,11 @@ #include #include +#include #include #include #include + #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/predictors/preconnect_manager.h" @@ -253,7 +255,7 @@ class ElectronBrowserContext : public content::BrowserContext { std::unique_ptr preconnect_manager_; std::unique_ptr protocol_registry_; - absl::optional user_agent_; + std::optional user_agent_; base::FilePath path_; bool in_memory_ = false; bool use_cache_ = true; diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 1638f64c0400..7165fc12576c 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -5,6 +5,7 @@ #include "shell/browser/electron_browser_main_parts.h" #include +#include #include #include #include @@ -64,7 +65,6 @@ #include "shell/common/logging.h" #include "shell/common/node_bindings.h" #include "shell/common/node_includes.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/idle/idle.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_switches.h" @@ -308,7 +308,7 @@ int ElectronBrowserMainParts::PreCreateThreads() { // We must set this env first to make ui::ResourceBundle accept the custom // locale. auto env = base::Environment::Create(); - absl::optional lc_all; + std::optional lc_all; if (!locale.empty()) { std::string str; if (env->GetVar("LC_ALL", &str)) diff --git a/shell/browser/electron_browser_main_parts.h b/shell/browser/electron_browser_main_parts.h index 62c8441b6628..41d69716f156 100644 --- a/shell/browser/electron_browser_main_parts.h +++ b/shell/browser/electron_browser_main_parts.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_MAIN_PARTS_H_ #include +#include #include #include "base/functional/callback.h" @@ -16,7 +17,6 @@ #include "electron/buildflags/buildflags.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/device/public/mojom/geolocation_control.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/display/screen.h" #include "ui/views/layout/layout_provider.h" @@ -153,7 +153,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts { // A place to remember the exit code once the message loop is ready. // Before then, we just exit() without any intermediate steps. - absl::optional exit_code_; + std::optional exit_code_; std::unique_ptr node_bindings_; diff --git a/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc b/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc index a7dce3c231ec..e93bd81b710d 100644 --- a/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc +++ b/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc @@ -53,7 +53,7 @@ PdfViewerPrivateIsAllowedLocalFileAccessFunction:: ExtensionFunction::ResponseAction PdfViewerPrivateIsAllowedLocalFileAccessFunction::Run() { - absl::optional params = + std::optional params = IsAllowedLocalFileAccess::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -81,7 +81,7 @@ PdfViewerPrivateSetPdfOcrPrefFunction:: // TODO(codebytere): enable when https://crbug.com/1393069 works properly. ExtensionFunction::ResponseAction PdfViewerPrivateSetPdfOcrPrefFunction::Run() { - absl::optional params = + std::optional params = SetPdfOcrPref::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); return RespondNow(WithArguments(false)); diff --git a/shell/browser/extensions/api/resources_private/resources_private_api.cc b/shell/browser/extensions/api/resources_private/resources_private_api.cc index 2dd1f974a4f8..d3f1158bd653 100644 --- a/shell/browser/extensions/api/resources_private/resources_private_api.cc +++ b/shell/browser/extensions/api/resources_private/resources_private_api.cc @@ -40,7 +40,7 @@ ResourcesPrivateGetStringsFunction::~ResourcesPrivateGetStringsFunction() = default; ExtensionFunction::ResponseAction ResourcesPrivateGetStringsFunction::Run() { - absl::optional params( + std::optional params( get_strings::Params::Create(args())); base::Value::Dict dict; diff --git a/shell/browser/extensions/api/scripting/scripting_api.cc b/shell/browser/extensions/api/scripting/scripting_api.cc index bc1b1cb973ca..2024e3644306 100644 --- a/shell/browser/extensions/api/scripting/scripting_api.cc +++ b/shell/browser/extensions/api/scripting/scripting_api.cc @@ -198,14 +198,14 @@ bool GetFileResources(const std::vector& files, using ResourcesLoadedCallback = base::OnceCallback, - absl::optional)>; + std::optional)>; // Checks the loaded content of extension resources. Invokes `callback` with // the constructed file sources on success or with an error on failure. void CheckLoadedResources(std::vector file_names, ResourcesLoadedCallback callback, std::vector> file_data, - absl::optional load_error) { + std::optional load_error) { if (load_error) { std::move(callback).Run({}, std::move(load_error)); return; @@ -228,7 +228,7 @@ void CheckLoadedResources(std::vector file_names, } } - std::move(callback).Run(std::move(file_sources), absl::nullopt); + std::move(callback).Run(std::move(file_sources), std::nullopt); } // Checks the specified `files` for validity, and attempts to load and localize @@ -582,7 +582,7 @@ ScriptingExecuteScriptFunction::ScriptingExecuteScriptFunction() = default; ScriptingExecuteScriptFunction::~ScriptingExecuteScriptFunction() = default; ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() { - absl::optional params = + std::optional params = api::scripting::ExecuteScript::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); injection_ = std::move(params->injection); @@ -654,7 +654,7 @@ ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() { void ScriptingExecuteScriptFunction::DidLoadResources( std::vector file_sources, - absl::optional load_error) { + std::optional load_error) { if (load_error) { Respond(Error(std::move(*load_error))); return; @@ -749,7 +749,7 @@ ScriptingInsertCSSFunction::ScriptingInsertCSSFunction() = default; ScriptingInsertCSSFunction::~ScriptingInsertCSSFunction() = default; ExtensionFunction::ResponseAction ScriptingInsertCSSFunction::Run() { - absl::optional params = + std::optional params = api::scripting::InsertCSS::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -793,7 +793,7 @@ ExtensionFunction::ResponseAction ScriptingInsertCSSFunction::Run() { void ScriptingInsertCSSFunction::DidLoadResources( std::vector file_sources, - absl::optional load_error) { + std::optional load_error) { if (load_error) { Respond(Error(std::move(*load_error))); return; @@ -850,7 +850,7 @@ ScriptingRemoveCSSFunction::ScriptingRemoveCSSFunction() = default; ScriptingRemoveCSSFunction::~ScriptingRemoveCSSFunction() = default; ExtensionFunction::ResponseAction ScriptingRemoveCSSFunction::Run() { - absl::optional params = + std::optional params = api::scripting::RemoveCSS::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -929,7 +929,7 @@ ScriptingRegisterContentScriptsFunction:: ~ScriptingRegisterContentScriptsFunction() = default; ExtensionFunction::ResponseAction ScriptingUpdateContentScriptsFunction::Run() { - absl::optional params = + std::optional params = api::scripting::UpdateContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -1087,7 +1087,7 @@ void ScriptingRegisterContentScriptsFunction::OnContentScriptFilesValidated( } void ScriptingRegisterContentScriptsFunction::OnContentScriptsRegistered( - const absl::optional& error) { + const std::optional& error) { if (error.has_value()) Respond(Error(std::move(*error))); else @@ -1102,11 +1102,11 @@ ScriptingGetRegisteredContentScriptsFunction:: ExtensionFunction::ResponseAction ScriptingGetRegisteredContentScriptsFunction::Run() { - absl::optional params = + std::optional params = api::scripting::GetRegisteredContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); - const absl::optional& filter = + const std::optional& filter = params->filter; std::set id_filter; if (filter && filter->ids) { @@ -1157,7 +1157,7 @@ ScriptingUnregisterContentScriptsFunction::Run() { api::scripting::UnregisterContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); - absl::optional& filter = params->filter; + std::optional& filter = params->filter; ExtensionUserScriptLoader* loader = ExtensionSystem::Get(browser_context()) ->user_script_manager() @@ -1206,7 +1206,7 @@ ScriptingUnregisterContentScriptsFunction::Run() { } void ScriptingUnregisterContentScriptsFunction::OnContentScriptsUnregistered( - const absl::optional& error) { + const std::optional& error) { if (error.has_value()) Respond(Error(std::move(*error))); else @@ -1220,7 +1220,7 @@ ScriptingUpdateContentScriptsFunction:: ExtensionFunction::ResponseAction ScriptingRegisterContentScriptsFunction::Run() { - absl::optional params = + std::optional params = api::scripting::RegisterContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -1341,7 +1341,7 @@ void ScriptingUpdateContentScriptsFunction::OnContentScriptFilesValidated( } void ScriptingUpdateContentScriptsFunction::OnContentScriptsUpdated( - const absl::optional& error) { + const std::optional& error) { if (error.has_value()) Respond(Error(std::move(*error))); else diff --git a/shell/browser/extensions/api/scripting/scripting_api.h b/shell/browser/extensions/api/scripting/scripting_api.h index c0d83ebef704..9466aa8514b1 100644 --- a/shell/browser/extensions/api/scripting/scripting_api.h +++ b/shell/browser/extensions/api/scripting/scripting_api.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_EXTENSIONS_API_SCRIPTING_SCRIPTING_API_H_ #include +#include #include #include #include @@ -16,7 +17,6 @@ #include "extensions/browser/script_executor.h" #include "extensions/common/mojom/code_injection.mojom.h" #include "extensions/common/user_script.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace extensions { @@ -49,7 +49,7 @@ class ScriptingExecuteScriptFunction : public ExtensionFunction { // Called when the resource files to be injected has been loaded. void DidLoadResources(std::vector file_sources, - absl::optional load_error); + std::optional load_error); // Triggers the execution of `sources` in the appropriate context. // Returns true on success; on failure, populates `error`. @@ -78,7 +78,7 @@ class ScriptingInsertCSSFunction : public ExtensionFunction { // Called when the resource files to be injected has been loaded. void DidLoadResources(std::vector file_sources, - absl::optional load_error); + std::optional load_error); // Triggers the execution of `sources` in the appropriate context. // Returns true on success; on failure, populates `error`. @@ -132,7 +132,7 @@ class ScriptingRegisterContentScriptsFunction : public ExtensionFunction { scripting::ValidateScriptsResult result); // Called when content scripts have been registered. - void OnContentScriptsRegistered(const absl::optional& error); + void OnContentScriptsRegistered(const std::optional& error); }; class ScriptingGetRegisteredContentScriptsFunction : public ExtensionFunction { @@ -171,7 +171,7 @@ class ScriptingUnregisterContentScriptsFunction : public ExtensionFunction { ~ScriptingUnregisterContentScriptsFunction() override; // Called when content scripts have been unregistered. - void OnContentScriptsUnregistered(const absl::optional& error); + void OnContentScriptsUnregistered(const std::optional& error); }; class ScriptingUpdateContentScriptsFunction : public ExtensionFunction { @@ -197,7 +197,7 @@ class ScriptingUpdateContentScriptsFunction : public ExtensionFunction { scripting::ValidateScriptsResult result); // Called when content scripts have been updated. - void OnContentScriptsUpdated(const absl::optional& error); + void OnContentScriptsUpdated(const std::optional& error); }; } // namespace extensions diff --git a/shell/browser/extensions/api/tabs/tabs_api.cc b/shell/browser/extensions/api/tabs/tabs_api.cc index 1252bc5a9b61..bbe0c14e3537 100644 --- a/shell/browser/extensions/api/tabs/tabs_api.cc +++ b/shell/browser/extensions/api/tabs/tabs_api.cc @@ -71,7 +71,7 @@ void ZoomModeToZoomSettings(WebContentsZoomController::ZoomMode zoom_mode, // Returns true if either |boolean| is disengaged, or if |boolean| and // |value| are equal. This function is used to check if a tab's parameters match // those of the browser. -bool MatchesBool(const absl::optional& boolean, bool value) { +bool MatchesBool(const std::optional& boolean, bool value) { return !boolean || *boolean == value; } @@ -210,7 +210,7 @@ bool TabsExecuteScriptFunction::ShouldRemoveCSS() const { } ExtensionFunction::ResponseAction TabsReloadFunction::Run() { - absl::optional params = + std::optional params = tabs::Reload::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -233,7 +233,7 @@ ExtensionFunction::ResponseAction TabsReloadFunction::Run() { } ExtensionFunction::ResponseAction TabsQueryFunction::Run() { - absl::optional params = + std::optional params = tabs::Query::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -255,8 +255,8 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() { } std::string title = params->query_info.title.value_or(std::string()); - absl::optional audible = params->query_info.audible; - absl::optional muted = params->query_info.muted; + std::optional audible = params->query_info.audible; + std::optional muted = params->query_info.muted; base::Value::List result; @@ -321,7 +321,7 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() { } ExtensionFunction::ResponseAction TabsGetFunction::Run() { - absl::optional params = tabs::Get::Params::Create(args()); + std::optional params = tabs::Get::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); int tab_id = params->tab_id; @@ -349,7 +349,7 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() { } ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() { - absl::optional params = + std::optional params = tabs::SetZoom::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -377,7 +377,7 @@ ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() { } ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() { - absl::optional params = + std::optional params = tabs::GetZoomSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -393,7 +393,7 @@ ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() { } ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() { - absl::optional params = + std::optional params = tabs::GetZoomSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -417,7 +417,7 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() { ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() { using tabs::ZoomSettings; - absl::optional params = + std::optional params = tabs::SetZoomSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -588,7 +588,7 @@ base::expected PrepareURLForNavigation( TabsUpdateFunction::TabsUpdateFunction() : web_contents_(nullptr) {} ExtensionFunction::ResponseAction TabsUpdateFunction::Run() { - absl::optional params = + std::optional params = tabs::Update::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); diff --git a/shell/browser/extensions/electron_messaging_delegate.cc b/shell/browser/extensions/electron_messaging_delegate.cc index aec0ba411553..487515f12f75 100644 --- a/shell/browser/extensions/electron_messaging_delegate.cc +++ b/shell/browser/extensions/electron_messaging_delegate.cc @@ -41,7 +41,7 @@ ElectronMessagingDelegate::IsNativeMessagingHostAllowed( return PolicyPermission::DISALLOW; } -absl::optional ElectronMessagingDelegate::MaybeGetTabInfo( +std::optional ElectronMessagingDelegate::MaybeGetTabInfo( content::WebContents* web_contents) { if (web_contents) { auto* api_contents = electron::api::WebContents::From(web_contents); @@ -54,7 +54,7 @@ absl::optional ElectronMessagingDelegate::MaybeGetTabInfo( return tab.ToValue(); } } - return absl::nullopt; + return std::nullopt; } content::WebContents* ElectronMessagingDelegate::GetWebContentsByTabId( diff --git a/shell/browser/extensions/electron_messaging_delegate.h b/shell/browser/extensions/electron_messaging_delegate.h index 1b6c921a73f2..67b6aabe8144 100644 --- a/shell/browser/extensions/electron_messaging_delegate.h +++ b/shell/browser/extensions/electron_messaging_delegate.h @@ -27,7 +27,7 @@ class ElectronMessagingDelegate : public MessagingDelegate { PolicyPermission IsNativeMessagingHostAllowed( content::BrowserContext* browser_context, const std::string& native_host_name) override; - absl::optional MaybeGetTabInfo( + std::optional MaybeGetTabInfo( content::WebContents* web_contents) override; content::WebContents* GetWebContentsByTabId( content::BrowserContext* browser_context, diff --git a/shell/browser/login_handler.cc b/shell/browser/login_handler.cc index 446562c57e3c..44d14b146350 100644 --- a/shell/browser/login_handler.cc +++ b/shell/browser/login_handler.cc @@ -52,7 +52,7 @@ void LoginHandler::EmitEvent( api::WebContents* api_web_contents = api::WebContents::From(web_contents()); if (!api_web_contents) { - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); return; } @@ -75,7 +75,7 @@ void LoginHandler::EmitEvent( // deleted. Check the weak ptr before accessing any member variables to // prevent UAF. if (weak_this && !default_prevented && auth_required_callback_) { - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); } } @@ -85,7 +85,7 @@ void LoginHandler::CallbackFromJS(gin::Arguments* args) { if (auth_required_callback_) { std::u16string username, password; if (!args->GetNext(&username) || !args->GetNext(&password)) { - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); return; } std::move(auth_required_callback_) diff --git a/shell/browser/mac/in_app_purchase_observer.h b/shell/browser/mac/in_app_purchase_observer.h index a5e610091fb3..b8a1b4cdb8cb 100644 --- a/shell/browser/mac/in_app_purchase_observer.h +++ b/shell/browser/mac/in_app_purchase_observer.h @@ -5,13 +5,13 @@ #ifndef ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_ #define ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_ +#include #include #include #include "base/functional/callback.h" #include "base/memory/raw_ptr_exclusion.h" #include "base/memory/weak_ptr.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if defined(__OBJC__) @class InAppTransactionObserver; @@ -39,7 +39,7 @@ struct Payment { std::string productIdentifier = ""; int quantity = 1; std::string applicationUsername; - absl::optional paymentDiscount; + std::optional paymentDiscount; Payment(); Payment(const Payment&); diff --git a/shell/browser/mac/in_app_purchase_product.h b/shell/browser/mac/in_app_purchase_product.h index ad76841ffb6b..753f0d63170a 100644 --- a/shell/browser/mac/in_app_purchase_product.h +++ b/shell/browser/mac/in_app_purchase_product.h @@ -5,11 +5,11 @@ #ifndef ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_PRODUCT_H_ #define ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_PRODUCT_H_ +#include #include #include #include "base/functional/callback.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace in_app_purchase { @@ -31,7 +31,7 @@ struct ProductDiscount { std::string priceLocale; std::string paymentMode; int numberOfPeriods; - absl::optional subscriptionPeriod; + std::optional subscriptionPeriod; ProductDiscount(const ProductDiscount&); ProductDiscount(); @@ -50,10 +50,10 @@ struct Product { double price = 0.0; std::string formattedPrice; std::string currencyCode; - absl::optional introductoryPrice; + std::optional introductoryPrice; std::vector discounts; std::string subscriptionGroupIdentifier; - absl::optional subscriptionPeriod; + std::optional subscriptionPeriod; // Downloadable Content Information bool isDownloadable = false; diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 3be30d4455f4..46a0c7fc49e0 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -488,7 +488,7 @@ bool NativeWindow::AddTabbedWindow(NativeWindow* window) { return true; // for non-Mac platforms } -absl::optional NativeWindow::GetTabbingIdentifier() const { +std::optional NativeWindow::GetTabbingIdentifier() const { return ""; // for non-Mac platforms } @@ -539,7 +539,7 @@ void NativeWindow::PreviewFile(const std::string& path, void NativeWindow::CloseFilePreview() {} -absl::optional NativeWindow::GetWindowControlsOverlayRect() { +std::optional NativeWindow::GetWindowControlsOverlayRect() { return overlay_rect_; } diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index b2d215854bcb..bc7868cc07f5 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include "shell/browser/draggable_region_provider.h" #include "shell/browser/native_window_observer.h" #include "shell/browser/ui/inspectable_web_contents_view.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/widget/widget_delegate.h" class SkRegion; @@ -229,8 +229,8 @@ class NativeWindow : public base::SupportsUserData, #if BUILDFLAG(IS_MAC) virtual void SetWindowButtonVisibility(bool visible) = 0; virtual bool GetWindowButtonVisibility() const = 0; - virtual void SetWindowButtonPosition(absl::optional position) = 0; - virtual absl::optional GetWindowButtonPosition() const = 0; + virtual void SetWindowButtonPosition(std::optional position) = 0; + virtual std::optional GetWindowButtonPosition() const = 0; virtual void RedrawTrafficLights() = 0; virtual void UpdateFrame() = 0; #endif @@ -254,7 +254,7 @@ class NativeWindow : public base::SupportsUserData, virtual void MoveTabToNewWindow(); virtual void ToggleTabBar(); virtual bool AddTabbedWindow(NativeWindow* window); - virtual absl::optional GetTabbingIdentifier() const; + virtual std::optional GetTabbingIdentifier() const; // Toggle the menu bar. virtual void SetAutoHideMenuBar(bool auto_hide); @@ -284,7 +284,7 @@ class NativeWindow : public base::SupportsUserData, return weak_factory_.GetWeakPtr(); } - virtual absl::optional GetWindowControlsOverlayRect(); + virtual std::optional GetWindowControlsOverlayRect(); virtual void SetWindowControlsOverlayRect(const gfx::Rect& overlay_rect); // Methods called by the WebContents. @@ -433,11 +433,11 @@ class NativeWindow : public base::SupportsUserData, TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal; // Minimum and maximum size. - absl::optional size_constraints_; + std::optional size_constraints_; // Same as above but stored as content size, we are storing 2 types of size // constraints beacause converting between them will cause rounding errors // on HiDPI displays on some environments. - absl::optional content_size_constraints_; + std::optional content_size_constraints_; std::queue pending_transitions_; FullScreenTransitionState fullscreen_transition_state_ = diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index 3abbe323adf9..fd359e9cce96 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -8,6 +8,7 @@ #import #include +#include #include #include @@ -127,8 +128,8 @@ class NativeWindowMac : public NativeWindow, void SetVibrancy(const std::string& type) override; void SetWindowButtonVisibility(bool visible) override; bool GetWindowButtonVisibility() const override; - void SetWindowButtonPosition(absl::optional position) override; - absl::optional GetWindowButtonPosition() const override; + void SetWindowButtonPosition(std::optional position) override; + std::optional GetWindowButtonPosition() const override; void RedrawTrafficLights() override; void UpdateFrame() override; void SetTouchBar( @@ -142,7 +143,7 @@ class NativeWindowMac : public NativeWindow, void MoveTabToNewWindow() override; void ToggleTabBar() override; bool AddTabbedWindow(NativeWindow* window) override; - absl::optional GetTabbingIdentifier() const override; + std::optional GetTabbingIdentifier() const override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; void PreviewFile(const std::string& path, @@ -150,7 +151,7 @@ class NativeWindowMac : public NativeWindow, void CloseFilePreview() override; gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override; gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override; - absl::optional GetWindowControlsOverlayRect() override; + std::optional GetWindowControlsOverlayRect() override; void NotifyWindowEnterFullScreen() override; void NotifyWindowLeaveFullScreen() override; void SetActive(bool is_key) override; @@ -249,7 +250,7 @@ class NativeWindowMac : public NativeWindow, bool fullscreen_before_kiosk_ = false; bool is_kiosk_ = false; bool zoom_to_page_width_ = false; - absl::optional traffic_light_position_; + std::optional traffic_light_position_; // Trying to close an NSWindow during a fullscreen transition will cause the // window to lock up. Use this to track if CloseWindow was called during a @@ -271,7 +272,7 @@ class NativeWindowMac : public NativeWindow, // The visibility mode of window button controls when explicitly set through // setWindowButtonVisibility(). - absl::optional window_button_visibility_; + std::optional window_button_visibility_; // Controls the position and visibility of window buttons. WindowButtonsProxy* __strong buttons_proxy_; diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 0064431cc23a..9e87c14ea4ba 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1545,7 +1545,7 @@ bool NativeWindowMac::GetWindowButtonVisibility() const { } void NativeWindowMac::SetWindowButtonPosition( - absl::optional position) { + std::optional position) { traffic_light_position_ = std::move(position); if (buttons_proxy_) { [buttons_proxy_ setMargin:traffic_light_position_]; @@ -1553,7 +1553,7 @@ void NativeWindowMac::SetWindowButtonPosition( } } -absl::optional NativeWindowMac::GetWindowButtonPosition() const { +std::optional NativeWindowMac::GetWindowButtonPosition() const { return traffic_light_position_; } @@ -1623,9 +1623,9 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) { return true; } -absl::optional NativeWindowMac::GetTabbingIdentifier() const { +std::optional NativeWindowMac::GetTabbingIdentifier() const { if ([window_ tabbingMode] == NSWindowTabbingModeDisallowed) - return absl::nullopt; + return std::nullopt; return base::SysNSStringToUTF8([window_ tabbingIdentifier]); } @@ -1870,9 +1870,9 @@ void NativeWindowMac::SetForwardMouseMessages(bool forward) { [window_ setAcceptsMouseMovedEvents:forward]; } -absl::optional NativeWindowMac::GetWindowControlsOverlayRect() { +std::optional NativeWindowMac::GetWindowControlsOverlayRect() { if (!titlebar_overlay_) - return absl::nullopt; + return std::nullopt; // On macOS, when in fullscreen mode, window controls (the menu bar, title // bar, and toolbar) are attached to a separate NSView that slides down from @@ -1896,7 +1896,7 @@ absl::optional NativeWindowMac::GetWindowControlsOverlayRect() { return overlay; } - return absl::nullopt; + return std::nullopt; } // static diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index f8b1d272c4f3..e5683cecf00d 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -8,6 +8,7 @@ #include "shell/browser/native_window.h" #include +#include #include #include @@ -304,7 +305,7 @@ class NativeWindowViews : public NativeWindow, // Whether the window is currently being moved. bool is_moving_ = false; - absl::optional pending_bounds_change_; + std::optional pending_bounds_change_; // The color to use as the theme and symbol colors respectively for Window // Controls Overlay if enabled on Windows. diff --git a/shell/browser/net/asar/asar_file_validator.h b/shell/browser/net/asar/asar_file_validator.h index b5ba25770e1f..31a8a05d8edc 100644 --- a/shell/browser/net/asar/asar_file_validator.h +++ b/shell/browser/net/asar/asar_file_validator.h @@ -7,12 +7,12 @@ #include #include +#include #include "crypto/secure_hash.h" #include "mojo/public/cpp/system/file_data_source.h" #include "mojo/public/cpp/system/filtered_data_source.h" #include "shell/common/asar/archive.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace asar { diff --git a/shell/browser/net/asar/asar_url_loader.cc b/shell/browser/net/asar/asar_url_loader.cc index 74a43533130e..c1e83c5d6e75 100644 --- a/shell/browser/net/asar/asar_url_loader.cc +++ b/shell/browser/net/asar/asar_url_loader.cc @@ -78,7 +78,7 @@ class AsarURLLoader : public network::mojom::URLLoader { const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) override {} + const std::optional& new_url) override {} void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} @@ -270,7 +270,7 @@ class AsarURLLoader : public network::mojom::URLLoader { head->mime_type.c_str()); } client_->OnReceiveResponse(std::move(head), std::move(consumer_handle), - absl::nullopt); + std::nullopt); if (total_bytes_to_send == 0) { // There's definitely no more data, so we're already done. diff --git a/shell/browser/net/cert_verifier_client.cc b/shell/browser/net/cert_verifier_client.cc index bf14cdb39727..0a9d2dca851f 100644 --- a/shell/browser/net/cert_verifier_client.cc +++ b/shell/browser/net/cert_verifier_client.cc @@ -26,7 +26,7 @@ void CertVerifierClient::Verify( const scoped_refptr& certificate, const std::string& hostname, int flags, - const absl::optional& ocsp_response, + const std::optional& ocsp_response, VerifyCallback callback) { VerifyRequestParams params; params.hostname = hostname; diff --git a/shell/browser/net/cert_verifier_client.h b/shell/browser/net/cert_verifier_client.h index f46eaf87b51d..975c5b787140 100644 --- a/shell/browser/net/cert_verifier_client.h +++ b/shell/browser/net/cert_verifier_client.h @@ -40,7 +40,7 @@ class CertVerifierClient : public network::mojom::CertVerifierClient { const scoped_refptr& certificate, const std::string& hostname, int flags, - const absl::optional& ocsp_response, + const std::optional& ocsp_response, VerifyCallback callback) override; private: diff --git a/shell/browser/net/electron_url_loader_factory.cc b/shell/browser/net/electron_url_loader_factory.cc index 933c706c0158..e07730ccdede 100644 --- a/shell/browser/net/electron_url_loader_factory.cc +++ b/shell/browser/net/electron_url_loader_factory.cc @@ -211,7 +211,7 @@ void ElectronURLLoaderFactory::RedirectedRequest::FollowRedirect( const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) { + const std::optional& new_url) { // Update |request_| with info from the redirect, so that it's accurate // The following references code in WorkerScriptLoader::FollowRedirect bool should_clear_upload = false; @@ -592,7 +592,7 @@ void ElectronURLLoaderFactory::StartLoadingStream( // Note that We must submit a empty body otherwise NetworkService would // crash. client_remote->OnReceiveResponse(std::move(head), std::move(consumer), - absl::nullopt); + std::nullopt); producer.reset(); // The data pipe is empty. client_remote->OnComplete(network::URLLoaderCompletionStatus(net::OK)); return; @@ -640,7 +640,7 @@ void ElectronURLLoaderFactory::SendContents( } client_remote->OnReceiveResponse(std::move(head), std::move(consumer), - absl::nullopt); + std::nullopt); auto write_data = std::make_unique(); write_data->client = std::move(client_remote); diff --git a/shell/browser/net/electron_url_loader_factory.h b/shell/browser/net/electron_url_loader_factory.h index 60a451332ea5..9fd628bddd88 100644 --- a/shell/browser/net/electron_url_loader_factory.h +++ b/shell/browser/net/electron_url_loader_factory.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_NET_ELECTRON_URL_LOADER_FACTORY_H_ #include +#include #include #include #include @@ -21,7 +22,6 @@ #include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" #include "shell/common/gin_helper/dictionary.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { @@ -73,7 +73,7 @@ class ElectronURLLoaderFactory : public network::SelfDeletingURLLoaderFactory { const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) override; + const std::optional& new_url) override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} diff --git a/shell/browser/net/node_stream_loader.cc b/shell/browser/net/node_stream_loader.cc index d0ea49cd9c68..d11e5eccba7a 100644 --- a/shell/browser/net/node_stream_loader.cc +++ b/shell/browser/net/node_stream_loader.cc @@ -59,7 +59,7 @@ void NodeStreamLoader::Start(network::mojom::URLResponseHeadPtr head) { producer_ = std::make_unique(std::move(producer)); client_->OnReceiveResponse(std::move(head), std::move(consumer), - absl::nullopt); + std::nullopt); auto weak = weak_factory_.GetWeakPtr(); On("end", diff --git a/shell/browser/net/node_stream_loader.h b/shell/browser/net/node_stream_loader.h index 5629f64b5584..5ca1e9b29993 100644 --- a/shell/browser/net/node_stream_loader.h +++ b/shell/browser/net/node_stream_loader.h @@ -60,7 +60,7 @@ class NodeStreamLoader : public network::mojom::URLLoader { const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) override {} + const std::optional& new_url) override {} void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc index 3d38d753969b..2a0728105ffe 100644 --- a/shell/browser/net/proxying_url_loader_factory.cc +++ b/shell/browser/net/proxying_url_loader_factory.cc @@ -93,11 +93,11 @@ ProxyingURLLoaderFactory::InProgressRequest::~InProgressRequest() { } if (on_before_send_headers_callback_) { std::move(on_before_send_headers_callback_) - .Run(net::ERR_ABORTED, absl::nullopt); + .Run(net::ERR_ABORTED, std::nullopt); } if (on_headers_received_callback_) { std::move(on_headers_received_callback_) - .Run(net::ERR_ABORTED, absl::nullopt, absl::nullopt); + .Run(net::ERR_ABORTED, std::nullopt, std::nullopt); } } @@ -182,7 +182,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::FollowRedirect( const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) { + const std::optional& new_url) { if (new_url) request_.url = new_url.value(); @@ -241,7 +241,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveEarlyHints( void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse( network::mojom::URLResponseHeadPtr head, mojo::ScopedDataPipeConsumerHandle body, - absl::optional cached_metadata) { + std::optional cached_metadata) { current_body_ = std::move(body); current_cached_metadata_ = std::move(cached_metadata); if (current_request_uses_header_client_) { @@ -342,7 +342,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnBeforeSendHeaders( const net::HttpRequestHeaders& headers, OnBeforeSendHeadersCallback callback) { if (!current_request_uses_header_client_) { - std::move(callback).Run(net::OK, absl::nullopt); + std::move(callback).Run(net::OK, std::nullopt); return; } @@ -356,7 +356,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived( const net::IPEndPoint& remote_endpoint, OnHeadersReceivedCallback callback) { if (!current_request_uses_header_client_) { - std::move(callback).Run(net::OK, absl::nullopt, GURL()); + std::move(callback).Run(net::OK, std::nullopt, GURL()); if (for_cors_preflight_) { // CORS preflight is supported only when "extraHeaders" is specified. @@ -581,7 +581,7 @@ void ProxyingURLLoaderFactory::InProgressRequest:: } DCHECK(on_headers_received_callback_); - absl::optional headers; + std::optional headers; if (override_headers_) { headers = override_headers_->raw_headers(); if (current_request_uses_header_client_) { @@ -749,7 +749,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory( int frame_routing_id, uint64_t* request_id_generator, std::unique_ptr navigation_ui_data, - absl::optional navigation_id, + std::optional navigation_id, mojo::PendingReceiver loader_request, mojo::PendingRemote target_factory_remote, mojo::PendingReceiver diff --git a/shell/browser/net/proxying_url_loader_factory.h b/shell/browser/net/proxying_url_loader_factory.h index 49a107e5d5f4..828c7da67faf 100644 --- a/shell/browser/net/proxying_url_loader_factory.h +++ b/shell/browser/net/proxying_url_loader_factory.h @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include "services/network/url_loader_factory.h" #include "shell/browser/net/electron_url_loader_factory.h" #include "shell/browser/net/web_request_api_interface.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace electron { @@ -83,7 +83,7 @@ class ProxyingURLLoaderFactory const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) override; + const std::optional& new_url) override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override; void PauseReadingBodyFromNet() override; @@ -95,7 +95,7 @@ class ProxyingURLLoaderFactory void OnReceiveResponse( network::mojom::URLResponseHeadPtr head, mojo::ScopedDataPipeConsumerHandle body, - absl::optional cached_metadata) override; + std::optional cached_metadata) override; void OnReceiveRedirect(const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr head) override; void OnUploadProgress(int64_t current_position, @@ -135,7 +135,7 @@ class ProxyingURLLoaderFactory raw_ptr const factory_; network::ResourceRequest request_; - const absl::optional original_initiator_; + const std::optional original_initiator_; const uint64_t request_id_ = 0; const int32_t network_service_request_id_ = 0; const int32_t frame_routing_id_ = MSG_ROUTING_NONE; @@ -144,7 +144,7 @@ class ProxyingURLLoaderFactory mojo::Receiver proxied_loader_receiver_; mojo::Remote target_client_; - absl::optional info_; + std::optional info_; mojo::Receiver proxied_client_receiver_{ this}; @@ -180,7 +180,7 @@ class ProxyingURLLoaderFactory std::vector removed_headers; net::HttpRequestHeaders modified_headers; net::HttpRequestHeaders modified_cors_exempt_headers; - absl::optional new_url; + std::optional new_url; // disable copy FollowRedirectParams(const FollowRedirectParams&) = delete; @@ -188,7 +188,7 @@ class ProxyingURLLoaderFactory }; std::unique_ptr pending_follow_redirect_params_; - absl::optional current_cached_metadata_; + std::optional current_cached_metadata_; base::WeakPtrFactory weak_factory_{this}; }; @@ -200,7 +200,7 @@ class ProxyingURLLoaderFactory int frame_routing_id, uint64_t* request_id_generator, std::unique_ptr navigation_ui_data, - absl::optional navigation_id, + std::optional navigation_id, mojo::PendingReceiver loader_request, mojo::PendingRemote target_factory_remote, @@ -264,7 +264,7 @@ class ProxyingURLLoaderFactory const int frame_routing_id_; raw_ptr request_id_generator_; // managed by ElectronBrowserClient std::unique_ptr navigation_ui_data_; - absl::optional navigation_id_; + std::optional navigation_id_; mojo::ReceiverSet proxy_receivers_; mojo::Remote target_factory_; mojo::Receiver diff --git a/shell/browser/net/proxying_websocket.cc b/shell/browser/net/proxying_websocket.cc index 3519f67d3682..ae73b6d70f67 100644 --- a/shell/browser/net/proxying_websocket.cc +++ b/shell/browser/net/proxying_websocket.cc @@ -44,16 +44,16 @@ ProxyingWebSocket::ProxyingWebSocket( /*is_download=*/false, /*is_async=*/true, /*is_service_worker_script=*/false, - /*navigation_id=*/absl::nullopt)) {} + /*navigation_id=*/std::nullopt)) {} ProxyingWebSocket::~ProxyingWebSocket() { if (on_before_send_headers_callback_) { std::move(on_before_send_headers_callback_) - .Run(net::ERR_ABORTED, absl::nullopt); + .Run(net::ERR_ABORTED, std::nullopt); } if (on_headers_received_callback_) { std::move(on_headers_received_callback_) - .Run(net::ERR_ABORTED, absl::nullopt, GURL()); + .Run(net::ERR_ABORTED, std::nullopt, GURL()); } } @@ -229,7 +229,7 @@ void ProxyingWebSocket::StartProxying( WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional& user_agent, + const std::optional& user_agent, mojo::PendingRemote handshake_client, bool has_extra_headers, @@ -358,11 +358,11 @@ void ProxyingWebSocket::OnHeadersReceivedComplete(int error_code) { } if (on_headers_received_callback_) { - absl::optional headers; + std::optional headers; if (override_headers_) headers = override_headers_->raw_headers(); std::move(on_headers_received_callback_) - .Run(net::OK, headers, absl::nullopt); + .Run(net::OK, headers, std::nullopt); } if (override_headers_) { @@ -384,7 +384,7 @@ void ProxyingWebSocket::OnAuthRequiredComplete(AuthRequiredResponse rv) { switch (rv) { case AuthRequiredResponse::kNoAction: case AuthRequiredResponse::kCancelAuth: - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); break; case AuthRequiredResponse::kSetAuth: diff --git a/shell/browser/net/proxying_websocket.h b/shell/browser/net/proxying_websocket.h index 96dc08bb5832..c3e953c2f794 100644 --- a/shell/browser/net/proxying_websocket.h +++ b/shell/browser/net/proxying_websocket.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_ #define ELECTRON_SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_ +#include #include #include #include @@ -19,7 +20,6 @@ #include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/websocket.mojom.h" #include "shell/browser/net/web_request_api_interface.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -101,7 +101,7 @@ class ProxyingWebSocket : public network::mojom::WebSocketHandshakeClient, WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional& user_agent, + const std::optional& user_agent, mojo::PendingRemote handshake_client, bool has_extra_headers, diff --git a/shell/browser/net/resolve_host_function.cc b/shell/browser/net/resolve_host_function.cc index 3071955e922c..826511f0067d 100644 --- a/shell/browser/net/resolve_host_function.cc +++ b/shell/browser/net/resolve_host_function.cc @@ -53,8 +53,8 @@ void ResolveHostFunction::Run() { receiver_.set_disconnect_handler(base::BindOnce( &ResolveHostFunction::OnComplete, this, net::ERR_NAME_NOT_RESOLVED, net::ResolveErrorInfo(net::ERR_FAILED), - /*resolved_addresses=*/absl::nullopt, - /*endpoint_results_with_metadata=*/absl::nullopt)); + /*resolved_addresses=*/std::nullopt, + /*endpoint_results_with_metadata=*/std::nullopt)); if (electron::IsUtilityProcess()) { URLLoaderBundle::GetInstance()->GetHostResolver()->ResolveHost( network::mojom::HostResolverHost::NewHostPortPair( @@ -75,8 +75,8 @@ void ResolveHostFunction::Run() { void ResolveHostFunction::OnComplete( int result, const net::ResolveErrorInfo& resolve_error_info, - const absl::optional& resolved_addresses, - const absl::optional& + const std::optional& resolved_addresses, + const std::optional& endpoint_results_with_metadata) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); diff --git a/shell/browser/net/resolve_host_function.h b/shell/browser/net/resolve_host_function.h index a860e09d5f6f..0260faaa225a 100644 --- a/shell/browser/net/resolve_host_function.h +++ b/shell/browser/net/resolve_host_function.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NET_RESOLVE_HOST_FUNCTION_H_ #define ELECTRON_SHELL_BROWSER_NET_RESOLVE_HOST_FUNCTION_H_ +#include #include #include "base/memory/raw_ptr.h" @@ -16,7 +17,6 @@ #include "services/network/public/cpp/resolve_host_client_base.h" #include "services/network/public/mojom/host_resolver.mojom.h" #include "services/network/public/mojom/network_context.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { @@ -26,9 +26,8 @@ class ResolveHostFunction : public base::RefCountedThreadSafe, network::ResolveHostClientBase { public: - using ResolveHostCallback = base::OnceCallback& resolved_addresses)>; + using ResolveHostCallback = base::OnceCallback< + void(int64_t, const std::optional& resolved_addresses)>; explicit ResolveHostFunction(ElectronBrowserContext* browser_context, std::string host, @@ -50,8 +49,8 @@ class ResolveHostFunction // network::mojom::ResolveHostClient implementation void OnComplete(int result, const net::ResolveErrorInfo& resolve_error_info, - const absl::optional& resolved_addresses, - const absl::optional& + const std::optional& resolved_addresses, + const std::optional& endpoint_results_with_metadata) override; SEQUENCE_CHECKER(sequence_checker_); diff --git a/shell/browser/net/resolve_proxy_helper.cc b/shell/browser/net/resolve_proxy_helper.cc index 474a3ec49403..106e86316974 100644 --- a/shell/browser/net/resolve_proxy_helper.cc +++ b/shell/browser/net/resolve_proxy_helper.cc @@ -53,7 +53,7 @@ void ResolveProxyHelper::StartPendingRequest() { receiver_.BindNewPipeAndPassRemote(); receiver_.set_disconnect_handler( base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete, - base::Unretained(this), net::ERR_ABORTED, absl::nullopt)); + base::Unretained(this), net::ERR_ABORTED, std::nullopt)); browser_context_->GetDefaultStoragePartition() ->GetNetworkContext() ->LookUpProxyForURL(pending_requests_.front().url, @@ -63,7 +63,7 @@ void ResolveProxyHelper::StartPendingRequest() { void ResolveProxyHelper::OnProxyLookupComplete( int32_t net_error, - const absl::optional& proxy_info) { + const std::optional& proxy_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!pending_requests_.empty()); diff --git a/shell/browser/net/resolve_proxy_helper.h b/shell/browser/net/resolve_proxy_helper.h index 632e16004183..20c998be26cf 100644 --- a/shell/browser/net/resolve_proxy_helper.h +++ b/shell/browser/net/resolve_proxy_helper.h @@ -6,13 +6,13 @@ #define ELECTRON_SHELL_BROWSER_NET_RESOLVE_PROXY_HELPER_H_ #include +#include #include #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "mojo/public/cpp/bindings/receiver.h" #include "services/network/public/mojom/proxy_lookup_client.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace electron { @@ -61,7 +61,7 @@ class ResolveProxyHelper // network::mojom::ProxyLookupClient implementation. void OnProxyLookupComplete( int32_t net_error, - const absl::optional& proxy_info) override; + const std::optional& proxy_info) override; // Self-reference. Owned as long as there's an outstanding proxy lookup. scoped_refptr owned_self_; diff --git a/shell/browser/net/system_network_context_manager.h b/shell/browser/net/system_network_context_manager.h index dfce7949f7d2..819894da4cae 100644 --- a/shell/browser/net/system_network_context_manager.h +++ b/shell/browser/net/system_network_context_manager.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_ #define ELECTRON_SHELL_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_ +#include + #include "base/memory/ref_counted.h" #include "chrome/browser/net/proxy_config_monitor.h" #include "mojo/public/cpp/bindings/remote.h" @@ -14,7 +16,6 @@ #include "services/network/public/mojom/network_service.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams(); diff --git a/shell/browser/net/url_pipe_loader.cc b/shell/browser/net/url_pipe_loader.cc index ff53323ffab5..688613deee02 100644 --- a/shell/browser/net/url_pipe_loader.cc +++ b/shell/browser/net/url_pipe_loader.cc @@ -72,7 +72,7 @@ void URLPipeLoader::OnResponseStarted( producer_ = std::make_unique(std::move(producer)); client_->OnReceiveResponse(response_head.Clone(), std::move(consumer), - absl::nullopt); + std::nullopt); } void URLPipeLoader::OnWrite(base::OnceClosure resume, MojoResult result) { diff --git a/shell/browser/net/url_pipe_loader.h b/shell/browser/net/url_pipe_loader.h index e55a771ea165..bb302084bd34 100644 --- a/shell/browser/net/url_pipe_loader.h +++ b/shell/browser/net/url_pipe_loader.h @@ -68,7 +68,7 @@ class URLPipeLoader : public network::mojom::URLLoader, const std::vector& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional& new_url) override {} + const std::optional& new_url) override {} void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index d9bd9211cca7..12e45ae54464 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -31,7 +32,6 @@ #include "content/public/browser/render_process_host.h" #include "gpu/command_buffer/client/gl_helper.h" #include "media/base/video_frame.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/skia/include/core/SkCanvas.h" #include "ui/compositor/compositor.h" @@ -355,7 +355,7 @@ void OffScreenRenderWidgetHostView::SetBackgroundColor(SkColor color) { } } -absl::optional OffScreenRenderWidgetHostView::GetBackgroundColor() { +std::optional OffScreenRenderWidgetHostView::GetBackgroundColor() { return background_color_; } @@ -508,9 +508,9 @@ gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() { return gfx::Rect(size_); } -absl::optional +std::optional OffScreenRenderWidgetHostView::GetDisplayFeature() { - return absl::nullopt; + return std::nullopt; } void OffScreenRenderWidgetHostView::SetDisplayFeatureForTesting( @@ -530,8 +530,8 @@ OffScreenRenderWidgetHostView::CreateSyntheticGestureTarget() { void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged( const gfx::Range&, - const absl::optional>& character_bounds, - const absl::optional>& line_bounds) {} + const std::optional>& character_bounds, + const std::optional>& line_bounds) {} gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize() { return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), diff --git a/shell/browser/osr/osr_render_widget_host_view.h b/shell/browser/osr/osr_render_widget_host_view.h index f85d8cc17bc3..fa3da326605a 100644 --- a/shell/browser/osr/osr_render_widget_host_view.h +++ b/shell/browser/osr/osr_render_widget_host_view.h @@ -95,7 +95,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, gfx::Size GetVisibleViewportSize() override; void SetInsets(const gfx::Insets&) override; void SetBackgroundColor(SkColor color) override; - absl::optional GetBackgroundColor() override; + std::optional GetBackgroundColor() override; void UpdateBackgroundColor() override; blink::mojom::PointerLockResult LockMouse( bool request_unadjusted_movement) override; @@ -141,7 +141,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, display::ScreenInfo GetScreenInfo() const override; void TransformPointToRootSurface(gfx::PointF* point) override; gfx::Rect GetBoundsInRootWindow(void) override; - absl::optional GetDisplayFeature() override; + std::optional GetDisplayFeature() override; void SetDisplayFeatureForTesting( const content::DisplayFeature* display_feature) override; void NotifyHostAndDelegateOnWasShown( @@ -154,8 +154,8 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, CreateSyntheticGestureTarget() override; void ImeCompositionRangeChanged( const gfx::Range&, - const absl::optional>& character_bounds, - const absl::optional>& line_bounds) override; + const std::optional>& character_bounds, + const std::optional>& line_bounds) override; gfx::Size GetCompositorViewportPixelSize() override; ui::Compositor* GetCompositor() override; diff --git a/shell/browser/osr/osr_video_consumer.cc b/shell/browser/osr/osr_video_consumer.cc index f2ed683460e2..917b483e2e98 100644 --- a/shell/browser/osr/osr_video_consumer.cc +++ b/shell/browser/osr/osr_video_consumer.cc @@ -128,7 +128,7 @@ void OffScreenVideoConsumer::OnFrameCaptured( new FramePinner{std::move(mapping), callbacks_remote.Unbind()}); bitmap.setImmutable(); - absl::optional update_rect = info->metadata.capture_update_rect; + std::optional update_rect = info->metadata.capture_update_rect; if (!update_rect.has_value() || update_rect->IsEmpty()) { update_rect = content_rect; } diff --git a/shell/browser/ui/accelerator_util.cc b/shell/browser/ui/accelerator_util.cc index 6f1dfaca36b2..28f1fb9ac44e 100644 --- a/shell/browser/ui/accelerator_util.cc +++ b/shell/browser/ui/accelerator_util.cc @@ -34,7 +34,7 @@ bool StringToAccelerator(const std::string& shortcut, // Now, parse it into an accelerator. int modifiers = ui::EF_NONE; ui::KeyboardCode key = ui::VKEY_UNKNOWN; - absl::optional shifted_char; + std::optional shifted_char; for (const auto& token : tokens) { ui::KeyboardCode code = electron::KeyboardCodeFromStr(token, &shifted_char); if (shifted_char) diff --git a/shell/browser/ui/cocoa/electron_ns_window_delegate.h b/shell/browser/ui/cocoa/electron_ns_window_delegate.h index 97e7dddf3e99..f65d78a095d1 100644 --- a/shell/browser/ui/cocoa/electron_ns_window_delegate.h +++ b/shell/browser/ui/cocoa/electron_ns_window_delegate.h @@ -7,9 +7,10 @@ #include +#include + #include "base/memory/raw_ptr.h" #include "components/remote_cocoa/app_shim/views_nswindow_delegate.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { class NativeWindowMac; @@ -30,7 +31,7 @@ class NativeWindowMac; // Only valid during a live resize. // Used to keep track of whether a resize is happening horizontally or // vertically, even if physically the user is resizing in both directions. - absl::optional resizingHorizontally_; + std::optional resizingHorizontally_; } - (id)initWithShell:(electron::NativeWindowMac*)shell; @end diff --git a/shell/browser/ui/cocoa/window_buttons_proxy.h b/shell/browser/ui/cocoa/window_buttons_proxy.h index 39ef57c4c4bc..77b68d79d1d1 100644 --- a/shell/browser/ui/cocoa/window_buttons_proxy.h +++ b/shell/browser/ui/cocoa/window_buttons_proxy.h @@ -7,7 +7,8 @@ #import -#include "third_party/abseil-cpp/absl/types/optional.h" +#include + #include "ui/gfx/geometry/point.h" @class WindowButtonsProxy; @@ -48,7 +49,7 @@ - (void)setShowOnHover:(BOOL)yes; // Set left-top margin of the window buttons.. -- (void)setMargin:(const absl::optional&)margin; +- (void)setMargin:(const std::optional&)margin; // Set height of button container - (void)setHeight:(const float)height; diff --git a/shell/browser/ui/cocoa/window_buttons_proxy.mm b/shell/browser/ui/cocoa/window_buttons_proxy.mm index 6cc28b279beb..2edf2d22d74e 100644 --- a/shell/browser/ui/cocoa/window_buttons_proxy.mm +++ b/shell/browser/ui/cocoa/window_buttons_proxy.mm @@ -79,7 +79,7 @@ [self updateButtonsVisibility]; } -- (void)setMargin:(const absl::optional&)margin { +- (void)setMargin:(const std::optional&)margin { if (margin) margin_ = *margin; else diff --git a/shell/browser/ui/electron_menu_model.cc b/shell/browser/ui/electron_menu_model.cc index 3f305cb515ed..d85de9d9075e 100644 --- a/shell/browser/ui/electron_menu_model.cc +++ b/shell/browser/ui/electron_menu_model.cc @@ -100,7 +100,7 @@ void ElectronMenuModel::SetSharingItem(SharingItem item) { sharing_item_.emplace(std::move(item)); } -const absl::optional& +const std::optional& ElectronMenuModel::GetSharingItem() const { return sharing_item_; } diff --git a/shell/browser/ui/electron_menu_model.h b/shell/browser/ui/electron_menu_model.h index ba96b14187d7..297b3022885d 100644 --- a/shell/browser/ui/electron_menu_model.h +++ b/shell/browser/ui/electron_menu_model.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_ELECTRON_MENU_MODEL_H_ #define ELECTRON_SHELL_BROWSER_UI_ELECTRON_MENU_MODEL_H_ +#include #include #include @@ -14,7 +15,6 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/observer_list_types.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/models/simple_menu_model.h" #include "url/gurl.h" @@ -29,9 +29,9 @@ class ElectronMenuModel : public ui::SimpleMenuModel { SharingItem(const SharingItem&) = delete; ~SharingItem(); - absl::optional> texts; - absl::optional> urls; - absl::optional> file_paths; + std::optional> texts; + std::optional> urls; + std::optional> file_paths; }; #endif @@ -98,7 +98,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel { bool GetSharingItemAt(size_t index, SharingItem* item) const; // Set/Get the SharingItem of this menu. void SetSharingItem(SharingItem item); - const absl::optional& GetSharingItem() const; + const std::optional& GetSharingItem() const; #endif // ui::SimpleMenuModel: @@ -116,7 +116,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel { raw_ptr delegate_; // weak ref. #if BUILDFLAG(IS_MAC) - absl::optional sharing_item_; + std::optional sharing_item_; #endif base::flat_map toolTips_; // command id -> tooltip diff --git a/shell/browser/ui/message_box.h b/shell/browser/ui/message_box.h index 66932b515d77..489b17a328a0 100644 --- a/shell/browser/ui/message_box.h +++ b/shell/browser/ui/message_box.h @@ -5,12 +5,12 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_ #define ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_ +#include #include #include #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr_exclusion.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gfx/image/image_skia.h" namespace electron { @@ -29,7 +29,7 @@ struct MessageBoxSettings { RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr; MessageBoxType type = electron::MessageBoxType::kNone; std::vector buttons; - absl::optional id; + std::optional id; int default_id; int cancel_id; bool no_link = false; diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index dd5130722cdf..51bb743b0d46 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -192,7 +192,7 @@ class GtkMessageBox : public NativeWindowObserver { private: // The id of the dialog. - absl::optional id_; + std::optional id_; // The id to return when the dialog is closed without pressing buttons. int cancel_id_ = 0; diff --git a/shell/browser/ui/message_box_mac.mm b/shell/browser/ui/message_box_mac.mm index 63d93d3efe53..975e5e0a72ee 100644 --- a/shell/browser/ui/message_box_mac.mm +++ b/shell/browser/ui/message_box_mac.mm @@ -162,7 +162,7 @@ void ShowMessageBox(const MessageBoxSettings& settings, // Duplicate the callback object here since c is a reference and gcd would // only store the pointer, by duplication we can force gcd to store a copy. __block MessageBoxCallback callback_ = std::move(callback); - __block absl::optional id = std::move(settings.id); + __block std::optional id = std::move(settings.id); __block int cancel_id = settings.cancel_id; auto handler = ^(NSModalResponse response) { diff --git a/shell/browser/ui/message_box_win.cc b/shell/browser/ui/message_box_win.cc index f5f64dae5063..3761ccd7d388 100644 --- a/shell/browser/ui/message_box_win.cc +++ b/shell/browser/ui/message_box_win.cc @@ -304,7 +304,7 @@ void ShowMessageBox(const MessageBoxSettings& settings, dialog_thread::Run(base::BindOnce(&ShowTaskDialogUTF8, settings, parent_widget, base::Unretained(hwnd)), base::BindOnce( - [](MessageBoxCallback callback, absl::optional id, + [](MessageBoxCallback callback, std::optional id, DialogResult result) { if (id) GetDialogsMap().erase(*id); diff --git a/shell/browser/ui/tray_icon.h b/shell/browser/ui/tray_icon.h index 98ebe66480d1..03c1a637c874 100644 --- a/shell/browser/ui/tray_icon.h +++ b/shell/browser/ui/tray_icon.h @@ -18,7 +18,7 @@ namespace electron { class TrayIcon { public: - static TrayIcon* Create(absl::optional guid); + static TrayIcon* Create(std::optional guid); #if BUILDFLAG(IS_WIN) using ImageType = HICON; diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index 3e01df792d7d..16dc1b8e24a4 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -422,7 +422,7 @@ gfx::Rect TrayIconCocoa::GetBounds() { } // static -TrayIcon* TrayIcon::Create(absl::optional guid) { +TrayIcon* TrayIcon::Create(std::optional guid) { return new TrayIconCocoa; } diff --git a/shell/browser/ui/tray_icon_linux.cc b/shell/browser/ui/tray_icon_linux.cc index 3309984ef159..c21ecb8e4a53 100644 --- a/shell/browser/ui/tray_icon_linux.cc +++ b/shell/browser/ui/tray_icon_linux.cc @@ -108,7 +108,7 @@ ui::StatusIconLinux* TrayIconLinux::GetStatusIcon() { } // static -TrayIcon* TrayIcon::Create(absl::optional guid) { +TrayIcon* TrayIcon::Create(std::optional guid) { return new TrayIconLinux; } diff --git a/shell/browser/ui/tray_icon_win.cc b/shell/browser/ui/tray_icon_win.cc index 0f4e0059f897..328e83a9d977 100644 --- a/shell/browser/ui/tray_icon_win.cc +++ b/shell/browser/ui/tray_icon_win.cc @@ -8,7 +8,7 @@ namespace electron { // static -TrayIcon* TrayIcon::Create(absl::optional guid) { +TrayIcon* TrayIcon::Create(std::optional guid) { static NotifyIconHost host; return host.CreateNotifyIcon(guid); } diff --git a/shell/browser/ui/views/autofill_popup_view.cc b/shell/browser/ui/views/autofill_popup_view.cc index 67cebf4f7484..9919b1504c71 100644 --- a/shell/browser/ui/views/autofill_popup_view.cc +++ b/shell/browser/ui/views/autofill_popup_view.cc @@ -147,8 +147,8 @@ bool AutofillPopupView::CanStartDragForView(views::View*, } void AutofillPopupView::OnSelectedRowChanged( - absl::optional previous_row_selection, - absl::optional current_row_selection) { + std::optional previous_row_selection, + std::optional current_row_selection) { SchedulePaint(); if (current_row_selection) { @@ -436,7 +436,7 @@ void AutofillPopupView::AcceptSelection(const gfx::Point& point) { AcceptSelectedLine(); } -void AutofillPopupView::SetSelectedLine(absl::optional selected_line) { +void AutofillPopupView::SetSelectedLine(std::optional selected_line) { if (!popup_) return; if (selected_line_ == selected_line) @@ -479,7 +479,7 @@ void AutofillPopupView::SelectPreviousLine() { } void AutofillPopupView::ClearSelection() { - SetSelectedLine(absl::nullopt); + SetSelectedLine(std::nullopt); } void AutofillPopupView::RemoveObserver() { diff --git a/shell/browser/ui/views/autofill_popup_view.h b/shell/browser/ui/views/autofill_popup_view.h index e8e45a42ed80..88420bb4cd74 100644 --- a/shell/browser/ui/views/autofill_popup_view.h +++ b/shell/browser/ui/views/autofill_popup_view.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_UI_VIEWS_AUTOFILL_POPUP_VIEW_H_ #include +#include #include "shell/browser/ui/autofill_popup.h" @@ -14,7 +15,6 @@ #include "content/public/common/input/native_web_keyboard_event.h" #include "electron/buildflags/buildflags.h" #include "shell/browser/osr/osr_view_proxy.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/metadata/metadata_header_macros.h" #include "ui/base/metadata/metadata_impl_macros.h" @@ -84,8 +84,8 @@ class AutofillPopupView : public views::WidgetDelegateView, private: friend class AutofillPopup; - void OnSelectedRowChanged(absl::optional previous_row_selection, - absl::optional current_row_selection); + void OnSelectedRowChanged(std::optional previous_row_selection, + std::optional current_row_selection); // Draw the given autofill entry in |entry_rect|. void DrawAutofillEntry(gfx::Canvas* canvas, @@ -122,7 +122,7 @@ class AutofillPopupView : public views::WidgetDelegateView, void AcceptSuggestion(int index); bool AcceptSelectedLine(); void AcceptSelection(const gfx::Point& point); - void SetSelectedLine(absl::optional selected_line); + void SetSelectedLine(std::optional selected_line); void SetSelection(const gfx::Point& point); void SelectNextLine(); void SelectPreviousLine(); @@ -141,7 +141,7 @@ class AutofillPopupView : public views::WidgetDelegateView, base::Time show_time_; // The index of the currently selected line - absl::optional selected_line_; + std::optional selected_line_; std::unique_ptr view_proxy_; diff --git a/shell/browser/ui/views/menu_delegate.cc b/shell/browser/ui/views/menu_delegate.cc index 589424c04f01..895fc0e0c5e3 100644 --- a/shell/browser/ui/views/menu_delegate.cc +++ b/shell/browser/ui/views/menu_delegate.cc @@ -78,7 +78,7 @@ const gfx::FontList* MenuDelegate::GetLabelFontList(int id) const { return adapter_->GetLabelFontList(id); } -absl::optional MenuDelegate::GetLabelColor(int id) const { +std::optional MenuDelegate::GetLabelColor(int id) const { return adapter_->GetLabelColor(id); } diff --git a/shell/browser/ui/views/menu_delegate.h b/shell/browser/ui/views/menu_delegate.h index 8af32cbcb789..b7511688e8e8 100644 --- a/shell/browser/ui/views/menu_delegate.h +++ b/shell/browser/ui/views/menu_delegate.h @@ -53,7 +53,7 @@ class MenuDelegate : public views::MenuDelegate { bool GetAccelerator(int id, ui::Accelerator* accelerator) const override; std::u16string GetLabel(int id) const override; const gfx::FontList* GetLabelFontList(int id) const override; - absl::optional GetLabelColor(int id) const override; + std::optional GetLabelColor(int id) const override; bool IsCommandEnabled(int id) const override; bool IsCommandVisible(int id) const override; bool IsItemChecked(int id) const override; diff --git a/shell/browser/ui/webui/accessibility_ui.cc b/shell/browser/ui/webui/accessibility_ui.cc index 8006920f0cd6..058dd0d6229a 100644 --- a/shell/browser/ui/webui/accessibility_ui.cc +++ b/shell/browser/ui/webui/accessibility_ui.cc @@ -5,6 +5,7 @@ #include "shell/browser/ui/webui/accessibility_ui.h" #include +#include #include #include #include @@ -42,7 +43,6 @@ #include "content/public/browser/web_ui_data_source.h" #include "shell/browser/native_window.h" #include "shell/browser/window_list.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/accessibility/platform/ax_platform_node.h" #include "ui/accessibility/platform/ax_platform_node_delegate.h" #include "ui/base/webui/web_ui_util.h" diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc index e9dab479abe1..9ec2588c70ce 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc @@ -4,11 +4,12 @@ #include "shell/browser/ui/win/electron_desktop_window_tree_host_win.h" +#include + #include "base/win/windows_version.h" #include "electron/buildflags/buildflags.h" #include "shell/browser/ui/views/win_frame_view.h" #include "shell/browser/win/dark_mode.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/win/hwnd_metrics.h" #include "ui/base/win/shell.h" diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h index 2c627ceeb084..66cf2ae12312 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h @@ -7,8 +7,9 @@ #include +#include + #include "shell/browser/native_window_views.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" namespace electron { @@ -44,7 +45,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin, private: raw_ptr native_window_view_; // weak ref - absl::optional force_should_paint_as_active_; + std::optional force_should_paint_as_active_; }; } // namespace electron diff --git a/shell/browser/ui/win/notify_icon_host.cc b/shell/browser/ui/win/notify_icon_host.cc index 63d0df3d9eda..285d6ab37a7b 100644 --- a/shell/browser/ui/win/notify_icon_host.cc +++ b/shell/browser/ui/win/notify_icon_host.cc @@ -191,7 +191,7 @@ NotifyIconHost::~NotifyIconHost() { delete ptr; } -NotifyIcon* NotifyIconHost::CreateNotifyIcon(absl::optional guid) { +NotifyIcon* NotifyIconHost::CreateNotifyIcon(std::optional guid) { if (guid.has_value()) { for (NotifyIcons::const_iterator i(notify_icons_.begin()); i != notify_icons_.end(); ++i) { diff --git a/shell/browser/ui/win/notify_icon_host.h b/shell/browser/ui/win/notify_icon_host.h index 3b5ce54626ec..b58da039e1d6 100644 --- a/shell/browser/ui/win/notify_icon_host.h +++ b/shell/browser/ui/win/notify_icon_host.h @@ -7,10 +7,10 @@ #include +#include #include #include "shell/common/gin_converters/guid_converter.h" -#include "third_party/abseil-cpp/absl/types/optional.h" const GUID GUID_DEFAULT = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; @@ -27,7 +27,7 @@ class NotifyIconHost { NotifyIconHost(const NotifyIconHost&) = delete; NotifyIconHost& operator=(const NotifyIconHost&) = delete; - NotifyIcon* CreateNotifyIcon(absl::optional guid); + NotifyIcon* CreateNotifyIcon(std::optional guid); void Remove(NotifyIcon* notify_icon); private: diff --git a/shell/browser/web_contents_preferences.cc b/shell/browser/web_contents_preferences.cc index 8c43cd3da1f0..4a7ab227708f 100644 --- a/shell/browser/web_contents_preferences.cc +++ b/shell/browser/web_contents_preferences.cc @@ -119,7 +119,7 @@ void WebContentsPreferences::Clear() { node_integration_in_worker_ = false; disable_html_fullscreen_window_resize_ = false; webview_tag_ = false; - sandbox_ = absl::nullopt; + sandbox_ = std::nullopt; context_isolation_ = true; javascript_ = true; images_ = true; @@ -133,24 +133,24 @@ void WebContentsPreferences::Clear() { navigate_on_drag_drop_ = false; autoplay_policy_ = blink::mojom::AutoplayPolicy::kNoUserGestureRequired; default_font_family_.clear(); - default_font_size_ = absl::nullopt; - default_monospace_font_size_ = absl::nullopt; - minimum_font_size_ = absl::nullopt; - default_encoding_ = absl::nullopt; + default_font_size_ = std::nullopt; + default_monospace_font_size_ = std::nullopt; + minimum_font_size_ = std::nullopt; + default_encoding_ = std::nullopt; is_webview_ = false; custom_args_.clear(); custom_switches_.clear(); - enable_blink_features_ = absl::nullopt; - disable_blink_features_ = absl::nullopt; + enable_blink_features_ = std::nullopt; + disable_blink_features_ = std::nullopt; disable_popups_ = false; disable_dialogs_ = false; safe_dialogs_ = false; - safe_dialogs_message_ = absl::nullopt; + safe_dialogs_message_ = std::nullopt; ignore_menu_shortcuts_ = false; - background_color_ = absl::nullopt; + background_color_ = std::nullopt; image_animation_policy_ = blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAllowed; - preload_path_ = absl::nullopt; + preload_path_ = std::nullopt; v8_cache_options_ = blink::mojom::V8CacheOptions::kDefault; #if BUILDFLAG(IS_MAC) diff --git a/shell/browser/web_contents_preferences.h b/shell/browser/web_contents_preferences.h index e46ee17bbbda..05e6665a0082 100644 --- a/shell/browser/web_contents_preferences.h +++ b/shell/browser/web_contents_preferences.h @@ -55,10 +55,10 @@ class WebContentsPreferences base::Value* last_preference() { return &last_web_preferences_; } bool IsOffscreen() const { return offscreen_; } - absl::optional GetBackgroundColor() const { + std::optional GetBackgroundColor() const { return background_color_; } - void SetBackgroundColor(absl::optional color) { + void SetBackgroundColor(std::optional color) { background_color_ = color; } bool ShouldUsePreferredSizeMode() const { @@ -104,7 +104,7 @@ class WebContentsPreferences bool node_integration_in_worker_; bool disable_html_fullscreen_window_resize_; bool webview_tag_; - absl::optional sandbox_; + std::optional sandbox_; bool context_isolation_; bool javascript_; bool images_; @@ -118,23 +118,23 @@ class WebContentsPreferences bool navigate_on_drag_drop_; blink::mojom::AutoplayPolicy autoplay_policy_; std::map default_font_family_; - absl::optional default_font_size_; - absl::optional default_monospace_font_size_; - absl::optional minimum_font_size_; - absl::optional default_encoding_; + std::optional default_font_size_; + std::optional default_monospace_font_size_; + std::optional minimum_font_size_; + std::optional default_encoding_; bool is_webview_; std::vector custom_args_; std::vector custom_switches_; - absl::optional enable_blink_features_; - absl::optional disable_blink_features_; + std::optional enable_blink_features_; + std::optional disable_blink_features_; bool disable_popups_; bool disable_dialogs_; bool safe_dialogs_; - absl::optional safe_dialogs_message_; + std::optional safe_dialogs_message_; bool ignore_menu_shortcuts_; - absl::optional background_color_; + std::optional background_color_; blink::mojom::ImageAnimationPolicy image_animation_policy_; - absl::optional preload_path_; + std::optional preload_path_; blink::mojom::V8CacheOptions v8_cache_options_; #if BUILDFLAG(IS_MAC) diff --git a/shell/browser/zoom_level_delegate.cc b/shell/browser/zoom_level_delegate.cc index 6e85a5cad44c..c91afb6a819f 100644 --- a/shell/browser/zoom_level_delegate.cc +++ b/shell/browser/zoom_level_delegate.cc @@ -100,7 +100,7 @@ void ZoomLevelDelegate::ExtractPerHostZoomLevels( std::vector keys_to_remove; base::Value::Dict host_zoom_dictionary_copy = host_zoom_dictionary.Clone(); for (auto [host, value] : host_zoom_dictionary_copy) { - const absl::optional zoom_level = value.GetIfDouble(); + const std::optional zoom_level = value.GetIfDouble(); // Filter out A) the empty host, B) zoom levels equal to the default; and // remember them, so that we can later erase them from Prefs. diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc index ea1c8d5f912f..c29dc3ed3af5 100644 --- a/shell/common/api/electron_api_clipboard.cc +++ b/shell/common/api/electron_api_clipboard.cc @@ -229,7 +229,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) { } ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); - absl::optional image; + std::optional image; base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); base::RepeatingClosure callback = run_loop.QuitClosure(); @@ -237,7 +237,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) { GetClipboardBuffer(args), /* data_dst = */ nullptr, base::BindOnce( - [](absl::optional* image, base::RepeatingClosure cb, + [](std::optional* image, base::RepeatingClosure cb, const std::vector& result) { SkBitmap bitmap; gfx::PNGCodec::Decode(result.data(), result.size(), &bitmap); diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index a2994e1e33a0..ef772bf72f20 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -324,7 +324,7 @@ bool NativeImage::IsEmpty() { return image_.IsEmpty(); } -gfx::Size NativeImage::GetSize(const absl::optional scale_factor) { +gfx::Size NativeImage::GetSize(const std::optional scale_factor) { float sf = scale_factor.value_or(1.0f); gfx::ImageSkiaRep image_rep = image_.AsImageSkia().GetRepresentation(sf); @@ -340,7 +340,7 @@ std::vector NativeImage::GetScaleFactors() { return scale_factors; } -float NativeImage::GetAspectRatio(const absl::optional scale_factor) { +float NativeImage::GetAspectRatio(const std::optional scale_factor) { float sf = scale_factor.value_or(1.0f); gfx::Size size = GetSize(sf); if (size.IsEmpty()) @@ -354,8 +354,8 @@ gin::Handle NativeImage::Resize(gin::Arguments* args, float scale_factor = GetScaleFactorFromOptions(args); gfx::Size size = GetSize(scale_factor); - absl::optional new_width = options.FindInt("width"); - absl::optional new_height = options.FindInt("height"); + std::optional new_width = options.FindInt("width"); + std::optional new_height = options.FindInt("height"); int width = new_width.value_or(size.width()); int height = new_height.value_or(size.height()); size.SetSize(width, height); diff --git a/shell/common/api/electron_api_native_image.h b/shell/common/api/electron_api_native_image.h index 1a346444d144..6087eb203374 100644 --- a/shell/common/api/electron_api_native_image.h +++ b/shell/common/api/electron_api_native_image.h @@ -117,8 +117,8 @@ class NativeImage : public gin::Wrappable { gin::Handle Crop(v8::Isolate* isolate, const gfx::Rect& rect); std::string ToDataURL(gin::Arguments* args); bool IsEmpty(); - gfx::Size GetSize(const absl::optional scale_factor); - float GetAspectRatio(const absl::optional scale_factor); + gfx::Size GetSize(const std::optional scale_factor); + float GetAspectRatio(const std::optional scale_factor); void AddRepresentation(const gin_helper::Dictionary& options); void UpdateExternalAllocatedMemoryUsage(); diff --git a/shell/common/api/electron_api_net.cc b/shell/common/api/electron_api_net.cc index 8339dc68db72..78a3b0a26ca7 100644 --- a/shell/common/api/electron_api_net.cc +++ b/shell/common/api/electron_api_net.cc @@ -46,7 +46,7 @@ base::FilePath FileURLToFilePath(v8::Isolate* isolate, const GURL& url) { v8::Local ResolveHost( v8::Isolate* isolate, std::string host, - absl::optional params) { + std::optional params) { gin_helper::Promise promise(isolate); v8::Local handle = promise.GetHandle(); @@ -54,7 +54,7 @@ v8::Local ResolveHost( nullptr, std::move(host), params ? std::move(params.value()) : nullptr, base::BindOnce( [](gin_helper::Promise promise, - int64_t net_error, const absl::optional& addrs) { + int64_t net_error, const std::optional& addrs) { if (net_error < 0) { promise.RejectWithErrorMessage(net::ErrorToString(net_error)); } else { diff --git a/shell/common/api/electron_api_url_loader.cc b/shell/common/api/electron_api_url_loader.cc index 9cb27af9b741..975c571cd30c 100644 --- a/shell/common/api/electron_api_url_loader.cc +++ b/shell/common/api/electron_api_url_loader.cc @@ -392,7 +392,7 @@ void SimpleURLLoaderWrapper::PinBodyGetter(v8::Local body_getter) { SimpleURLLoaderWrapper::~SimpleURLLoaderWrapper() = default; void SimpleURLLoaderWrapper::OnAuthRequired( - const absl::optional& window_id, + const std::optional& window_id, uint32_t request_id, const GURL& url, bool first_auth_attempt, @@ -413,7 +413,7 @@ void SimpleURLLoaderWrapper::OnAuthRequired( gin::Arguments* args) { std::u16string username_str, password_str; if (!args->GetNext(&username_str) || !args->GetNext(&password_str)) { - auth_responder->OnAuthCredentials(absl::nullopt); + auth_responder->OnAuthCredentials(std::nullopt); return; } auth_responder->OnAuthCredentials( @@ -436,7 +436,7 @@ void SimpleURLLoaderWrapper::OnClearSiteData( const GURL& url, const std::string& header_value, int32_t load_flags, - const absl::optional& cookie_partition_key, + const std::optional& cookie_partition_key, bool partitioned_state_allowed_only, OnClearSiteDataCallback callback) { std::move(callback).Run(); @@ -758,7 +758,7 @@ void SimpleURLLoaderWrapper::OnRedirect( bool should_clear_upload = false; net::RedirectUtil::UpdateHttpRequest( request_->url, request_->method, redirect_info, *removed_headers, - /* modified_headers = */ absl::nullopt, &request_->headers, + /* modified_headers = */ std::nullopt, &request_->headers, &should_clear_upload); if (should_clear_upload) { // The request body is no longer applicable. diff --git a/shell/common/api/electron_api_url_loader.h b/shell/common/api/electron_api_url_loader.h index ccabfb83bde0..5729b1d8c9c7 100644 --- a/shell/common/api/electron_api_url_loader.h +++ b/shell/common/api/electron_api_url_loader.h @@ -73,7 +73,7 @@ class SimpleURLLoaderWrapper // network::mojom::URLLoaderNetworkServiceObserver: void OnAuthRequired( - const absl::optional& window_id, + const std::optional& window_id, uint32_t request_id, const GURL& url, bool first_auth_attempt, @@ -87,21 +87,21 @@ class SimpleURLLoaderWrapper bool fatal, OnSSLCertificateErrorCallback response) override; void OnCertificateRequested( - const absl::optional& window_id, + const std::optional& window_id, const scoped_refptr& cert_info, mojo::PendingRemote client_cert_responder) override {} void OnPrivateNetworkAccessPermissionRequired( const GURL& url, const net::IPAddress& ip_address, - const absl::optional& private_network_device_id, - const absl::optional& private_network_device_name, + const std::optional& private_network_device_id, + const std::optional& private_network_device_name, OnPrivateNetworkAccessPermissionRequiredCallback callback) override {} void OnClearSiteData( const GURL& url, const std::string& header_value, int32_t load_flags, - const absl::optional& cookie_partition_key, + const std::optional& cookie_partition_key, bool partitioned_state_allowed_only, OnClearSiteDataCallback callback) override; void OnLoadingStateUpdate(network::mojom::LoadInfoPtr info, diff --git a/shell/common/asar/archive.cc b/shell/common/asar/archive.cc index 905fafe74ec3..578dd3b6a12b 100644 --- a/shell/common/asar/archive.cc +++ b/shell/common/asar/archive.cc @@ -90,13 +90,13 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, uint32_t header_size, bool load_integrity, const base::Value::Dict* node) { - if (absl::optional size = node->FindInt("size")) { + if (std::optional size = node->FindInt("size")) { info->size = static_cast(*size); } else { return false; } - if (absl::optional unpacked = node->FindBool("unpacked")) { + if (std::optional unpacked = node->FindBool("unpacked")) { info->unpacked = *unpacked; if (info->unpacked) { return true; @@ -111,7 +111,7 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, return false; } - if (absl::optional executable = node->FindBool("executable")) { + if (std::optional executable = node->FindBool("executable")) { info->executable = *executable; } @@ -121,7 +121,7 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, if (const base::Value::Dict* integrity = node->FindDict("integrity")) { const std::string* algorithm = integrity->FindString("algorithm"); const std::string* hash = integrity->FindString("hash"); - absl::optional block_size = integrity->FindInt("blockSize"); + std::optional block_size = integrity->FindInt("blockSize"); const base::Value::List* blocks = integrity->FindList("blocks"); if (algorithm && hash && block_size && block_size > 0 && blocks) { @@ -242,7 +242,7 @@ bool Archive::Init() { // Validate header signature if required and possible if (electron::fuses::IsEmbeddedAsarIntegrityValidationEnabled() && RelativePath().has_value()) { - absl::optional integrity = HeaderIntegrity(); + std::optional integrity = HeaderIntegrity(); if (!integrity.has_value()) { LOG(FATAL) << "Failed to get integrity for validatable asar archive: " << RelativePath().value(); @@ -264,7 +264,7 @@ bool Archive::Init() { } #endif - absl::optional value = base::JSONReader::Read(header); + std::optional value = base::JSONReader::Read(header); if (!value || !value->is_dict()) { LOG(ERROR) << "Failed to parse header"; return false; @@ -276,12 +276,12 @@ bool Archive::Init() { } #if !BUILDFLAG(IS_MAC) -absl::optional Archive::HeaderIntegrity() const { - return absl::nullopt; +std::optional Archive::HeaderIntegrity() const { + return std::nullopt; } -absl::optional Archive::RelativePath() const { - return absl::nullopt; +std::optional Archive::RelativePath() const { + return std::nullopt; } #endif diff --git a/shell/common/asar/archive.h b/shell/common/asar/archive.h index b11f2ac212f7..ed9b18d74c4e 100644 --- a/shell/common/asar/archive.h +++ b/shell/common/asar/archive.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_COMMON_ASAR_ARCHIVE_H_ #include +#include #include #include #include @@ -16,7 +17,6 @@ #include "base/files/file_path.h" #include "base/synchronization/lock.h" #include "base/values.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace asar { @@ -48,7 +48,7 @@ class Archive { bool executable; uint32_t size; uint64_t offset; - absl::optional integrity; + std::optional integrity; }; enum class FileType { @@ -71,8 +71,8 @@ class Archive { // Read and parse the header. bool Init(); - absl::optional HeaderIntegrity() const; - absl::optional RelativePath() const; + std::optional HeaderIntegrity() const; + std::optional RelativePath() const; // Get the info of a file. bool GetFileInfo(const base::FilePath& path, FileInfo* info) const; @@ -106,7 +106,7 @@ class Archive { base::File file_; int fd_ = -1; uint32_t header_size_ = 0; - absl::optional header_; + std::optional header_; // Cached external temporary files. base::Lock external_files_lock_; diff --git a/shell/common/asar/archive_mac.mm b/shell/common/asar/archive_mac.mm index 4501bab716c8..ac4b485991e2 100644 --- a/shell/common/asar/archive_mac.mm +++ b/shell/common/asar/archive_mac.mm @@ -21,19 +21,19 @@ namespace asar { -absl::optional Archive::RelativePath() const { +std::optional Archive::RelativePath() const { base::FilePath bundle_path = base::MakeAbsoluteFilePath( base::apple::MainBundlePath().Append("Contents")); base::FilePath relative_path; if (!bundle_path.AppendRelativePath(path_, &relative_path)) - return absl::nullopt; + return std::nullopt; return relative_path; } -absl::optional Archive::HeaderIntegrity() const { - absl::optional relative_path = RelativePath(); +std::optional Archive::HeaderIntegrity() const { + std::optional relative_path = RelativePath(); // Callers should have already asserted this CHECK(relative_path.has_value()); @@ -42,7 +42,7 @@ absl::optional Archive::HeaderIntegrity() const { // Integrity not provided if (!integrity) - return absl::nullopt; + return std::nullopt; NSString* ns_relative_path = base::apple::FilePathToNSString(relative_path.value()); @@ -50,7 +50,7 @@ absl::optional Archive::HeaderIntegrity() const { NSDictionary* integrity_payload = [integrity objectForKey:ns_relative_path]; if (!integrity_payload) - return absl::nullopt; + return std::nullopt; NSString* algorithm = [integrity_payload objectForKey:@"algorithm"]; NSString* hash = [integrity_payload objectForKey:@"hash"]; @@ -61,7 +61,7 @@ absl::optional Archive::HeaderIntegrity() const { return header_integrity; } - return absl::nullopt; + return std::nullopt; } } // namespace asar diff --git a/shell/common/asar/scoped_temporary_file.cc b/shell/common/asar/scoped_temporary_file.cc index f2982c9d37cc..d0f00034dba2 100644 --- a/shell/common/asar/scoped_temporary_file.cc +++ b/shell/common/asar/scoped_temporary_file.cc @@ -55,7 +55,7 @@ bool ScopedTemporaryFile::InitFromFile( const base::FilePath::StringType& ext, uint64_t offset, uint64_t size, - const absl::optional& integrity) { + const std::optional& integrity) { if (!src->IsValid()) return false; diff --git a/shell/common/asar/scoped_temporary_file.h b/shell/common/asar/scoped_temporary_file.h index 5fd31a848b2f..0cf4f0095551 100644 --- a/shell/common/asar/scoped_temporary_file.h +++ b/shell/common/asar/scoped_temporary_file.h @@ -5,9 +5,10 @@ #ifndef ELECTRON_SHELL_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ #define ELECTRON_SHELL_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ +#include + #include "base/files/file_path.h" #include "shell/common/asar/archive.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class File; @@ -34,7 +35,7 @@ class ScopedTemporaryFile { const base::FilePath::StringType& ext, uint64_t offset, uint64_t size, - const absl::optional& integrity); + const std::optional& integrity); base::FilePath path() const { return path_; } diff --git a/shell/common/gin_converters/blink_converter.cc b/shell/common/gin_converters/blink_converter.cc index 8a85c34a6e95..ae886e7d0aea 100644 --- a/shell/common/gin_converters/blink_converter.cc +++ b/shell/common/gin_converters/blink_converter.cc @@ -258,7 +258,7 @@ bool Converter::FromV8(v8::Isolate* isolate, if (!dict.Get("keyCode", &str)) return false; - absl::optional shifted_char; + std::optional shifted_char; ui::KeyboardCode keyCode = electron::KeyboardCodeFromStr(str, &shifted_char); out->windows_key_code = keyCode; if (shifted_char) @@ -460,9 +460,9 @@ v8::Local Converter::ToV8( // static v8::Local -Converter>::ToV8( +Converter>::ToV8( v8::Isolate* isolate, - const absl::optional& in) { + const std::optional& in) { base::StringPiece str{"none"}; if (in.has_value()) { switch (*in) { diff --git a/shell/common/gin_converters/blink_converter.h b/shell/common/gin_converters/blink_converter.h index 506758ce892f..1dd38e9de4af 100644 --- a/shell/common/gin_converters/blink_converter.h +++ b/shell/common/gin_converters/blink_converter.h @@ -80,10 +80,10 @@ struct Converter { }; template <> -struct Converter> { +struct Converter> { static v8::Local ToV8( v8::Isolate* isolate, - const absl::optional& in); + const std::optional& in); }; template <> diff --git a/shell/common/gin_converters/content_converter.cc b/shell/common/gin_converters/content_converter.cc index 4f1bb7c77d2b..8b016584e54d 100644 --- a/shell/common/gin_converters/content_converter.cc +++ b/shell/common/gin_converters/content_converter.cc @@ -25,7 +25,7 @@ namespace { [[nodiscard]] constexpr base::StringPiece FormControlToInputFieldTypeString( - const absl::optional form_control_type) { + const std::optional form_control_type) { if (!form_control_type) return "none"; diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index d23c4a21af85..888bc8ba0a07 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -482,7 +482,7 @@ class ChunkedDataPipeReadableStream mojo::Remote chunked_data_pipe_getter_; mojo::ScopedDataPipeConsumerHandle data_pipe_; mojo::SimpleWatcher handle_watcher_; - absl::optional size_; + std::optional size_; uint64_t bytes_read_ = 0; bool is_eof_ = false; v8::Global buf_; diff --git a/shell/common/gin_converters/optional_converter.h b/shell/common/gin_converters/optional_converter.h index e40a463c760d..16feb18dfd2e 100644 --- a/shell/common/gin_converters/optional_converter.h +++ b/shell/common/gin_converters/optional_converter.h @@ -5,17 +5,17 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_OPTIONAL_CONVERTER_H_ #define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_OPTIONAL_CONVERTER_H_ +#include #include #include "gin/converter.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace gin { template -struct Converter> { +struct Converter> { static v8::Local ToV8(v8::Isolate* isolate, - const absl::optional& val) { + const std::optional& val) { if (val) return Converter::ToV8(isolate, val.value()); else @@ -23,7 +23,7 @@ struct Converter> { } static bool FromV8(v8::Isolate* isolate, v8::Local val, - absl::optional* out) { + std::optional* out) { T converted; if (Converter::FromV8(isolate, val, &converted)) out->emplace(std::move(converted)); diff --git a/shell/common/gin_helper/dictionary.h b/shell/common/gin_helper/dictionary.h index dbf7a9c33e63..b490e5d6d0b8 100644 --- a/shell/common/gin_helper/dictionary.h +++ b/shell/common/gin_helper/dictionary.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_DICTIONARY_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_DICTIONARY_H_ +#include #include #include @@ -12,7 +13,6 @@ #include "shell/common/gin_converters/std_converter.h" #include "shell/common/gin_helper/accessor.h" #include "shell/common/gin_helper/function_template.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace gin_helper { @@ -66,9 +66,9 @@ class Dictionary : public gin::Dictionary { return !result.IsNothing() && result.FromJust(); } - // Like normal Get but put result in an absl::optional. + // Like normal Get but put result in an std::optional. template - bool GetOptional(base::StringPiece key, absl::optional* out) const { + bool GetOptional(base::StringPiece key, std::optional* out) const { T ret; if (Get(key, &ret)) { out->emplace(std::move(ret)); diff --git a/shell/common/gin_helper/function_template.h b/shell/common/gin_helper/function_template.h index 11b38f8fac43..0a0922b3be34 100644 --- a/shell/common/gin_helper/function_template.h +++ b/shell/common/gin_helper/function_template.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_H_ +#include #include #include "base/functional/bind.h" @@ -15,7 +16,6 @@ #include "shell/common/gin_helper/destroyable.h" #include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/microtasks_scope.h" -#include "third_party/abseil-cpp/absl/types/optional.h" // This file is forked from gin/function_template.h with 2 differences: // 1. Support for additional types of arguments. @@ -96,13 +96,13 @@ bool GetNextArgument(gin::Arguments* args, } } -// Support absl::optional as output, which would be empty and do not throw error +// Support std::optional as output, which would be empty and do not throw error // when conversion to T fails. template bool GetNextArgument(gin::Arguments* args, int create_flags, bool is_first, - absl::optional* result) { + std::optional* result) { T converted; // Use gin::Arguments::GetNext which always advances |next| counter. if (args->GetNext(&converted)) diff --git a/shell/common/gin_helper/function_template_extensions.h b/shell/common/gin_helper/function_template_extensions.h index 7420ffde724c..ace47fdb7537 100644 --- a/shell/common/gin_helper/function_template_extensions.h +++ b/shell/common/gin_helper/function_template_extensions.h @@ -16,12 +16,12 @@ // in the gin_helper namespace. namespace gin { -// Support absl::optional as an argument. +// Support std::optional as an argument. template bool GetNextArgument(Arguments* args, const InvokerOptions& invoker_options, bool is_first, - absl::optional* result) { + std::optional* result) { T converted; // Use gin::Arguments::GetNext which always advances |next| counter. if (args->GetNext(&converted)) diff --git a/shell/common/keyboard_util.cc b/shell/common/keyboard_util.cc index 84e4ea7a283c..d8d8d553d84f 100644 --- a/shell/common/keyboard_util.cc +++ b/shell/common/keyboard_util.cc @@ -15,8 +15,7 @@ namespace electron { namespace { -using CodeAndShiftedChar = - std::pair>; +using CodeAndShiftedChar = std::pair>; constexpr CodeAndShiftedChar KeyboardCodeFromKeyIdentifier( base::StringPiece str) { @@ -274,7 +273,7 @@ constexpr CodeAndShiftedChar KeyboardCodeFromCharCode(char16_t c) { } // namespace ui::KeyboardCode KeyboardCodeFromStr(base::StringPiece str, - absl::optional* shifted_char) { + std::optional* shifted_char) { auto const [code, shifted] = str.size() == 1 ? KeyboardCodeFromCharCode(base::ToLowerASCII(str[0])) : KeyboardCodeFromKeyIdentifier(base::ToLowerASCII(str)); diff --git a/shell/common/keyboard_util.h b/shell/common/keyboard_util.h index 95ebda6c44f5..45cc80f264a3 100644 --- a/shell/common/keyboard_util.h +++ b/shell/common/keyboard_util.h @@ -5,8 +5,9 @@ #ifndef ELECTRON_SHELL_COMMON_KEYBOARD_UTIL_H_ #define ELECTRON_SHELL_COMMON_KEYBOARD_UTIL_H_ +#include + #include "base/strings/string_piece.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/events/keycodes/keyboard_codes.h" namespace electron { @@ -15,7 +16,7 @@ namespace electron { // for example + and /, set it in |shifted_char|. // pressed. ui::KeyboardCode KeyboardCodeFromStr(base::StringPiece str, - absl::optional* shifted_char); + std::optional* shifted_char); } // namespace electron diff --git a/shell/common/mac/codesign_util.cc b/shell/common/mac/codesign_util.cc index 2abfb2eb32d2..455bfa5d02e5 100644 --- a/shell/common/mac/codesign_util.cc +++ b/shell/common/mac/codesign_util.cc @@ -5,17 +5,18 @@ #include "shell/common/mac/codesign_util.h" +#include + #include "base/apple/foundation_util.h" #include "base/apple/osstatus_logging.h" #include "base/apple/scoped_cftyperef.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include #include namespace electron { -absl::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { +std::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { base::apple::ScopedCFTypeRef static_code; OSStatus status = SecCodeCopyStaticCode(code, kSecCSDefaultFlags, static_code.InitializeInto()); @@ -24,7 +25,7 @@ absl::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { } if (status != errSecSuccess) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopyStaticCode"; - return absl::optional(); + return std::optional(); } // Copy the signing info from the SecStaticCodeRef. base::apple::ScopedCFTypeRef signing_info; @@ -33,7 +34,7 @@ absl::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { signing_info.InitializeInto()); if (status != errSecSuccess) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopySigningInformation"; - return absl::optional(); + return std::optional(); } // Look up the code signing flags. If the flags are absent treat this as // unsigned. This decision is consistent with the StaticCode source: @@ -50,7 +51,7 @@ absl::optional IsUnsignedOrAdHocSigned(SecCodeRef code) { long long flags; if (!CFNumberGetValue(signing_info_flags, kCFNumberLongLongType, &flags)) { LOG(ERROR) << "CFNumberGetValue"; - return absl::optional(); + return std::optional(); } if (static_cast(flags) & kSecCodeSignatureAdhoc) { return true; @@ -67,7 +68,7 @@ bool ProcessSignatureIsSameWithCurrentApp(pid_t pid) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopyGuestWithAttributes"; return false; } - absl::optional not_signed = IsUnsignedOrAdHocSigned(self_code.get()); + std::optional not_signed = IsUnsignedOrAdHocSigned(self_code.get()); if (!not_signed.has_value()) { // Error happened. return false; diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 704f71e8b916..676c71237176 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -556,7 +556,7 @@ std::shared_ptr NodeBindings::CreateEnvironment( node::MultiIsolatePlatform* platform, std::vector args, std::vector exec_args, - absl::optional> on_app_code_ready) { + std::optional> on_app_code_ready) { // Feed node the path to initialization script. std::string process_type; switch (browser_env_) { @@ -762,7 +762,7 @@ std::shared_ptr NodeBindings::CreateEnvironment( std::shared_ptr NodeBindings::CreateEnvironment( v8::Handle context, node::MultiIsolatePlatform* platform, - absl::optional> on_app_code_ready) { + std::optional> on_app_code_ready) { #if BUILDFLAG(IS_WIN) auto& electron_args = ElectronCommandLine::argv(); std::vector args(electron_args.size()); diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index cd476c4dbbd0..596eee17d3be 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_COMMON_NODE_BINDINGS_H_ #include +#include #include #include #include @@ -18,7 +19,6 @@ #include "gin/public/context_holder.h" #include "gin/public/gin_embedders.h" #include "shell/common/node_includes.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "uv.h" // NOLINT(build/include_directory) #include "v8/include/v8.h" @@ -97,14 +97,14 @@ class NodeBindings { node::MultiIsolatePlatform* platform, std::vector args, std::vector exec_args, - absl::optional> on_app_code_ready = - absl::nullopt); + std::optional> on_app_code_ready = + std::nullopt); std::shared_ptr CreateEnvironment( v8::Handle context, node::MultiIsolatePlatform* platform, - absl::optional> on_app_code_ready = - absl::nullopt); + std::optional> on_app_code_ready = + std::nullopt); // Load node.js in the environment. void LoadEnvironment(node::Environment* env); diff --git a/shell/common/platform_util_linux.cc b/shell/common/platform_util_linux.cc index e29ace1c64c7..27245423dbcf 100644 --- a/shell/common/platform_util_linux.cc +++ b/shell/common/platform_util_linux.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -30,7 +31,6 @@ #include "dbus/message.h" #include "dbus/object_proxy.h" #include "shell/common/platform_util_internal.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gtk/gtk_util.h" // nogncheck #include "url/gurl.h" @@ -247,7 +247,7 @@ class ShowItemHelper { raw_ptr dbus_proxy_ = nullptr; raw_ptr object_proxy_ = nullptr; - absl::optional prefer_filemanager_interface_; + std::optional prefer_filemanager_interface_; }; // Descriptions pulled from https://linux.die.net/man/1/xdg-open diff --git a/shell/renderer/api/electron_api_ipc_renderer.cc b/shell/renderer/api/electron_api_ipc_renderer.cc index 58feca6ad41b..317b93368749 100644 --- a/shell/renderer/api/electron_api_ipc_renderer.cc +++ b/shell/renderer/api/electron_api_ipc_renderer.cc @@ -131,7 +131,7 @@ class IPCRenderer : public gin::Wrappable, gin_helper::ErrorThrower thrower, const std::string& channel, v8::Local message_value, - absl::optional> transfer) { + std::optional> transfer) { if (!electron_ipc_remote_) { thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError); return; @@ -153,7 +153,7 @@ class IPCRenderer : public gin::Wrappable, std::vector ports; for (auto& transferable : transferables) { - absl::optional port = + std::optional port = blink::WebMessagePortConverter:: DisentangleAndExtractMessagePortChannel(isolate, transferable); if (!port.has_value()) {