2022-03-01 19:10:06 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Tab.h"
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
#include <LibGUI/Model.h>
|
|
|
|
#include <LibGUI/Widget.h>
|
|
|
|
#include <LibWeb/Cookie/Cookie.h>
|
|
|
|
|
|
|
|
namespace Browser {
|
|
|
|
|
|
|
|
class CookiesModel final : public GUI::Model {
|
|
|
|
public:
|
|
|
|
enum Column {
|
|
|
|
Domain,
|
|
|
|
Path,
|
2022-03-30 01:02:50 +03:00
|
|
|
Name,
|
|
|
|
Value,
|
2022-03-01 19:10:06 +03:00
|
|
|
ExpiryTime,
|
2022-10-21 14:01:06 +03:00
|
|
|
SameSite,
|
2022-03-01 19:10:06 +03:00
|
|
|
__Count,
|
|
|
|
};
|
|
|
|
|
2022-05-04 22:53:01 +03:00
|
|
|
void set_items(AK::Vector<Web::Cookie::Cookie> items);
|
2022-03-01 19:10:06 +03:00
|
|
|
void clear_items();
|
2022-05-06 21:30:39 +03:00
|
|
|
virtual int row_count(GUI::ModelIndex const&) const override;
|
2022-03-01 19:10:06 +03:00
|
|
|
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
|
2023-06-13 18:30:15 +03:00
|
|
|
virtual ErrorOr<String> column_name(int) const override;
|
2022-03-01 19:10:06 +03:00
|
|
|
virtual GUI::ModelIndex index(int row, int column = 0, GUI::ModelIndex const& = GUI::ModelIndex()) const override;
|
|
|
|
virtual GUI::Variant data(GUI::ModelIndex const& index, GUI::ModelRole role = GUI::ModelRole::Display) const override;
|
2023-04-26 19:23:08 +03:00
|
|
|
virtual GUI::Model::MatchResult data_matches(GUI::ModelIndex const& index, GUI::Variant const& term) const override;
|
2022-03-01 19:10:06 +03:00
|
|
|
|
2022-11-01 15:30:03 +03:00
|
|
|
Web::Cookie::Cookie take_cookie(GUI::ModelIndex const&);
|
|
|
|
AK::Vector<Web::Cookie::Cookie> take_all_cookies();
|
2022-10-20 18:38:20 +03:00
|
|
|
|
2022-03-01 19:10:06 +03:00
|
|
|
private:
|
|
|
|
AK::Vector<Web::Cookie::Cookie> m_cookies;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|