From d8949a4d04c40cbf316b7dab8194e2db888ecc2d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:45:27 +0200 Subject: [PATCH] refactor: remove unused web contents preferences methods (#42970) * chore: remove unused WebContentsPreferences::ShouldDisableDialogs() Co-authored-by: Charles Kerr * chore: remove unused WebContentsPreferences::ShouldUseSafeDialogs() caller removed in 85bc005c Co-authored-by: Charles Kerr * chore: remove unused WebContentsPreferences::GetSafeDialogsMessage() caller removed in 85bc005c Co-authored-by: Charles Kerr * refactor: WebContentsPreferences::GetPreloadPath() now returns a std::optional Co-authored-by: Charles Kerr * refactor: make WebContentsPreferences::last_preference() const Co-authored-by: Charles Kerr --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/api/electron_api_web_contents.cc | 5 ++--- shell/browser/web_contents_preferences.cc | 17 ----------------- shell/browser/web_contents_preferences.h | 7 ++----- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 2ecb429f903c..7e2c4c0ef56d 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -3619,9 +3619,8 @@ std::vector WebContents::GetPreloadPaths() const { auto result = SessionPreferences::GetValidPreloads(GetBrowserContext()); if (auto* web_preferences = WebContentsPreferences::From(web_contents())) { - base::FilePath preload; - if (web_preferences->GetPreloadPath(&preload)) { - result.emplace_back(preload); + if (auto preload = web_preferences->GetPreloadPath()) { + result.emplace_back(*preload); } } diff --git a/shell/browser/web_contents_preferences.cc b/shell/browser/web_contents_preferences.cc index ee7acea23cbe..e9aa635c8a81 100644 --- a/shell/browser/web_contents_preferences.cc +++ b/shell/browser/web_contents_preferences.cc @@ -258,14 +258,6 @@ void WebContentsPreferences::SetFromDictionary( SaveLastPreferences(); } -bool WebContentsPreferences::GetSafeDialogsMessage(std::string* message) const { - if (safe_dialogs_message_) { - *message = *safe_dialogs_message_; - return true; - } - return false; -} - bool WebContentsPreferences::SetImageAnimationPolicy(std::string policy) { if (policy == "animate") { image_animation_policy_ = @@ -283,15 +275,6 @@ bool WebContentsPreferences::SetImageAnimationPolicy(std::string policy) { return false; } -bool WebContentsPreferences::GetPreloadPath(base::FilePath* path) const { - DCHECK(path); - if (preload_path_) { - *path = *preload_path_; - return true; - } - return false; -} - bool WebContentsPreferences::IsSandboxed() const { if (sandbox_) return *sandbox_; diff --git a/shell/browser/web_contents_preferences.h b/shell/browser/web_contents_preferences.h index dd89bfe39070..b134f1aa76b5 100644 --- a/shell/browser/web_contents_preferences.h +++ b/shell/browser/web_contents_preferences.h @@ -52,7 +52,7 @@ class WebContentsPreferences void OverrideWebkitPrefs(blink::web_pref::WebPreferences* prefs, blink::RendererPreferences* renderer_prefs); - base::Value* last_preference() { return &last_web_preferences_; } + const base::Value* last_preference() const { return &last_web_preferences_; } bool IsOffscreen() const { return offscreen_; } std::optional GetBackgroundColor() const { @@ -75,12 +75,9 @@ class WebContentsPreferences bool AllowsNodeIntegrationInSubFrames() const { return node_integration_in_sub_frames_; } - bool ShouldDisableDialogs() const { return disable_dialogs_; } - bool ShouldUseSafeDialogs() const { return safe_dialogs_; } - bool GetSafeDialogsMessage(std::string* message) const; bool ShouldDisablePopups() const { return disable_popups_; } bool IsWebSecurityEnabled() const { return web_security_; } - bool GetPreloadPath(base::FilePath* path) const; + std::optional GetPreloadPath() const { return preload_path_; } bool IsSandboxed() const; private: