1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:27:35 +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:
Timothy Flynn 2023-08-31 07:07:07 -04:00 committed by Andreas Kling
parent 7d313ff83d
commit 5c5a00dd3a
28 changed files with 76 additions and 107 deletions

View file

@ -9,9 +9,9 @@
#include <AK/Optional.h>
#include <AK/StringView.h>
#include <AK/URL.h>
#include <Browser/CookieJar.h>
#include <LibWeb/CSS/PreferredColorScheme.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWebView/CookieJar.h>
#import <System/Cocoa.h>
@ -21,7 +21,7 @@
@interface ApplicationDelegate : NSObject <NSApplicationDelegate>
- (nullable instancetype)init:(Optional<URL>)initial_url
withCookieJar:(Browser::CookieJar)cookie_jar
withCookieJar:(WebView::CookieJar)cookie_jar
webdriverContentIPCPath:(StringView)webdriver_content_ipc_path;
- (nonnull TabController*)createNewTab:(Optional<URL> const&)url
@ -35,7 +35,7 @@
- (void)removeTab:(nonnull TabController*)controller;
- (Browser::CookieJar&)cookieJar;
- (WebView::CookieJar&)cookieJar;
- (Optional<StringView> const&)webdriverContentIPCPath;
- (Web::CSS::PreferredColorScheme)preferredColorScheme;

View file

@ -22,7 +22,7 @@
URL m_new_tab_page_url;
// This will always be populated, but we cannot have a non-default constructible instance variable.
Optional<Browser::CookieJar> m_cookie_jar;
Optional<WebView::CookieJar> m_cookie_jar;
Optional<StringView> m_webdriver_content_ipc_path;
@ -46,7 +46,7 @@
@implementation ApplicationDelegate
- (instancetype)init:(Optional<URL>)initial_url
withCookieJar:(Browser::CookieJar)cookie_jar
withCookieJar:(WebView::CookieJar)cookie_jar
webdriverContentIPCPath:(StringView)webdriver_content_ipc_path
{
if (self = [super init]) {
@ -110,7 +110,7 @@
[self.managed_tabs removeObject:controller];
}
- (Browser::CookieJar&)cookieJar
- (WebView::CookieJar&)cookieJar
{
return *m_cookie_jar;
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Browser/History.h>
#include <LibWebView/History.h>
#import <Application/ApplicationDelegate.h>
#import <UI/LadybirdWebView.h>
@ -34,7 +34,7 @@ enum class IsHistoryNavigation {
{
DeprecatedString m_title;
Browser::History m_history;
WebView::History m_history;
IsHistoryNavigation m_is_history_navigation;
}

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Browser/CookieJar.h>
#include <Browser/Database.h>
#include <Ladybird/Utilities.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibMain/Main.h>
#include <LibWebView/CookieJar.h>
#include <LibWebView/Database.h>
#import <Application/Application.h>
#import <Application/ApplicationDelegate.h>
@ -48,8 +48,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client(move(sql_server_paths)));
auto database = TRY(Browser::Database::create(move(sql_client)));
auto cookie_jar = TRY(Browser::CookieJar::create(*database));
auto database = TRY(WebView::Database::create(move(sql_client)));
auto cookie_jar = TRY(WebView::CookieJar::create(*database));
Optional<URL> initial_url;
if (auto parsed_url = Ladybird::sanitize_url(url); parsed_url.is_valid()) {

View file

@ -85,20 +85,10 @@ elseif (APPLE)
find_library(COCOA_LIBRARY Cocoa)
endif()
set(BROWSER_SOURCE_DIR ${SERENITY_SOURCE_DIR}/Userland/Applications/Browser/)
set(SOURCES
${BROWSER_SOURCE_DIR}/CookieJar.cpp
${BROWSER_SOURCE_DIR}/Database.cpp
${BROWSER_SOURCE_DIR}/History.cpp
HelperProcess.cpp
Utilities.cpp
)
set(BROWSER_HEADERS
${BROWSER_SOURCE_DIR}/CookieJar.h
${BROWSER_SOURCE_DIR}/Database.h
${BROWSER_SOURCE_DIR}/History.h
)
set(LADYBIRD_HEADERS
HelperProcess.h
Types.h
@ -156,10 +146,6 @@ else()
add_library(ladybird STATIC ${SOURCES})
endif()
target_sources(ladybird PUBLIC FILE_SET browser TYPE HEADERS
BASE_DIRS ${SERENITY_SOURCE_DIR}/Userland/Applications
FILES ${BROWSER_HEADERS}
)
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
BASE_DIRS ${SERENITY_SOURCE_DIR}
FILES ${LADYBIRD_HEADERS}

View file

@ -14,10 +14,10 @@
#include "StringUtils.h"
#include "WebContentView.h"
#include <AK/TypeCasts.h>
#include <Browser/CookieJar.h>
#include <Ladybird/Utilities.h>
#include <LibWeb/CSS/PreferredColorScheme.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWebView/CookieJar.h>
#include <QAction>
#include <QActionGroup>
#include <QClipboard>
@ -39,7 +39,7 @@ static QIcon const& app_icon()
return icon;
}
BrowserWindow::BrowserWindow(Optional<URL> const& initial_url, Browser::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
BrowserWindow::BrowserWindow(Optional<URL> const& initial_url, WebView::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
: m_cookie_jar(cookie_jar)
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
, m_enable_callgrind_profiling(enable_callgrind_profiling)

View file

@ -10,6 +10,7 @@
#include "Tab.h"
#include <LibCore/Forward.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWebView/Forward.h>
#include <QIcon>
#include <QLineEdit>
#include <QMainWindow>
@ -17,10 +18,6 @@
#include <QTabWidget>
#include <QToolBar>
namespace Browser {
class CookieJar;
}
namespace Ladybird {
class WebContentView;
@ -28,7 +25,7 @@ class WebContentView;
class BrowserWindow : public QMainWindow {
Q_OBJECT
public:
explicit BrowserWindow(Optional<URL> const& initial_url, Browser::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
explicit BrowserWindow(Optional<URL> const& initial_url, WebView::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
WebContentView& view() const { return m_current_tab->view(); }
@ -119,7 +116,7 @@ private:
OwnPtr<QAction> m_view_source_action {};
OwnPtr<QAction> m_inspect_dom_node_action {};
Browser::CookieJar& m_cookie_jar;
WebView::CookieJar& m_cookie_jar;
StringView m_webdriver_content_ipc_path;
WebView::EnableCallgrindProfiling m_enable_callgrind_profiling;

View file

@ -11,7 +11,6 @@
#include "Settings.h"
#include "StringUtils.h"
#include "TVGIconEngine.h"
#include <Browser/History.h>
#include <LibGfx/ImageFormats/BMPWriter.h>
#include <LibGfx/Painter.h>
#include <LibWebView/SourceHighlighter.h>

View file

@ -9,7 +9,7 @@
#include "LocationEdit.h"
#include "WebContentView.h"
#include <Browser/History.h>
#include <LibWebView/History.h>
#include <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
@ -82,7 +82,7 @@ private:
LocationEdit* m_location_edit { nullptr };
WebContentView* m_view { nullptr };
BrowserWindow* m_window { nullptr };
Browser::History m_history;
WebView::History m_history;
QString m_title;
QLabel* m_hover_label { nullptr };

View file

@ -9,8 +9,6 @@
#include "Settings.h"
#include "WebContentView.h"
#include <AK/OwnPtr.h>
#include <Browser/CookieJar.h>
#include <Browser/Database.h>
#include <Ladybird/HelperProcess.h>
#include <Ladybird/Utilities.h>
#include <LibCore/ArgsParser.h>
@ -21,6 +19,8 @@
#include <LibGfx/Font/FontDatabase.h>
#include <LibMain/Main.h>
#include <LibSQL/SQLClient.h>
#include <LibWebView/CookieJar.h>
#include <LibWebView/Database.h>
#include <QApplication>
namespace Ladybird {
@ -95,15 +95,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return url;
};
RefPtr<Browser::Database> database;
RefPtr<WebView::Database> database;
if (enable_sql_database) {
auto sql_server_paths = TRY(get_paths_for_helper_process("SQLServer"sv));
auto sql_client = TRY(SQL::SQLClient::launch_server_and_create_client(move(sql_server_paths)));
database = TRY(Browser::Database::create(move(sql_client)));
database = TRY(WebView::Database::create(move(sql_client)));
}
auto cookie_jar = database ? TRY(Browser::CookieJar::create(*database)) : Browser::CookieJar::create();
auto cookie_jar = database ? TRY(WebView::CookieJar::create(*database)) : WebView::CookieJar::create();
Optional<URL> initial_url;
if (auto url = TRY(get_formatted_url(raw_url)); url.is_valid())