1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-26 01:05:07 +00:00
serenity/Userland/Applications/Browser/History.h
Linus Groh 6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00

42 lines
1,007 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/URL.h>
#include <AK/Vector.h>
namespace Browser {
class History {
public:
struct URLTitlePair {
URL url;
DeprecatedString title;
};
void dump() const;
void push(const URL& url, DeprecatedString const& title);
void replace_current(const URL& url, DeprecatedString const& title);
void update_title(DeprecatedString 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();
private:
Vector<URLTitlePair> m_items;
int m_current { -1 };
};
}