ladybird/Userland/Libraries/LibWebView/History.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00

45 lines
1.1 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibURL/URL.h>
namespace WebView {
class History {
public:
struct URLTitlePair {
URL::URL url;
ByteString title;
};
void dump() const;
Vector<URLTitlePair> get_all_history_entries();
void push(const URL::URL& url, ByteString const& title);
void replace_current(const URL::URL& url, ByteString const& title);
void update_title(ByteString const& title);
URLTitlePair current() const;
Vector<StringView> const get_back_title_history();
Vector<StringView> const get_forward_title_history();
void go_back(int steps = 1);
void go_forward(int steps = 1);
bool can_go_back(int steps = 1) { return (m_current - steps) >= 0; }
bool can_go_forward(int steps = 1) { return (m_current + steps) < static_cast<int>(m_items.size()); }
void clear();
bool is_empty() const { return m_items.is_empty(); }
private:
Vector<URLTitlePair> m_items;
int m_current { -1 };
};
}