mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:27:45 +00:00
Ladybird+LibWebView: Move CookieJar, Database, and History to LibWebView
These classes are used as-is in all chromes. Move them to LibWebView so that non-Serenity chromes don't have to awkwardly reach into its headers and sources.
This commit is contained in:
parent
7d313ff83d
commit
5c5a00dd3a
28 changed files with 76 additions and 107 deletions
|
@ -11,7 +11,6 @@
|
|||
#include "BookmarksBarWidget.h"
|
||||
#include "Browser.h"
|
||||
#include "ConsoleWidget.h"
|
||||
#include "CookieJar.h"
|
||||
#include "InspectorWidget.h"
|
||||
#include "Tab.h"
|
||||
#include <Applications/Browser/BrowserWindowGML.h>
|
||||
|
@ -35,6 +34,7 @@
|
|||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/OutOfProcessWebView.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
|
||||
|
@ -56,7 +56,7 @@ static DeprecatedString search_engines_file_path()
|
|||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
|
||||
BrowserWindow::BrowserWindow(WebView::CookieJar& cookie_jar, URL url)
|
||||
: m_cookie_jar(cookie_jar)
|
||||
, m_window_actions(*this)
|
||||
{
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
class CookieJar;
|
||||
class Tab;
|
||||
|
||||
class BrowserWindow final : public GUI::Window
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
void broadcast_window_size(Gfx::IntSize);
|
||||
|
||||
private:
|
||||
BrowserWindow(CookieJar&, URL);
|
||||
BrowserWindow(WebView::CookieJar&, URL);
|
||||
|
||||
void build_menus();
|
||||
ErrorOr<void> load_search_engines(GUI::Menu& settings_menu);
|
||||
|
@ -76,7 +76,7 @@ private:
|
|||
|
||||
RefPtr<GUI::Menu> m_zoom_menu;
|
||||
|
||||
CookieJar& m_cookie_jar;
|
||||
WebView::CookieJar& m_cookie_jar;
|
||||
WindowActions m_window_actions;
|
||||
RefPtr<GUI::TabWidget> m_tab_widget;
|
||||
RefPtr<BookmarksBarWidget> m_bookmarks_bar;
|
||||
|
|
|
@ -15,12 +15,9 @@ set(SOURCES
|
|||
BookmarksBarWidget.cpp
|
||||
BrowserWindow.cpp
|
||||
ConsoleWidget.cpp
|
||||
CookieJar.cpp
|
||||
CookiesModel.cpp
|
||||
Database.cpp
|
||||
DownloadWidget.cpp
|
||||
ElementSizePreviewWidget.cpp
|
||||
History.cpp
|
||||
History/HistoryModel.cpp
|
||||
History/HistoryWidget.cpp
|
||||
IconBag.cpp
|
||||
|
@ -41,5 +38,5 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_app(Browser ICON app-browser)
|
||||
target_link_libraries(Browser PRIVATE LibCore LibFileSystem LibWebView LibWeb LibProtocol LibPublicSuffix LibGUI LibDesktop LibConfig LibGfx LibIPC LibJS LibLocale LibMain LibSyntax LibSQL)
|
||||
target_link_libraries(Browser PRIVATE LibCore LibFileSystem LibWebView LibWeb LibProtocol LibPublicSuffix LibGUI LibDesktop LibConfig LibGfx LibIPC LibJS LibLocale LibMain LibSyntax)
|
||||
link_with_locale_data(Browser)
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Traits.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
class CookieJar;
|
||||
class Database;
|
||||
|
||||
struct CookieStorageKey;
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<>
|
||||
struct Traits<Browser::CookieStorageKey>;
|
||||
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Browser {
|
||||
|
||||
void HistoryModel::set_items(AK::Vector<History::URLTitlePair> items)
|
||||
void HistoryModel::set_items(AK::Vector<WebView::History::URLTitlePair> items)
|
||||
{
|
||||
begin_insert_rows({}, m_entries.size(), m_entries.size());
|
||||
m_entries = items;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Vector.h>
|
||||
#include <Applications/Browser/History.h>
|
||||
#include <LibGUI/Model.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibWebView/History.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
__Count,
|
||||
};
|
||||
|
||||
void set_items(AK::Vector<History::URLTitlePair> items);
|
||||
void set_items(AK::Vector<WebView::History::URLTitlePair> items);
|
||||
void clear_items();
|
||||
virtual int row_count(GUI::ModelIndex const&) const override;
|
||||
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
virtual GUI::Model::MatchResult data_matches(GUI::ModelIndex const& index, GUI::Variant const& term) const override;
|
||||
|
||||
private:
|
||||
AK::Vector<History::URLTitlePair> m_entries;
|
||||
AK::Vector<WebView::History::URLTitlePair> m_entries;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ HistoryWidget::HistoryWidget()
|
|||
m_table_view->set_alternating_row_colors(true);
|
||||
}
|
||||
|
||||
void HistoryWidget::set_history_entries(Vector<History::URLTitlePair> entries)
|
||||
void HistoryWidget::set_history_entries(Vector<WebView::History::URLTitlePair> entries)
|
||||
{
|
||||
m_model->set_items(entries);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../History.h"
|
||||
#include "HistoryModel.h"
|
||||
#include <LibGUI/FilteringProxyModel.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibWebView/History.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
|
@ -20,7 +20,7 @@ class HistoryWidget final : public GUI::Widget {
|
|||
public:
|
||||
virtual ~HistoryWidget() override = default;
|
||||
|
||||
void set_history_entries(Vector<History::URLTitlePair> entries);
|
||||
void set_history_entries(Vector<WebView::History::URLTitlePair> entries);
|
||||
void clear_history_entries();
|
||||
|
||||
private:
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "History.h"
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
|
@ -15,6 +14,7 @@
|
|||
#include <LibGfx/ShareableBitmap.h>
|
||||
#include <LibHTTP/Job.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWebView/History.h>
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
|
||||
namespace WebView {
|
||||
|
@ -122,7 +122,7 @@ private:
|
|||
|
||||
Optional<URL> url_from_location_bar(MayAppendTLD = MayAppendTLD::No);
|
||||
|
||||
History m_history;
|
||||
WebView::History m_history;
|
||||
|
||||
RefPtr<WebView::OutOfProcessWebView> m_web_content_view;
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#include <Applications/Browser/Browser.h>
|
||||
#include <Applications/Browser/BrowserWindow.h>
|
||||
#include <Applications/Browser/CookieJar.h>
|
||||
#include <Applications/Browser/Database.h>
|
||||
#include <Applications/Browser/Tab.h>
|
||||
#include <Applications/Browser/WindowActions.h>
|
||||
#include <Applications/BrowserSettings/Defaults.h>
|
||||
|
@ -26,6 +24,8 @@
|
|||
#include <LibGUI/TabWidget.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/Database.h>
|
||||
#include <LibWebView/OutOfProcessWebView.h>
|
||||
#include <LibWebView/RequestServerAdapter.h>
|
||||
#include <unistd.h>
|
||||
|
@ -140,7 +140,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
Browser::g_icon_bag = TRY(Browser::IconBag::try_create());
|
||||
|
||||
auto database = TRY(Browser::Database::create());
|
||||
auto database = TRY(WebView::Database::create());
|
||||
TRY(load_content_filters());
|
||||
TRY(load_autoplay_allowlist());
|
||||
|
||||
|
@ -169,7 +169,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!specified_urls.is_empty())
|
||||
first_url = TRY(url_from_argument_string(specified_urls.first()));
|
||||
|
||||
auto cookie_jar = TRY(Browser::CookieJar::create(*database));
|
||||
auto cookie_jar = TRY(WebView::CookieJar::create(*database));
|
||||
auto window = Browser::BrowserWindow::construct(cookie_jar, first_url);
|
||||
|
||||
auto content_filters_watcher = TRY(Core::FileWatcher::create());
|
||||
|
|
|
@ -2,7 +2,10 @@ set(SOURCES
|
|||
AccessibilityTreeModel.cpp
|
||||
AriaPropertiesStateModel.cpp
|
||||
ConsoleClient.cpp
|
||||
CookieJar.cpp
|
||||
Database.cpp
|
||||
DOMTreeModel.cpp
|
||||
History.cpp
|
||||
RequestServerAdapter.cpp
|
||||
SourceHighlighter.cpp
|
||||
StylePropertiesModel.cpp
|
||||
|
@ -36,7 +39,7 @@ set(GENERATED_SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibWebView webview)
|
||||
target_link_libraries(LibWebView PRIVATE LibCore LibGfx LibGUI LibIPC LibProtocol LibJS LibWeb)
|
||||
target_link_libraries(LibWebView PRIVATE LibCore LibGfx LibGUI LibIPC LibProtocol LibJS LibWeb LibSQL)
|
||||
|
||||
if (SERENITYOS)
|
||||
target_link_libraries(LibWebView PRIVATE LibFileSystemAccessClient)
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "CookieJar.h"
|
||||
#include "Database.h"
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -19,8 +17,10 @@
|
|||
#include <LibSQL/TupleDescriptor.h>
|
||||
#include <LibSQL/Value.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/Database.h>
|
||||
|
||||
namespace Browser {
|
||||
namespace WebView {
|
||||
|
||||
ErrorOr<CookieJar> CookieJar::create(Database& database)
|
||||
{
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Forward.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
@ -16,10 +15,9 @@
|
|||
#include <LibSQL/Type.h>
|
||||
#include <LibWeb/Cookie/Cookie.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
class Database;
|
||||
namespace WebView {
|
||||
|
||||
struct CookieStorageKey {
|
||||
bool operator==(CookieStorageKey const&) const = default;
|
||||
|
@ -93,8 +91,8 @@ private:
|
|||
}
|
||||
|
||||
template<>
|
||||
struct AK::Traits<Browser::CookieStorageKey> : public AK::GenericTraits<Browser::CookieStorageKey> {
|
||||
static unsigned hash(Browser::CookieStorageKey const& key)
|
||||
struct AK::Traits<WebView::CookieStorageKey> : public AK::GenericTraits<WebView::CookieStorageKey> {
|
||||
static unsigned hash(WebView::CookieStorageKey const& key)
|
||||
{
|
||||
unsigned hash = 0;
|
||||
hash = pair_int_hash(hash, string_hash(key.name.characters(), key.name.length()));
|
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Database.h"
|
||||
#include <AK/StringView.h>
|
||||
#include <LibWebView/Database.h>
|
||||
|
||||
namespace Browser {
|
||||
namespace WebView {
|
||||
|
||||
static constexpr auto database_name = "Browser"sv;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2023, Jelle Raaijmakers <jelle@gmta.nl>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -20,7 +20,7 @@
|
|||
#include <LibSQL/Type.h>
|
||||
#include <LibSQL/Value.h>
|
||||
|
||||
namespace Browser {
|
||||
namespace WebView {
|
||||
|
||||
class Database : public RefCounted<Database> {
|
||||
using OnResult = Function<void(ReadonlySpan<SQL::Value>)>;
|
|
@ -6,11 +6,25 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Traits.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
class ConsoleClient;
|
||||
class CookieJar;
|
||||
class Database;
|
||||
class History;
|
||||
class OutOfProcessWebView;
|
||||
class ViewImplementation;
|
||||
class WebContentClient;
|
||||
|
||||
struct CookieStorageKey;
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<>
|
||||
struct Traits<WebView::CookieStorageKey>;
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "History.h"
|
||||
#include <LibWebView/History.h>
|
||||
|
||||
namespace Browser {
|
||||
namespace WebView {
|
||||
|
||||
void History::dump() const
|
||||
{
|
|
@ -9,7 +9,7 @@
|
|||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Browser {
|
||||
namespace WebView {
|
||||
|
||||
class History {
|
||||
public:
|
Loading…
Add table
Add a link
Reference in a new issue