Commit 8d02ead0 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[NTP][RQ] Adds support for repeatable queries in NTP MV tiles (Part 2)

Adds the Repeatable Queries Service as a source for the NTP MV tiles and
gates the repeatable queries UI changes based on that new source.
In practice, none of the tiles come from that service just yet.

Bug: 1138578
Change-Id: If8f35b70c4f5e1f464df12ec8c11ba7d3bd798b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2481070
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818653}
parent 5939e063
......@@ -195,14 +195,12 @@
style="--column-count: [[columnCount_]]; --row-count: [[rowCount_]];">
<dom-repeat id="tiles" items="[[tiles_]]" on-dom-change="onTilesRendered_">
<template>
<!-- TOOD(crbug.com/1138578): replace the query-tile attr binding to
something that checks whether the tile is a repeatable query tile. -->
<a class="tile" draggable$="[[booleanToString_(customLinksEnabled_)]]"
href$="[[item.url.url]]" title$="[[item.title]]"
on-dragstart="onDragStart_" on-touchstart="onTouchStart_"
hidden$="[[isHidden_(index, columnCount_)]]"
on-click="onTileClick_" on-keydown="onTileKeyDown_"
query-tile$="[[isHidden_(index, columnCount_)]]">
query-tile$="[[item.isQueryTile]]">
<cr-icon-button id="actionMenuButton" class="icon-more-vert"
title="$i18n{moreActions}" on-click="onTileActionButtonClick_"
tabindex="0" hidden$="[[!customLinksEnabled_]]"></cr-icon-button>
......@@ -210,12 +208,10 @@
title="$i18n{linkRemove}" on-click="onTileRemoveButtonClick_"
tabindex="0" hidden$="[[customLinksEnabled_]]"></cr-icon-button>
<div class="tile-icon">
<!-- TOOD(crbug.com/1138578): replace the hidden attr binding to
something that checks whether the tile is a repeatable query tile. -->
<img src$="[[getFaviconUrl_(item.url)]]" draggable="false"
hidden$="[[isHidden_(index, columnCount_)]]"></img>
hidden$="[[item.isQueryTile]]"></img>
<div class="query-tile-icon" draggable="false"
hidden$="[[!isHidden_(index, columnCount_)]]"></div>
hidden$="[[!item.isQueryTile]]"></div>
</div>
<div class$="tile-title [[getTileTitleDirectionClass_(item)]]">
<span>[[item.title]]</span>
......
......@@ -25,6 +25,7 @@ struct MostVisitedTile {
string title;
mojo_base.mojom.TextDirection title_direction;
url.mojom.Url url;
bool is_query_tile;
// ======= METRICS =======
// Identifier of most visited entry source (e.g. top sites).
......
......@@ -1192,6 +1192,8 @@ void NewTabPageHandler::MostVisitedInfoChanged(
value->source = static_cast<int32_t>(tile.source);
value->title_source = static_cast<int32_t>(tile.title_source);
value->data_generation_time = tile.data_generation_time;
value->is_query_tile =
tile.source == ntp_tiles::TileSource::REPEATABLE_QUERIES_SERVICE;
list.push_back(std::move(value));
}
result->custom_links_enabled = !info.use_most_visited;
......
......@@ -92,10 +92,11 @@ bool ChromeNTPTilesInternalsMessageHandlerClient::DoesSourceExist(
return false;
#endif
case ntp_tiles::TileSource::CUSTOM_LINKS:
#if !defined(OS_ANDROID)
return true;
#else
case ntp_tiles::TileSource::REPEATABLE_QUERIES_SERVICE:
#if defined(OS_ANDROID)
return false;
#else
return true;
#endif
}
NOTREACHED();
......
......@@ -60,6 +60,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: `https://${char}/`},
source: i,
titleSource: i,
isQueryTile: false,
dataGenerationTime: {internalValue: 0},
};
});
......@@ -732,6 +733,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://url/'},
source: 0,
titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0},
}],
visible: true,
......@@ -753,6 +755,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://url/'},
source: 0,
titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0},
}],
visible: true,
......@@ -824,6 +827,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://a/'},
source: 0,
titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0},
});
assertDeepEquals(tiles[1], {
......@@ -832,6 +836,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://b/'},
source: 1,
titleSource: 1,
isQueryTile: false,
dataGenerationTime: {internalValue: 0},
});
});
......@@ -856,6 +861,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://a/'},
source: 0,
titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0},
});
});
......
......@@ -28,6 +28,7 @@ const char kHistogramWhitelistName[] = "whitelist";
const char kHistogramHomepageName[] = "homepage";
const char kHistogramCustomLinksName[] = "custom_links";
const char kHistogramExploreName[] = "explore";
const char kHistogramRepeatableQueryName[] = "repeatable_query";
// Suffixes for the various icon types.
const char kTileTypeSuffixIconColor[] = "IconsColor";
......@@ -58,6 +59,8 @@ std::string GetSourceHistogramName(TileSource source) {
return kHistogramCustomLinksName;
case TileSource::EXPLORE:
return kHistogramExploreName;
case TileSource::REPEATABLE_QUERIES_SERVICE:
return kHistogramRepeatableQueryName;
}
NOTREACHED();
return std::string();
......
......@@ -179,6 +179,8 @@ bool MostVisitedSites::DoesSourceExist(TileSource source) const {
return custom_links_ != nullptr;
case TileSource::EXPLORE:
return explore_sites_client_ != nullptr;
case TileSource::REPEATABLE_QUERIES_SERVICE:
return false;
}
NOTREACHED();
return false;
......
......@@ -28,8 +28,10 @@ enum class TileSource {
HOMEPAGE,
// Tile comes from explore sites list.
EXPLORE,
// Tile comes from the repeatable queries service, based on search history.
REPEATABLE_QUERIES_SERVICE,
LAST = EXPLORE
LAST = REPEATABLE_QUERIES_SERVICE
};
} // namespace ntp_tiles
......
......@@ -76,6 +76,7 @@ bool IOSNTPTilesInternalsMessageHandlerBridge::DoesSourceExist(
case ntp_tiles::TileSource::CUSTOM_LINKS:
case ntp_tiles::TileSource::WHITELIST:
case ntp_tiles::TileSource::EXPLORE:
case ntp_tiles::TileSource::REPEATABLE_QUERIES_SERVICE:
return false;
}
NOTREACHED();
......
......@@ -11182,6 +11182,7 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<suffix name="popular_baked_in" label="Baked-in, popular suggestions."/>
<suffix name="popular_fetched"
label="Non-personalized, popular suggestions (fetched from the server)."/>
<suffix name="repeatable_query" label="Repeatable Query suggestion."/>
<suffix name="search_page" label="Google Search page">
<obsolete>
Used for experiment but was never launched, as of 2019-07.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment