#include "components/sessions/core/tab_restore_service_helper.h"
#include <inttypes.h>
#include <stddef.h>
#include <algorithm>
#include <iterator>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/containers/flat_set.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/observer_list.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/values.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/sessions/core/live_tab.h"
#include "components/sessions/core/live_tab_context.h"
#include "components/sessions/core/serialized_navigation_entry.h"
#include "components/sessions/core/session_constants.h"
#include "components/sessions/core/session_id.h"
#include "components/sessions/core/session_types.h"
#include "components/sessions/core/tab_restore_service.h"
#include "components/sessions/core/tab_restore_service_client.h"
#include "components/sessions/core/tab_restore_service_observer.h"
#include "components/sessions/core/tab_restore_types.h"
#include "components/tab_groups/tab_group_id.h"
#include "components/tab_groups/tab_group_visual_data.h"
#include "ui/base/window_open_disposition.h"
namespace sessions {
namespace {
enum class AddBehavior { … };
void AddSerializedNavigationEntries(
LiveTab* live_tab,
AddBehavior behavior,
std::vector<SerializedNavigationEntry>& navigations) { … }
}
TabRestoreServiceHelper::Observer::~Observer() { … }
void TabRestoreServiceHelper::Observer::OnClearEntries() { … }
void TabRestoreServiceHelper::Observer::OnNavigationEntriesDeleted() { … }
void TabRestoreServiceHelper::Observer::OnRestoreEntryById(
SessionID id,
Entries::const_iterator entry_iterator) { … }
void TabRestoreServiceHelper::Observer::OnAddEntry() { … }
TabRestoreServiceHelper::TabRestoreServiceHelper(
TabRestoreService* tab_restore_service,
TabRestoreServiceClient* client,
tab_restore::TimeFactory* time_factory)
: … { … }
void TabRestoreServiceHelper::SetHelperObserver(Observer* observer) { … }
TabRestoreServiceHelper::~TabRestoreServiceHelper() { … }
void TabRestoreServiceHelper::AddObserver(TabRestoreServiceObserver* observer) { … }
void TabRestoreServiceHelper::RemoveObserver(
TabRestoreServiceObserver* observer) { … }
std::optional<SessionID> TabRestoreServiceHelper::CreateHistoricalTab(
LiveTab* live_tab,
int index) { … }
void TabRestoreServiceHelper::BrowserClosing(LiveTabContext* context) { … }
void TabRestoreServiceHelper::BrowserClosed(LiveTabContext* context) { … }
std::unique_ptr<tab_restore::Group>
TabRestoreServiceHelper::CreateHistoricalGroupImpl(
LiveTabContext* context,
const tab_groups::TabGroupId& id) { … }
void TabRestoreServiceHelper::CreateHistoricalGroup(
LiveTabContext* context,
const tab_groups::TabGroupId& id) { … }
void TabRestoreServiceHelper::GroupClosed(const tab_groups::TabGroupId& group) { … }
void TabRestoreServiceHelper::GroupCloseStopped(
const tab_groups::TabGroupId& group) { … }
void TabRestoreServiceHelper::ClearEntries() { … }
bool TabRestoreServiceHelper::DeleteFromTab(const DeletionPredicate& predicate,
Tab* tab) { … }
bool TabRestoreServiceHelper::DeleteFromWindow(
const DeletionPredicate& predicate,
Window* window) { … }
bool TabRestoreServiceHelper::DeleteFromGroup(
const DeletionPredicate& predicate,
Group* group) { … }
void TabRestoreServiceHelper::DeleteNavigationEntries(
const DeletionPredicate& predicate) { … }
const TabRestoreService::Entries& TabRestoreServiceHelper::entries() const { … }
std::vector<LiveTab*> TabRestoreServiceHelper::RestoreMostRecentEntry(
LiveTabContext* context) { … }
void TabRestoreServiceHelper::RemoveEntryById(SessionID id) { … }
LiveTabContext* TabRestoreServiceHelper::RestoreTabOrGroupFromWindow(
Window& window,
SessionID id,
LiveTabContext* context,
WindowOpenDisposition disposition,
std::vector<LiveTab*>* live_tabs) { … }
std::vector<LiveTab*> TabRestoreServiceHelper::RestoreEntryById(
LiveTabContext* context,
SessionID id,
WindowOpenDisposition disposition) { … }
bool TabRestoreServiceHelper::IsRestoring() const { … }
void TabRestoreServiceHelper::NotifyEntriesChanged() { … }
void TabRestoreServiceHelper::NotifyLoaded() { … }
void TabRestoreServiceHelper::AddEntry(std::unique_ptr<Entry> entry,
bool notify,
bool to_front) { … }
void TabRestoreServiceHelper::PruneEntries() { … }
TabRestoreService::Entries::iterator
TabRestoreServiceHelper::GetEntryIteratorById(SessionID id) { … }
bool TabRestoreServiceHelper::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { … }
bool TabRestoreServiceHelper::ValidateEntry(const Entry& entry) { … }
void TabRestoreServiceHelper::PopulateTab(Tab* tab,
int index,
LiveTabContext* context,
LiveTab* live_tab) { … }
LiveTabContext* TabRestoreServiceHelper::RestoreTab(
const Tab& tab,
LiveTabContext* context,
WindowOpenDisposition disposition,
sessions::tab_restore::Type session_restore_type,
LiveTab** live_tab) { … }
bool TabRestoreServiceHelper::ValidateTab(const Tab& tab) { … }
bool TabRestoreServiceHelper::ValidateWindow(const Window& window) { … }
bool TabRestoreServiceHelper::ValidateGroup(const Group& group) { … }
bool TabRestoreServiceHelper::IsTabInteresting(const Tab& tab) { … }
bool TabRestoreServiceHelper::IsWindowInteresting(const Window& window) { … }
bool TabRestoreServiceHelper::IsGroupInteresting(const Group& group) { … }
bool TabRestoreServiceHelper::FilterEntry(const Entry& entry) { … }
void TabRestoreServiceHelper::UpdateTabBrowserIDs(SessionID::id_type old_id,
SessionID new_id) { … }
base::Time TabRestoreServiceHelper::TimeNow() const { … }
}