ladybird/Ladybird/History.h
Matthew Costa 7681ef25da Ladybird: Expanded toolbar with browser history and home button
This patch takes the browser history code from the Serenity browser and
wires it up to the QT interface. This is tied in with a few extra
toolbar buttons associated with each tab.
2022-12-25 07:58:58 -07:00

42 lines
892 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;
String title;
};
void dump() const;
void push(const URL& url, String const& title);
void update_title(String const& title);
URLTitlePair current() const;
Vector<StringView> get_back_title_history();
Vector<StringView> 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 };
};
}