#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list_page_handler.h"
#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/time.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/reading_list/reading_list_model_factory.h"
#include "chrome/browser/ui/bookmarks/bookmark_stats.h"
#include "chrome/browser/ui/bookmarks/bookmark_utils.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/side_panel/reading_list/reading_list_ui.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/policy/core/common/policy_pref_names.h"
#include "components/profile_metrics/browser_profile_type.h"
#include "components/reading_list/core/reading_list_entry.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/time_format.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/mojom/window_open_disposition.mojom.h"
#include "ui/base/window_open_disposition.h"
#include "ui/base/window_open_disposition_utils.h"
#include "url/gurl.h"
namespace {
bool EntrySorter(const reading_list::mojom::ReadLaterEntryPtr& rhs,
const reading_list::mojom::ReadLaterEntryPtr& lhs) { … }
int64_t TimeToUS(const base::Time& time) { … }
class ReadLaterItemContextMenu : public ui::SimpleMenuModel,
public ui::SimpleMenuModel::Delegate { … };
}
ReadingListPageHandler::ReadingListPageHandler(
mojo::PendingReceiver<reading_list::mojom::PageHandler> receiver,
mojo::PendingRemote<reading_list::mojom::Page> page,
ReadingListUI* reading_list_ui,
content::WebUI* web_ui)
: … { … }
ReadingListPageHandler::~ReadingListPageHandler() = default;
void ReadingListPageHandler::GetReadLaterEntries(
GetReadLaterEntriesCallback callback) { … }
void ReadingListPageHandler::OpenURL(
const GURL& url,
bool mark_as_read,
ui::mojom::ClickModifiersPtr click_modifiers) { … }
void ReadingListPageHandler::UpdateReadStatus(const GURL& url, bool read) { … }
void ReadingListPageHandler::MarkCurrentTabAsRead() { … }
void ReadingListPageHandler::AddCurrentTab() { … }
void ReadingListPageHandler::RemoveEntry(const GURL& url) { … }
void ReadingListPageHandler::ShowContextMenuForURL(const GURL& url,
int32_t x,
int32_t y) { … }
void ReadingListPageHandler::UpdateCurrentPageActionButtonState() { … }
void ReadingListPageHandler::ShowUI() { … }
void ReadingListPageHandler::CloseUI() { … }
void ReadingListPageHandler::ReadingListModelCompletedBatchUpdates(
const ReadingListModel* model) { … }
void ReadingListPageHandler::ReadingListModelBeingDeleted(
const ReadingListModel* model) { … }
void ReadingListPageHandler::ReadingListDidApplyChanges(
ReadingListModel* model) { … }
const std::optional<GURL> ReadingListPageHandler::GetActiveTabURL() { … }
void ReadingListPageHandler::SetActiveTabURL(const GURL& url) { … }
reading_list::mojom::ReadLaterEntryPtr ReadingListPageHandler::GetEntryData(
const ReadingListEntry* entry) { … }
reading_list::mojom::ReadLaterEntriesByStatusPtr
ReadingListPageHandler::CreateReadLaterEntriesByStatusData() { … }
std::string ReadingListPageHandler::GetTimeSinceLastUpdate(
int64_t last_update_time) { … }
void ReadingListPageHandler::UpdateCurrentPageActionButton() { … }
std::unique_ptr<ui::SimpleMenuModel>
ReadingListPageHandler::GetItemContextMenuModelForTesting(
Browser* browser,
ReadingListModel* reading_list_model,
GURL url) { … }