mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-09 03:07:48 -03:00
M119 stage 8
This commit is contained in:
parent
3ca987ebf2
commit
2bd5112793
10 changed files with 197 additions and 154 deletions
|
@ -1,16 +1,3 @@
|
|||
## .grd text replacements (search with grep)
|
||||
|
||||
Chromium > Thorium
|
||||
Chrome > Thorium
|
||||
Google Thorium > Thorium
|
||||
Thorium Web Store > Chrome Web Store (Except some UI elements)
|
||||
Thorium Remote Desktop > Chrome Remote Desktop
|
||||
ThoriumOS Flex > ThoriumOS
|
||||
Made possible by Thorium > Chromium
|
||||
Experiments > Thorium Experiments
|
||||
|
||||
---------------------------------------------------------------------------------------------
|
||||
|
||||
## sandbox perms
|
||||
|
||||
30 55
|
||||
|
|
|
@ -31,6 +31,13 @@ Google recommends Thorium > Alex313031 recommends Thorium
|
|||
|
||||
violates the Thorium > violates the Chrome
|
||||
|
||||
Google Thorium > Thorium
|
||||
## .grd text replacements (search with grep)
|
||||
|
||||
made possible by Chromium
|
||||
Chromium > Thorium
|
||||
Chrome > Thorium
|
||||
Google Thorium > Thorium
|
||||
Thorium Web Store > Chrome Web Store (Except some UI elements)
|
||||
Thorium Remote Desktop > Chrome Remote Desktop
|
||||
ThoriumOS Flex > ThoriumOS
|
||||
made possible by Thorium > Chromium
|
||||
Experiments > Thorium Experiments
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "chrome/common/chrome_constants.h"
|
||||
#include "chrome/grit/chromium_strings.h"
|
||||
#include "chrome/grit/branded_strings.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/common/process_type.h"
|
||||
|
|
|
@ -363,19 +363,12 @@ void BrowserRootView::PaintChildren(const views::PaintInfo& paint_info) {
|
|||
Tab* active_tab = tabstrip()->tab_at(active_tab_index.value());
|
||||
if (active_tab && active_tab->GetVisible()) {
|
||||
gfx::RectF bounds(active_tab->GetMirroredBounds());
|
||||
views::View* tabstrip_root = this;
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// In immersive fullscreen, the top container is hosted in
|
||||
// The root of the views tree that hosts tabstrip is BrowserRootView.
|
||||
// Except in Mac Immersive Fullscreen where the tabstrip is hosted in
|
||||
// `overlay_widget` or `tab_overlay_widget`, each have their own root
|
||||
// view.
|
||||
if (browser_view_->immersive_mode_controller()->IsRevealed()) {
|
||||
tabstrip_root =
|
||||
browser_view_->UsesImmersiveFullscreenTabbedMode()
|
||||
? browser_view_->tab_overlay_widget()->GetRootView()
|
||||
: browser_view_->overlay_widget()->GetRootView();
|
||||
}
|
||||
#endif
|
||||
ConvertRectToTarget(tabstrip(), tabstrip_root, &bounds);
|
||||
ConvertRectToTarget(tabstrip(), tabstrip()->GetWidget()->GetRootView(),
|
||||
&bounds);
|
||||
canvas->ClipRect(bounds, SkClipOp::kDifference);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,10 @@
|
|||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/window/non_client_view.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "ui/views/win/pen_event_handler_util.h"
|
||||
#endif
|
||||
|
||||
#if defined(USE_AURA)
|
||||
#include "ui/aura/env.h"
|
||||
#endif
|
||||
|
@ -104,6 +108,12 @@ namespace {
|
|||
// transitioning a tab from normal to pinned tab.
|
||||
constexpr int kPinnedTabExtraWidthToRenderAsNormal = 30;
|
||||
|
||||
// Additional padding of close button to the right of the tab
|
||||
// indicator when `extra_alert_indicator_padding_` is true.
|
||||
constexpr int kTabAlertIndicatorCloseButtonPaddingAdjustmentTouchUI = 8;
|
||||
constexpr int kTabAlertIndicatorCloseButtonPaddingAdjustment = 6;
|
||||
constexpr int kTabAlertIndicatorCloseButtonPaddingAdjustmentRefresh = 4;
|
||||
|
||||
bool g_show_hover_card_on_mouse_hover = true;
|
||||
|
||||
// Helper functions ------------------------------------------------------------
|
||||
|
@ -223,7 +233,8 @@ Tab::Tab(TabSlotController* controller)
|
|||
// onto opaque parts of a not-entirely-opaque layer.
|
||||
title_->SetSkipSubpixelRenderingOpacityCheck(true);
|
||||
|
||||
if (features::IsChromeRefresh2023()) {
|
||||
if (features::IsChromeRefresh2023() &&
|
||||
base::FeatureList::IsEnabled(features::kChromeRefresh2023TopChromeFont)) {
|
||||
title_->SetTextContext(views::style::CONTEXT_LABEL);
|
||||
title_->SetTextStyle(views::style::STYLE_BODY_4_EMPHASIS);
|
||||
}
|
||||
|
@ -368,8 +379,14 @@ void Tab::Layout() {
|
|||
int right = contents_rect.right();
|
||||
if (showing_close_button_) {
|
||||
right = close_x;
|
||||
if (extra_alert_indicator_padding_)
|
||||
right -= ui::TouchUiController::Get()->touch_ui() ? 8 : 6;
|
||||
if (extra_alert_indicator_padding_) {
|
||||
right -=
|
||||
ui::TouchUiController::Get()->touch_ui()
|
||||
? kTabAlertIndicatorCloseButtonPaddingAdjustmentTouchUI
|
||||
: (features::IsChromeRefresh2023()
|
||||
? kTabAlertIndicatorCloseButtonPaddingAdjustmentRefresh
|
||||
: kTabAlertIndicatorCloseButtonPaddingAdjustment);
|
||||
}
|
||||
}
|
||||
const gfx::Size image_size = alert_indicator_button_->GetPreferredSize();
|
||||
gfx::Rect bounds(
|
||||
|
@ -667,8 +684,21 @@ void Tab::OnGestureEvent(ui::GestureEvent* event) {
|
|||
ui::GestureEvent cloned_event(event_in_parent, parent(),
|
||||
static_cast<View*>(this));
|
||||
|
||||
if (!closing())
|
||||
if (!closing()) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// If the pen is down on the tab, let pen events fall through to the
|
||||
// default window handler until the pen is raised. This allows the
|
||||
// default window handler to execute drag-drop on the window when it's
|
||||
// moved by its tab, e.g., when the window has a single tab or when a
|
||||
// tab is being detached.
|
||||
const bool is_pen = event->details().primary_pointer_type() ==
|
||||
ui::EventPointerType::kPen;
|
||||
if (is_pen) {
|
||||
views::UseDefaultHandlerForPenEventsUntilPenUp();
|
||||
}
|
||||
#endif
|
||||
controller_->MaybeStartDrag(this, cloned_event, original_selection);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -855,6 +885,14 @@ bool Tab::IsSelected() const {
|
|||
return controller_->IsTabSelected(this);
|
||||
}
|
||||
|
||||
bool Tab::IsDiscarded() const {
|
||||
return data().is_tab_discarded;
|
||||
}
|
||||
|
||||
bool Tab::HasThumbnail() const {
|
||||
return data().thumbnail && data().thumbnail->has_data();
|
||||
}
|
||||
|
||||
void Tab::SetData(TabRendererData data) {
|
||||
DCHECK(GetWidget());
|
||||
|
||||
|
|
|
@ -1727,13 +1727,7 @@ std::u16string TabStrip::GetAccessibleTabName(const Tab* tab) const {
|
|||
|
||||
absl::optional<int> TabStrip::GetCustomBackgroundId(
|
||||
BrowserFrameActiveState active_state) const {
|
||||
if (!TitlebarBackgroundIsTransparent())
|
||||
return controller_->GetCustomBackgroundId(active_state);
|
||||
|
||||
constexpr int kBackgroundIdGlass = IDR_THEME_TAB_BACKGROUND_V;
|
||||
return GetThemeProvider()->HasCustomImage(kBackgroundIdGlass)
|
||||
? absl::make_optional(kBackgroundIdGlass)
|
||||
: absl::nullopt;
|
||||
return controller_->GetCustomBackgroundId(active_state);
|
||||
}
|
||||
|
||||
float TabStrip::GetHoverOpacityForTab(float range_parameter) const {
|
||||
|
|
|
@ -21,11 +21,14 @@
|
|||
#include "chrome/browser/ui/tabs/tab_style.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
|
||||
#include "chrome/browser/ui/views/frame/browser_view.h"
|
||||
#include "chrome/browser/ui/views/frame/top_container_background.h"
|
||||
#include "chrome/browser/ui/views/tabs/glow_hover_controller.h"
|
||||
#include "chrome/browser/ui/views/tabs/tab.h"
|
||||
#include "chrome/browser/ui/views/tabs/tab_close_button.h"
|
||||
#include "chrome/browser/ui/views/tabs/tab_group_underline.h"
|
||||
#include "chrome/browser/ui/views/tabs/tab_slot_controller.h"
|
||||
#include "chrome/browser/ui/views/tabs/tab_slot_view.h"
|
||||
#include "chrome/grit/theme_resources.h"
|
||||
#include "components/tab_groups/tab_group_visual_data.h"
|
||||
#include "third_party/skia/include/core/SkRRect.h"
|
||||
|
@ -206,6 +209,8 @@ GM2TabStyleViews::GM2TabStyleViews(Tab* tab)
|
|||
views::style::STYLE_PRIMARY)),
|
||||
heavy_font_(views::style::GetFont(views::style::CONTEXT_BUTTON_MD,
|
||||
views::style::STYLE_PRIMARY)) {
|
||||
// `tab_` must not be nullptr.
|
||||
CHECK(tab_);
|
||||
// TODO(dfried): create a new STYLE_PROMINENT or similar to use instead of
|
||||
// repurposing CONTEXT_BUTTON_MD.
|
||||
}
|
||||
|
@ -537,7 +542,6 @@ const gfx::FontList& GM2TabStyleViews::GetFontList() const {
|
|||
return normal_font_;
|
||||
}
|
||||
|
||||
|
||||
void GM2TabStyleViews::PaintTab(gfx::Canvas* canvas) const {
|
||||
absl::optional<int> active_tab_fill_id;
|
||||
if (tab_->GetThemeProvider()->HasCustomImage(IDR_THEME_TOOLBAR)) {
|
||||
|
@ -961,10 +965,12 @@ void GM2TabStyleViews::PaintTabBackgroundFill(
|
|||
if (fill_id.has_value()) {
|
||||
gfx::ScopedCanvas scale_scoper(canvas);
|
||||
canvas->sk_canvas()->scale(scale, scale);
|
||||
canvas->TileImageInt(
|
||||
*tab_->GetThemeProvider()->GetImageSkiaNamed(fill_id.value()),
|
||||
tab_->GetMirroredX() + tab_->controller()->GetBackgroundOffset(), 0, 0,
|
||||
y_inset, tab_->width(), tab_->height());
|
||||
gfx::ImageSkia* image =
|
||||
tab_->GetThemeProvider()->GetImageSkiaNamed(fill_id.value());
|
||||
TopContainerBackground::PaintThemeAlignedImage(
|
||||
canvas, tab_,
|
||||
BrowserView::GetBrowserViewForBrowser(tab_->controller()->GetBrowser()),
|
||||
image);
|
||||
}
|
||||
|
||||
if (hovered) {
|
||||
|
@ -1211,12 +1217,22 @@ SkPath ChromeRefresh2023TabStyleViews::GetPath(
|
|||
const int right_separator_overlap =
|
||||
tab_style()->GetSeparatorSize().width() - left_separator_overlap;
|
||||
|
||||
left -= (tab_style()->GetSeparatorMargins().right() +
|
||||
left_separator_overlap) *
|
||||
scale;
|
||||
right += (tab_style()->GetSeparatorMargins().left() +
|
||||
right_separator_overlap) *
|
||||
scale;
|
||||
// If there is a tab before this one, then expand into its overlap.
|
||||
const Tab* const previous_tab =
|
||||
tab()->controller()->GetAdjacentTab(tab(), -1);
|
||||
if (previous_tab) {
|
||||
left -= (tab_style()->GetSeparatorMargins().right() +
|
||||
left_separator_overlap) *
|
||||
scale;
|
||||
}
|
||||
|
||||
// If there is a tab after this one, then expand into its overlap.
|
||||
const Tab* const next_tab = tab()->controller()->GetAdjacentTab(tab(), 1);
|
||||
if (next_tab) {
|
||||
right += (tab_style()->GetSeparatorMargins().left() +
|
||||
right_separator_overlap) *
|
||||
scale;
|
||||
}
|
||||
}
|
||||
|
||||
SkPath path;
|
||||
|
|
|
@ -17,10 +17,16 @@ const char kEnableSnippets[] = "ntp_snippets.enable";
|
|||
// FEED_ARTICLES_LIST_VISIBLE in ChromePreferenceKeys.java is a pre-native cache
|
||||
// and should be consistent with this pref.
|
||||
const char kArticlesListVisible[] = "ntp_snippets.list_visible";
|
||||
// A boolean pref set to true if swapping out NTP isn't enabled or if DSE is
|
||||
// Google.
|
||||
// TODO(https://crbug.com/1483475): Inhibit loading feeds in native feeds code
|
||||
// when this pref is set to false.
|
||||
const char kEnableSnippetsByDse[] = "ntp_snippets_by_dse.enable";
|
||||
|
||||
void RegisterFeedSharedProfilePrefs(PrefRegistrySimple* registry) {
|
||||
registry->RegisterBooleanPref(kEnableSnippets, true);
|
||||
registry->RegisterBooleanPref(kArticlesListVisible, false);
|
||||
registry->RegisterBooleanPref(kEnableSnippetsByDse, true);
|
||||
}
|
||||
|
||||
} // namespace prefs
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include "components/history/core/browser/keyword_search_term_util.h"
|
||||
#include "components/history/core/browser/page_usage_data.h"
|
||||
#include "components/history/core/browser/sync/history_sync_bridge.h"
|
||||
#include "components/history/core/browser/sync/typed_url_sync_bridge.h"
|
||||
#include "components/history/core/browser/url_row.h"
|
||||
#include "components/history/core/browser/url_utils.h"
|
||||
#include "components/sync/base/features.h"
|
||||
#include "components/sync/base/report_unrecoverable_error.h"
|
||||
|
@ -92,6 +92,7 @@ using syncer::ClientTagBasedModelTypeProcessor;
|
|||
URLDatabase (stores a list of URLs)
|
||||
DownloadDatabase (stores a list of downloads)
|
||||
VisitDatabase (stores a list of visits for the URLs)
|
||||
VisitedLinkDatabase (stores a list of triple-key partitioned URLs)
|
||||
VisitSegmentDatabase (stores groups of URLs for the most visited view).
|
||||
|
||||
ExpireHistoryBackend (manages deleting things older than 3 months)
|
||||
|
@ -179,6 +180,11 @@ constexpr int kDomainDiversityMaxBacktrackedDays = 7;
|
|||
// avoid other potential issues.
|
||||
constexpr int kDSTRoundingOffsetHours = 4;
|
||||
|
||||
// When batch-deleting foreign visits (i.e. visits coming from other devices),
|
||||
// this specifies how many visits to delete in a single HistoryDBTask. This
|
||||
// usually happens when history sync was turned off.
|
||||
constexpr int kSyncHistoryForeignVisitsToDeletePerBatch = 100;
|
||||
|
||||
// Merges `update` into `existing` by overwriting fields in `existing` that are
|
||||
// not the default value in `update`.
|
||||
void MergeUpdateIntoExistingModelAnnotations(
|
||||
|
@ -203,24 +209,13 @@ void MergeUpdateIntoExistingModelAnnotations(
|
|||
}
|
||||
}
|
||||
|
||||
// Killswitch for the logic to start deleting foreign history on startup (if a
|
||||
// previous foreign-history-deletion operation didn't finish before browser
|
||||
// shutdown).
|
||||
BASE_FEATURE(kDeleteForeignVisitsOnStartup,
|
||||
"DeleteForeignVisitsOnStartup",
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
|
||||
int GetForeignVisitsToDeletePerBatch() {
|
||||
return syncer::kSyncHistoryForeignVisitsToDeletePerBatch.Get();
|
||||
}
|
||||
|
||||
class DeleteForeignVisitsDBTask : public HistoryDBTask {
|
||||
public:
|
||||
~DeleteForeignVisitsDBTask() override = default;
|
||||
|
||||
bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) override {
|
||||
VisitID max_visit_id = db->GetDeleteForeignVisitsUntilId();
|
||||
int max_count = GetForeignVisitsToDeletePerBatch();
|
||||
int max_count = kSyncHistoryForeignVisitsToDeletePerBatch;
|
||||
|
||||
VisitVector visits;
|
||||
if (!db->GetSomeForeignVisits(max_visit_id, max_count, &visits)) {
|
||||
|
@ -287,6 +282,14 @@ bool CanAddForeignVisitToSegments(
|
|||
#endif
|
||||
}
|
||||
|
||||
// Returns whether a page visit has a ui::PageTransition type that allows us
|
||||
// to construct a triple partition key for the VisitedLinkDatabase.
|
||||
bool IsVisitedLinkTransition(ui::PageTransition transition) {
|
||||
return ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_LINK) ||
|
||||
ui::PageTransitionCoreTypeIs(transition,
|
||||
ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::u16string FormatUrlForRedirectComparison(const GURL& url) {
|
||||
|
@ -410,34 +413,17 @@ void HistoryBackend::Init(
|
|||
InitImpl(history_database_params);
|
||||
delegate_->DBLoaded();
|
||||
|
||||
typed_url_sync_bridge_ = std::make_unique<TypedURLSyncBridge>(
|
||||
this, db_ ? db_->GetTypedURLMetadataDB() : nullptr,
|
||||
history_sync_bridge_ = std::make_unique<HistorySyncBridge>(
|
||||
this, db_ ? db_->GetHistoryMetadataDB() : nullptr,
|
||||
std::make_unique<ClientTagBasedModelTypeProcessor>(
|
||||
syncer::TYPED_URLS,
|
||||
syncer::HISTORY,
|
||||
base::BindRepeating(&syncer::ReportUnrecoverableError,
|
||||
history_database_params.channel)));
|
||||
typed_url_sync_bridge_->Init();
|
||||
|
||||
if (base::FeatureList::IsEnabled(syncer::kSyncEnableHistoryDataType)) {
|
||||
history_sync_bridge_ = std::make_unique<HistorySyncBridge>(
|
||||
this, db_ ? db_->GetHistoryMetadataDB() : nullptr,
|
||||
std::make_unique<ClientTagBasedModelTypeProcessor>(
|
||||
syncer::HISTORY,
|
||||
base::BindRepeating(&syncer::ReportUnrecoverableError,
|
||||
history_database_params.channel)));
|
||||
}
|
||||
|
||||
if (base::FeatureList::IsEnabled(kDeleteForeignVisitsOnStartup) && db_) {
|
||||
if (!base::FeatureList::IsEnabled(syncer::kSyncEnableHistoryDataType) &&
|
||||
db_->MayContainForeignVisits()) {
|
||||
// If the History Sync data type is disabled, but there are foreign visits
|
||||
// left (because it was previously enabled), then clean them up now.
|
||||
DeleteAllForeignVisitsAndResetIsKnownToSync();
|
||||
} else if (db_->GetDeleteForeignVisitsUntilId() != kInvalidVisitID) {
|
||||
// A deletion of foreign visits was still ongoing during the previous
|
||||
// browser shutdown. Continue it.
|
||||
StartDeletingForeignVisits();
|
||||
}
|
||||
if (db_ && db_->GetDeleteForeignVisitsUntilId() != kInvalidVisitID) {
|
||||
// A deletion of foreign visits was still ongoing during the previous
|
||||
// browser shutdown. Continue it.
|
||||
StartDeletingForeignVisits();
|
||||
}
|
||||
|
||||
memory_pressure_listener_ = std::make_unique<base::MemoryPressureListener>(
|
||||
|
@ -1012,6 +998,17 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
|
|||
request.opener->url);
|
||||
}
|
||||
|
||||
// Every url in the redirect chain gets the same top_level_url and frame_url
|
||||
// values.
|
||||
absl::optional<GURL> top_level_url = absl::nullopt;
|
||||
if (request.top_level_url.has_value() && request.top_level_url->is_valid()) {
|
||||
top_level_url = request.top_level_url;
|
||||
}
|
||||
absl::optional<GURL> frame_url = absl::nullopt;
|
||||
if (request.referrer.is_valid()) {
|
||||
frame_url = request.referrer;
|
||||
}
|
||||
|
||||
if (!has_redirects) {
|
||||
// The single entry is both a chain start and end.
|
||||
ui::PageTransition t = ui::PageTransitionFromInt(
|
||||
|
@ -1024,7 +1021,8 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
|
|||
external_referrer_url, t, request.hidden,
|
||||
request.visit_source, IsTypedIncrement(t), opener_visit,
|
||||
request.consider_for_ntp_most_visited,
|
||||
request.local_navigation_id, request.title)
|
||||
request.local_navigation_id, request.title, top_level_url,
|
||||
frame_url)
|
||||
.second;
|
||||
|
||||
// Update the segment for this visit. KEYWORD_GENERATED visits should not
|
||||
|
@ -1152,7 +1150,8 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
|
|||
should_increment_typed_count,
|
||||
redirect_index == 0 ? opener_visit : 0,
|
||||
request.consider_for_ntp_most_visited,
|
||||
request.local_navigation_id, request.title)
|
||||
request.local_navigation_id, request.title,
|
||||
top_level_url, frame_url)
|
||||
.second;
|
||||
|
||||
if (t & ui::PAGE_TRANSITION_CHAIN_START) {
|
||||
|
@ -1355,6 +1354,8 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
|
|||
bool consider_for_ntp_most_visited,
|
||||
absl::optional<int64_t> local_navigation_id,
|
||||
absl::optional<std::u16string> title,
|
||||
absl::optional<GURL> top_level_url,
|
||||
absl::optional<GURL> frame_url,
|
||||
absl::optional<base::TimeDelta> visit_duration,
|
||||
absl::optional<std::string> originator_cache_guid,
|
||||
absl::optional<VisitID> originator_visit_id,
|
||||
|
@ -1397,6 +1398,40 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
|
|||
url_info.set_id(url_id);
|
||||
}
|
||||
|
||||
VisitedLinkRow visited_link_info;
|
||||
if (base::FeatureList::IsEnabled(kPopulateVisitedLinkDatabase)) {
|
||||
// We require a top_level_site and a frame_origin to construct a
|
||||
// visited link partition key. So if top_level_url and/or fame_url are NULL
|
||||
// OR the transition type is a context where we know we cannot accurately
|
||||
// construct a triple partition key, then we skip the VisitedLinkDatabase.
|
||||
if (IsVisitedLinkTransition(transition) && top_level_url.has_value() &&
|
||||
frame_url.has_value()) {
|
||||
// Determine if the visited link is already in the database.
|
||||
VisitedLinkID existing_row_id = db_->GetRowForVisitedLink(
|
||||
url_id, *top_level_url, *frame_url, visited_link_info);
|
||||
// If the returned row id is valid, we update this existing row.
|
||||
if (existing_row_id) {
|
||||
if (!db_->UpdateVisitedLinkRowVisitCount(
|
||||
existing_row_id, visited_link_info.visit_count + 1)) {
|
||||
// If the update fails, log an error and return.
|
||||
DLOG(ERROR) << "AddPageVisit: Updating VisitedLink failed: " << url
|
||||
<< " " << *top_level_url << " " << *frame_url;
|
||||
return std::make_pair(0, 0);
|
||||
}
|
||||
} else { // otherwise, insert this new visited link.
|
||||
VisitedLinkID new_row_id =
|
||||
db_->AddVisitedLink(url_id, *top_level_url, *frame_url, 1);
|
||||
if (!new_row_id) {
|
||||
// If the insert fails, log an error and return.
|
||||
DLOG(ERROR) << "AddPageVisit: Inserting VisitedLink failed: " << url
|
||||
<< " " << *top_level_url << " " << *frame_url;
|
||||
return std::make_pair(0, 0);
|
||||
}
|
||||
db_->GetVisitedLinkRow(new_row_id, visited_link_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the visit with the time to the database.
|
||||
VisitRow visit_info(url_id, time, referring_visit, transition,
|
||||
/*arg_segment_id=*/0, should_increment_typed_count,
|
||||
|
@ -1412,6 +1447,15 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
|
|||
visit_info.originator_referring_visit = *originator_referring_visit;
|
||||
if (originator_opener_visit.has_value())
|
||||
visit_info.originator_opener_visit = *originator_opener_visit;
|
||||
if (visited_link_info.id) {
|
||||
visit_info.visited_link_id = visited_link_info.id;
|
||||
}
|
||||
|
||||
// TODO(crbug.com/1476511): any visit added via sync should not have a
|
||||
// corresponding entry in the VisitedLinkDatabase.
|
||||
if (visit_source == VisitSource::SOURCE_SYNCED) {
|
||||
CHECK(visit_info.visited_link_id == kInvalidVisitedLinkID);
|
||||
}
|
||||
|
||||
visit_info.is_known_to_sync = is_known_to_sync;
|
||||
visit_info.consider_for_ntp_most_visited = consider_for_ntp_most_visited;
|
||||
|
@ -1431,6 +1475,8 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit(
|
|||
return std::make_pair(url_id, visit_info.visit_id);
|
||||
}
|
||||
|
||||
// TODO(crbug.com/1475714): Determine if we want to record these URLs in the
|
||||
// VisitedLinkDatabase, and if so, plumb the correct value for top_level_site.
|
||||
void HistoryBackend::AddPagesWithDetails(const URLRows& urls,
|
||||
VisitSource visit_source) {
|
||||
TRACE_EVENT0("browser", "HistoryBackend::AddPagesWithDetails");
|
||||
|
@ -1489,18 +1535,13 @@ void HistoryBackend::AddPagesWithDetails(const URLRows& urls,
|
|||
ScheduleCommit();
|
||||
}
|
||||
|
||||
void HistoryBackend::SetTypedURLSyncBridgeForTest(
|
||||
std::unique_ptr<TypedURLSyncBridge> bridge) {
|
||||
typed_url_sync_bridge_ = std::move(bridge);
|
||||
}
|
||||
|
||||
bool HistoryBackend::IsExpiredVisitTime(const base::Time& time) const {
|
||||
return time < expirer_.GetCurrentExpirationTime();
|
||||
}
|
||||
|
||||
// static
|
||||
int HistoryBackend::GetForeignVisitsToDeletePerBatchForTest() {
|
||||
return GetForeignVisitsToDeletePerBatch();
|
||||
return kSyncHistoryForeignVisitsToDeletePerBatch;
|
||||
}
|
||||
|
||||
sql::Database& HistoryBackend::GetDBForTesting() {
|
||||
|
@ -1620,49 +1661,6 @@ bool HistoryBackend::GetMostRecentVisitsForURL(URLID id,
|
|||
return false;
|
||||
}
|
||||
|
||||
size_t HistoryBackend::UpdateURLs(const URLRows& urls) {
|
||||
if (!db_)
|
||||
return 0;
|
||||
|
||||
URLRows changed_urls;
|
||||
for (auto it = urls.begin(); it != urls.end(); ++it) {
|
||||
DCHECK(it->id());
|
||||
if (db_->UpdateURLRow(it->id(), *it))
|
||||
changed_urls.push_back(*it);
|
||||
}
|
||||
|
||||
// Broadcast notifications for any URLs that have actually been changed. This
|
||||
// will update the in-memory database and the InMemoryURLIndex.
|
||||
size_t num_updated_records = changed_urls.size();
|
||||
if (num_updated_records) {
|
||||
NotifyURLsModified(changed_urls, /*is_from_expiration=*/false);
|
||||
ScheduleCommit();
|
||||
}
|
||||
return num_updated_records;
|
||||
}
|
||||
|
||||
bool HistoryBackend::AddVisits(const GURL& url,
|
||||
const std::vector<VisitInfo>& visits,
|
||||
VisitSource visit_source) {
|
||||
if (db_) {
|
||||
for (const auto& visit : visits) {
|
||||
if (!AddPageVisit(url, visit.first, /*referring_visit=*/0,
|
||||
/*external_referrer_url=*/GURL(), visit.second,
|
||||
/*hidden=*/!ui::PageTransitionIsMainFrame(visit.second),
|
||||
visit_source, IsTypedIncrement(visit.second),
|
||||
/*opener_visit=*/0,
|
||||
/*consider_for_ntp_most_visited=*/true,
|
||||
/*local_navigation_id=*/absl::nullopt)
|
||||
.first) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ScheduleCommit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HistoryBackend::GetForeignVisit(const std::string& originator_cache_guid,
|
||||
VisitID originator_visit_id,
|
||||
VisitRow* visit_row) {
|
||||
|
@ -1699,10 +1697,11 @@ VisitID HistoryBackend::AddSyncedVisit(
|
|||
visit.transition, hidden, VisitSource::SOURCE_SYNCED,
|
||||
IsTypedIncrement(visit.transition), visit.opener_visit,
|
||||
visit.consider_for_ntp_most_visited,
|
||||
/*local_navigation_id=*/absl::nullopt, title, visit.visit_duration,
|
||||
visit.originator_cache_guid, visit.originator_visit_id,
|
||||
visit.originator_referring_visit, visit.originator_opener_visit,
|
||||
visit.is_known_to_sync);
|
||||
/*local_navigation_id=*/absl::nullopt, title,
|
||||
/*top_level_url=*/absl::nullopt, /*frame_url=*/absl::nullopt,
|
||||
visit.visit_duration, visit.originator_cache_guid,
|
||||
visit.originator_visit_id, visit.originator_referring_visit,
|
||||
visit.originator_opener_visit, visit.is_known_to_sync);
|
||||
|
||||
if (visit_id == kInvalidVisitID) {
|
||||
// Adding the page visit failed, do not continue.
|
||||
|
@ -1796,6 +1795,10 @@ VisitID HistoryBackend::UpdateSyncedVisit(
|
|||
// existing row. It'll be updated below, if necessary.
|
||||
updated_row.segment_id = original_row.segment_id;
|
||||
|
||||
// TODO(crbug.com/1476511): any VisitedLinkID associated with `updated_row`
|
||||
// will be voided to avoid storing stale/incorrect VisitedLinkIDs once
|
||||
// elements of the VisitRow's partition key change (in this case the
|
||||
// referring_visit).
|
||||
if (!db_->UpdateVisitRow(updated_row)) {
|
||||
return kInvalidVisitID;
|
||||
}
|
||||
|
@ -1843,6 +1846,10 @@ bool HistoryBackend::UpdateVisitReferrerOpenerIDs(VisitID visit_id,
|
|||
row.referring_visit = referrer_id;
|
||||
row.opener_visit = opener_id;
|
||||
|
||||
// TODO(crbug.com/1476511): any VisitedLinkID associated with `row`
|
||||
// will be voided to avoid storing stale/incorrect VisitedLinkIDs once
|
||||
// elements of the VisitRow's partition key change (in this case the
|
||||
// referring_visit).
|
||||
bool result = db_->UpdateVisitRow(row);
|
||||
|
||||
if (result && can_add_foreign_visits_to_segments_) {
|
||||
|
@ -1956,12 +1963,6 @@ QueryURLResult HistoryBackend::QueryURL(const GURL& url, bool want_visits) {
|
|||
return result;
|
||||
}
|
||||
|
||||
base::WeakPtr<syncer::ModelTypeControllerDelegate>
|
||||
HistoryBackend::GetTypedURLSyncControllerDelegate() {
|
||||
DCHECK(typed_url_sync_bridge_);
|
||||
return typed_url_sync_bridge_->change_processor()->GetControllerDelegate();
|
||||
}
|
||||
|
||||
base::WeakPtr<syncer::ModelTypeControllerDelegate>
|
||||
HistoryBackend::GetHistorySyncControllerDelegate() {
|
||||
DCHECK(history_sync_bridge_);
|
||||
|
@ -2808,9 +2809,12 @@ MostVisitedURLList HistoryBackend::QueryMostVisitedURLs(int result_count) {
|
|||
db_->QuerySegmentUsage(result_count, url_filter);
|
||||
|
||||
MostVisitedURLList result;
|
||||
for (const std::unique_ptr<PageUsageData>& current_data : data)
|
||||
result.emplace_back(current_data->GetURL(), current_data->GetTitle(),
|
||||
current_data->GetScore());
|
||||
for (const std::unique_ptr<PageUsageData>& current_data : data) {
|
||||
result.emplace_back(current_data->GetURL(), current_data->GetTitle());
|
||||
result.back().visit_count = current_data->GetVisitCount();
|
||||
result.back().last_visit_time = current_data->GetLastVisitTimeslot();
|
||||
result.back().score = current_data->GetScore();
|
||||
}
|
||||
|
||||
UMA_HISTOGRAM_TIMES("History.QueryMostVisitedURLsTime",
|
||||
base::TimeTicks::Now() - begin_time);
|
||||
|
@ -3494,10 +3498,8 @@ void HistoryBackend::KillHistoryDatabase() {
|
|||
if (!db_)
|
||||
return;
|
||||
|
||||
// Notify the sync bridges about storage error. They'll report failures to the
|
||||
// Notify the sync bridge about storage error. It'll report failures to the
|
||||
// sync engine and stop accepting remote updates.
|
||||
if (typed_url_sync_bridge_)
|
||||
typed_url_sync_bridge_->OnDatabaseError();
|
||||
if (history_sync_bridge_)
|
||||
history_sync_bridge_->OnDatabaseError();
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7ca871fcc2334299932c655b982f568e0c038e10
|
||||
Subproject commit b120b1cd91dfc95c0132bdac44a5455f5c5b4c83
|
Loading…
Reference in a new issue