mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:34:59 +00:00
Browser+LibWeb+WebContent: Add ability to inspect local storage
The storage inspector now has a new tab for local storage. The next step would be to persist local storage and receive real-time notifications for changes to update the table view.
This commit is contained in:
parent
f2b4c044db
commit
45a81f5a2c
14 changed files with 168 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "StorageWidget.h"
|
||||
#include "CookiesModel.h"
|
||||
#include "LocalStorageModel.h"
|
||||
#include <AK/Variant.h>
|
||||
#include <Applications/Browser/CookiesTabGML.h>
|
||||
#include <Applications/Browser/StorageWidgetGML.h>
|
||||
|
@ -26,12 +27,25 @@ StorageWidget::StorageWidget()
|
|||
m_cookies_table_view = cookies_tab->find_descendant_of_type_named<GUI::TableView>("cookies_tableview");
|
||||
m_cookies_model = adopt_ref(*new CookiesModel());
|
||||
|
||||
m_sorting_model = MUST(GUI::SortingProxyModel::create(*m_cookies_model));
|
||||
m_sorting_model->set_sort_role(GUI::ModelRole::Display);
|
||||
m_cookie_sorting_model = MUST(GUI::SortingProxyModel::create(*m_cookies_model));
|
||||
m_cookie_sorting_model->set_sort_role(GUI::ModelRole::Display);
|
||||
|
||||
m_cookies_table_view->set_model(m_sorting_model);
|
||||
m_cookies_table_view->set_model(m_cookie_sorting_model);
|
||||
m_cookies_table_view->set_column_headers_visible(true);
|
||||
m_cookies_table_view->set_alternating_row_colors(true);
|
||||
|
||||
auto local_storage_tab = tab_widget.try_add_tab<GUI::Widget>("Local Storage").release_value_but_fixme_should_propagate_errors();
|
||||
local_storage_tab->load_from_gml(cookies_tab_gml);
|
||||
|
||||
m_local_storage_table_view = local_storage_tab->find_descendant_of_type_named<GUI::TableView>("cookies_tableview");
|
||||
m_local_storage_model = adopt_ref(*new LocalStorageModel());
|
||||
|
||||
m_local_storage_sorting_model = MUST(GUI::SortingProxyModel::create(*m_local_storage_model));
|
||||
m_local_storage_sorting_model->set_sort_role(GUI::ModelRole::Display);
|
||||
|
||||
m_local_storage_table_view->set_model(m_local_storage_sorting_model);
|
||||
m_local_storage_table_view->set_column_headers_visible(true);
|
||||
m_local_storage_table_view->set_alternating_row_colors(true);
|
||||
}
|
||||
|
||||
void StorageWidget::add_cookie(Web::Cookie::Cookie const& cookie)
|
||||
|
@ -44,4 +58,14 @@ void StorageWidget::clear_cookies()
|
|||
m_cookies_model->clear_items();
|
||||
}
|
||||
|
||||
void StorageWidget::set_local_storage_entries(OrderedHashMap<String, String> entries)
|
||||
{
|
||||
m_local_storage_model->set_items(entries);
|
||||
}
|
||||
|
||||
void StorageWidget::clear_local_storage_entries()
|
||||
{
|
||||
m_local_storage_model->clear_items();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue