Truly independent web browser
LibWebView+Hub: Stop including the history store in the Hub
Andreas Kling5070ef356d93
diff --git a/Libraries/LibWebView/HistoryStore.cpp b/Libraries/LibWebView/HistoryStore.cppindex a96b7620d45..1e46f928652 100644--- a/Libraries/LibWebView/HistoryStore.cpp+++ b/Libraries/LibWebView/HistoryStore.cpp@@ -15,6 +15,7 @@#include <LibURL/URL.h>#include <LibWebView/HistoryDebug.h>#include <LibWebView/HistoryStore.h>+#include <LibWebView/URL.h>namespace WebView {@@ -499,35 +500,6 @@ HistoryStore::HistoryStore(NonnullOwnPtr<StorageImpl>&& storage, bool is_disableHistoryStore::~HistoryStore() = default;-// History records web pages and local files only. The browser opens what its history lists, and a javascript: URL would-// run in whatever document opened it, such as about:history. A store holds other URLs only if something other than the-// browser wrote to it, so the queries listing and suggesting entries skip them too.-static bool is_browsable_url(URL::URL const& url)-{- return url.scheme().is_one_of("http"sv, "https"sv, "file"sv);-}--Optional<String> HistoryStore::normalize_url(URL::URL const& url)-{- if (url.scheme().is_empty()) {- dbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Skipping history entry without a scheme: {}", url);- return {};- }-- if (!is_browsable_url(url)) {- dbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Skipping non-browsable history URL: {}", url);- return {};- }-- auto normalized_url = url.serialize(URL::ExcludeFragment::Yes);- if (normalized_url.is_empty()) {- dbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Skipping history entry with an empty normalized URL: {}", url);- return {};- }-- return normalized_url;-}-static bool transition_updates_general_score(HistoryVisitTransition transition){return transition == HistoryVisitTransition::Omnibox@@ -587,7 +559,7 @@ void HistoryStore::record_visit(URL::URL const& url, Optional<String> title, Uniif (m_is_disabled)return;- auto normalized_url = normalize_url(url);+ auto normalized_url = normalize_url_for_history(url);if (!normalized_url.has_value())return;@@ -610,7 +582,7 @@ void HistoryStore::update_title(URL::URL const& url, String const& title)return;}- auto normalized_url = normalize_url(url);+ auto normalized_url = normalize_url_for_history(url);if (!normalized_url.has_value())return;@@ -629,7 +601,7 @@ void HistoryStore::update_favicon(URL::URL const& url, String const& favicon_hasreturn;}- auto normalized_url = normalize_url(url);+ auto normalized_url = normalize_url_for_history(url);if (!normalized_url.has_value())return;@@ -646,7 +618,7 @@ Optional<HistoryEntry> HistoryStore::entry_for_url(URL::URL const& url)if (m_is_disabled)return {};- auto normalized_url = normalize_url(url);+ auto normalized_url = normalize_url_for_history(url);if (!normalized_url.has_value())return {};@@ -742,7 +714,7 @@ void HistoryStore::remove_entry_for_url(URL::URL const& url, RemoveHistoryEntryEif (m_is_disabled)return;- auto normalized_url = normalize_url(url);+ auto normalized_url = normalize_url_for_history(url);if (!normalized_url.has_value())return;diff --git a/Libraries/LibWebView/HistoryStore.h b/Libraries/LibWebView/HistoryStore.hindex 4556cbfe806..a29fce5d3da 100644--- a/Libraries/LibWebView/HistoryStore.h+++ b/Libraries/LibWebView/HistoryStore.h@@ -53,7 +53,6 @@ public:static ErrorOr<NonnullOwnPtr<HistoryStore>> create(Database::Database&);static NonnullOwnPtr<HistoryStore> create(Optional<FaviconStore&> favicon_store = {});static NonnullOwnPtr<HistoryStore> create_disabled();- static Optional<String> normalize_url(URL::URL const&);~HistoryStore();diff --git a/Libraries/LibWebView/ProcessSnapshot.cpp b/Libraries/LibWebView/ProcessSnapshot.cppindex c979aafdd86..18a96e5715b 100644--- a/Libraries/LibWebView/ProcessSnapshot.cpp+++ b/Libraries/LibWebView/ProcessSnapshot.cpp@@ -9,7 +9,6 @@#include <LibWebView/Application.h>#include <LibWebView/CanonicalDocument.h>#include <LibWebView/CanonicalTraversable.h>-#include <LibWebView/FaviconStore.h>#include <LibWebView/ProcessManager.h>#include <LibWebView/ProcessSnapshot.h>#include <LibWebView/ViewImplementation.h>diff --git a/Libraries/LibWebView/URL.cpp b/Libraries/LibWebView/URL.cppindex 39d7b9fcbe0..3c3cb34aaf2 100644--- a/Libraries/LibWebView/URL.cpp+++ b/Libraries/LibWebView/URL.cpp@@ -7,6 +7,7 @@*/#include <AK/CharacterTypes.h>+#include <AK/Debug.h>#include <AK/IPv4Address.h>#include <AK/IPv6Address.h>#include <AK/String.h>@@ -471,4 +472,33 @@ ByteString image_filename_with_extension(ByteString filename, StringView image_mreturn ByteString::formatted("{}{}", filename, *extension);}+// History records web pages and local files only. The browser opens what its history lists, and a javascript: URL would+// run in whatever document opened it, such as about:history. A store holds other URLs only if something other than the+// browser wrote to it, so the queries listing and suggesting entries skip them too.+static bool is_browsable_url(URL::URL const& url)+{+ return url.scheme().is_one_of("http"sv, "https"sv, "file"sv);+}++Optional<String> normalize_url_for_history(URL::URL const& url)+{+ if (url.scheme().is_empty()) {+ dbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Skipping history entry without a scheme: {}", url);+ return {};+ }++ if (!is_browsable_url(url)) {+ dbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Skipping non-browsable history URL: {}", url);+ return {};+ }++ auto normalized_url = url.serialize(URL::ExcludeFragment::Yes);+ if (normalized_url.is_empty()) {+ dbgln_if(WEBVIEW_HISTORY_DEBUG, "[History] Skipping history entry with an empty normalized URL: {}", url);+ return {};+ }++ return normalized_url;+}+}diff --git a/Libraries/LibWebView/URL.h b/Libraries/LibWebView/URL.hindex d8f68a95948..c0a0d47ae54 100644--- a/Libraries/LibWebView/URL.h+++ b/Libraries/LibWebView/URL.h@@ -58,4 +58,7 @@ WEBVIEW_API URLType url_type(URL::URL const&);WEBVIEW_API ByteString url_text_to_copy(URL::URL const&);WEBVIEW_API ByteString image_filename_with_extension(ByteString filename, StringView image_mime_type);+// The URL that the browsing history records for a visit to the URL, if history records it at all.+WEBVIEW_API Optional<String> normalize_url_for_history(URL::URL const&);+}diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cppindex 78865c90bd7..ea29fc39c34 100644--- a/Libraries/LibWebView/ViewImplementation.cpp+++ b/Libraries/LibWebView/ViewImplementation.cpp@@ -31,10 +31,8 @@#include <LibWebView/CanonicalSessionHistoryEntry.h>#include <LibWebView/CrashReportOutbox.h>#include <LibWebView/CrashReportReview.h>-#include <LibWebView/FaviconStore.h>#include <LibWebView/HelperProcess.h>#include <LibWebView/HistoryDebug.h>-#include <LibWebView/HistoryStore.h>#include <LibWebView/PageTranslation.h>#include <LibWebView/PermissionManager.h>#include <LibWebView/SessionHistory.h>diff --git a/Libraries/LibWebView/WebContentClient.cpp b/Libraries/LibWebView/WebContentClient.cppindex 8cc634c84f2..dd075585ffd 100644--- a/Libraries/LibWebView/WebContentClient.cpp+++ b/Libraries/LibWebView/WebContentClient.cpp@@ -36,7 +36,6 @@#include <LibWebView/GamepadManager.h>#include <LibWebView/HSTSStore.h>#include <LibWebView/HelperProcess.h>-#include <LibWebView/HistoryStore.h>#include <LibWebView/ImageDecoderManager.h>#include <LibWebView/NavigationLoader.h>#include <LibWebView/NotificationManager.h>diff --git a/Libraries/LibWebView/WebContentPage.cpp b/Libraries/LibWebView/WebContentPage.cppindex 5aecd31d5ec..9625bfc8955 100644--- a/Libraries/LibWebView/WebContentPage.cpp+++ b/Libraries/LibWebView/WebContentPage.cpp@@ -28,7 +28,6 @@#include <LibWebView/CanonicalWindow.h>#include <LibWebView/CookieJar.h>#include <LibWebView/GamepadManager.h>-#include <LibWebView/HistoryStore.h>#include <LibWebView/MicrophoneAuthorizer.h>#include <LibWebView/NavigationLoader.h>#include <LibWebView/NotificationManager.h>@@ -433,7 +432,7 @@ void WebContentPage::did_open_dialog(Web::PendingDialog dialog, Utf16String consvoid WebContentPage::maybe_record_history_visit_for_current_load(URL::URL const& url, Optional<String> title, StringView reason){- auto normalized_url = HistoryStore::normalize_url(url);+ auto normalized_url = normalize_url_for_history(url);if (!normalized_url.has_value())return;diff --git a/Services/Hub/HubClient.ipc b/Services/Hub/HubClient.ipcindex c86bc251ec8..a0f2e3e78a2 100644--- a/Services/Hub/HubClient.ipc+++ b/Services/Hub/HubClient.ipc@@ -25,7 +25,7 @@#include <LibWebView/AccessibilityTreeManager.h>#include <LibWebView/ContextMenuRequest.h>#include <LibWebView/FileDownloader.h>-#include <LibWebView/HistoryStore.h>+#include <LibWebView/HistoryVisitTransition.h>#include <LibWebView/MicrophoneAuthorizer.h>#include <LibWebView/SessionHistory.h>#include <LibWebView/TabPerformanceStats.h>diff --git a/Services/Hub/HubServer.ipc b/Services/Hub/HubServer.ipcindex eb270e45274..f4f608a3c22 100644--- a/Services/Hub/HubServer.ipc+++ b/Services/Hub/HubServer.ipc@@ -22,7 +22,7 @@#include <LibWebCommon/Page/SpellingError.h>#include <LibWebCommon/Page/WritingSuggestion.h>#include <LibWebCommon/Clipboard/SystemClipboard.h>-#include <LibWebView/HistoryStore.h>+#include <LibWebView/HistoryVisitTransition.h>#include <LibWebView/MicrophoneAuthorizer.h>#include <LibWebView/ProcessSnapshot.h>#include <LibWebView/SessionHistory.h>