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 @@ ...@@ -195,14 +195,12 @@
style="--column-count: [[columnCount_]]; --row-count: [[rowCount_]];"> style="--column-count: [[columnCount_]]; --row-count: [[rowCount_]];">
<dom-repeat id="tiles" items="[[tiles_]]" on-dom-change="onTilesRendered_"> <dom-repeat id="tiles" items="[[tiles_]]" on-dom-change="onTilesRendered_">
<template> <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_)]]" <a class="tile" draggable$="[[booleanToString_(customLinksEnabled_)]]"
href$="[[item.url.url]]" title$="[[item.title]]" href$="[[item.url.url]]" title$="[[item.title]]"
on-dragstart="onDragStart_" on-touchstart="onTouchStart_" on-dragstart="onDragStart_" on-touchstart="onTouchStart_"
hidden$="[[isHidden_(index, columnCount_)]]" hidden$="[[isHidden_(index, columnCount_)]]"
on-click="onTileClick_" on-keydown="onTileKeyDown_" on-click="onTileClick_" on-keydown="onTileKeyDown_"
query-tile$="[[isHidden_(index, columnCount_)]]"> query-tile$="[[item.isQueryTile]]">
<cr-icon-button id="actionMenuButton" class="icon-more-vert" <cr-icon-button id="actionMenuButton" class="icon-more-vert"
title="$i18n{moreActions}" on-click="onTileActionButtonClick_" title="$i18n{moreActions}" on-click="onTileActionButtonClick_"
tabindex="0" hidden$="[[!customLinksEnabled_]]"></cr-icon-button> tabindex="0" hidden$="[[!customLinksEnabled_]]"></cr-icon-button>
...@@ -210,12 +208,10 @@ ...@@ -210,12 +208,10 @@
title="$i18n{linkRemove}" on-click="onTileRemoveButtonClick_" title="$i18n{linkRemove}" on-click="onTileRemoveButtonClick_"
tabindex="0" hidden$="[[customLinksEnabled_]]"></cr-icon-button> tabindex="0" hidden$="[[customLinksEnabled_]]"></cr-icon-button>
<div class="tile-icon"> <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" <img src$="[[getFaviconUrl_(item.url)]]" draggable="false"
hidden$="[[isHidden_(index, columnCount_)]]"></img> hidden$="[[item.isQueryTile]]"></img>
<div class="query-tile-icon" draggable="false" <div class="query-tile-icon" draggable="false"
hidden$="[[!isHidden_(index, columnCount_)]]"></div> hidden$="[[!item.isQueryTile]]"></div>
</div> </div>
<div class$="tile-title [[getTileTitleDirectionClass_(item)]]"> <div class$="tile-title [[getTileTitleDirectionClass_(item)]]">
<span>[[item.title]]</span> <span>[[item.title]]</span>
......
...@@ -25,6 +25,7 @@ struct MostVisitedTile { ...@@ -25,6 +25,7 @@ struct MostVisitedTile {
string title; string title;
mojo_base.mojom.TextDirection title_direction; mojo_base.mojom.TextDirection title_direction;
url.mojom.Url url; url.mojom.Url url;
bool is_query_tile;
// ======= METRICS ======= // ======= METRICS =======
// Identifier of most visited entry source (e.g. top sites). // Identifier of most visited entry source (e.g. top sites).
......
...@@ -1192,6 +1192,8 @@ void NewTabPageHandler::MostVisitedInfoChanged( ...@@ -1192,6 +1192,8 @@ void NewTabPageHandler::MostVisitedInfoChanged(
value->source = static_cast<int32_t>(tile.source); value->source = static_cast<int32_t>(tile.source);
value->title_source = static_cast<int32_t>(tile.title_source); value->title_source = static_cast<int32_t>(tile.title_source);
value->data_generation_time = tile.data_generation_time; 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)); list.push_back(std::move(value));
} }
result->custom_links_enabled = !info.use_most_visited; result->custom_links_enabled = !info.use_most_visited;
......
...@@ -92,10 +92,11 @@ bool ChromeNTPTilesInternalsMessageHandlerClient::DoesSourceExist( ...@@ -92,10 +92,11 @@ bool ChromeNTPTilesInternalsMessageHandlerClient::DoesSourceExist(
return false; return false;
#endif #endif
case ntp_tiles::TileSource::CUSTOM_LINKS: case ntp_tiles::TileSource::CUSTOM_LINKS:
#if !defined(OS_ANDROID) case ntp_tiles::TileSource::REPEATABLE_QUERIES_SERVICE:
return true; #if defined(OS_ANDROID)
#else
return false; return false;
#else
return true;
#endif #endif
} }
NOTREACHED(); NOTREACHED();
......
...@@ -60,6 +60,7 @@ suite('NewTabPageMostVisitedTest', () => { ...@@ -60,6 +60,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: `https://${char}/`}, url: {url: `https://${char}/`},
source: i, source: i,
titleSource: i, titleSource: i,
isQueryTile: false,
dataGenerationTime: {internalValue: 0}, dataGenerationTime: {internalValue: 0},
}; };
}); });
...@@ -732,6 +733,7 @@ suite('NewTabPageMostVisitedTest', () => { ...@@ -732,6 +733,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://url/'}, url: {url: 'https://url/'},
source: 0, source: 0,
titleSource: 0, titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0}, dataGenerationTime: {internalValue: 0},
}], }],
visible: true, visible: true,
...@@ -753,6 +755,7 @@ suite('NewTabPageMostVisitedTest', () => { ...@@ -753,6 +755,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://url/'}, url: {url: 'https://url/'},
source: 0, source: 0,
titleSource: 0, titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0}, dataGenerationTime: {internalValue: 0},
}], }],
visible: true, visible: true,
...@@ -824,6 +827,7 @@ suite('NewTabPageMostVisitedTest', () => { ...@@ -824,6 +827,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://a/'}, url: {url: 'https://a/'},
source: 0, source: 0,
titleSource: 0, titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0}, dataGenerationTime: {internalValue: 0},
}); });
assertDeepEquals(tiles[1], { assertDeepEquals(tiles[1], {
...@@ -832,6 +836,7 @@ suite('NewTabPageMostVisitedTest', () => { ...@@ -832,6 +836,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://b/'}, url: {url: 'https://b/'},
source: 1, source: 1,
titleSource: 1, titleSource: 1,
isQueryTile: false,
dataGenerationTime: {internalValue: 0}, dataGenerationTime: {internalValue: 0},
}); });
}); });
...@@ -856,6 +861,7 @@ suite('NewTabPageMostVisitedTest', () => { ...@@ -856,6 +861,7 @@ suite('NewTabPageMostVisitedTest', () => {
url: {url: 'https://a/'}, url: {url: 'https://a/'},
source: 0, source: 0,
titleSource: 0, titleSource: 0,
isQueryTile: false,
dataGenerationTime: {internalValue: 0}, dataGenerationTime: {internalValue: 0},
}); });
}); });
......
...@@ -28,6 +28,7 @@ const char kHistogramWhitelistName[] = "whitelist"; ...@@ -28,6 +28,7 @@ const char kHistogramWhitelistName[] = "whitelist";
const char kHistogramHomepageName[] = "homepage"; const char kHistogramHomepageName[] = "homepage";
const char kHistogramCustomLinksName[] = "custom_links"; const char kHistogramCustomLinksName[] = "custom_links";
const char kHistogramExploreName[] = "explore"; const char kHistogramExploreName[] = "explore";
const char kHistogramRepeatableQueryName[] = "repeatable_query";
// Suffixes for the various icon types. // Suffixes for the various icon types.
const char kTileTypeSuffixIconColor[] = "IconsColor"; const char kTileTypeSuffixIconColor[] = "IconsColor";
...@@ -58,6 +59,8 @@ std::string GetSourceHistogramName(TileSource source) { ...@@ -58,6 +59,8 @@ std::string GetSourceHistogramName(TileSource source) {
return kHistogramCustomLinksName; return kHistogramCustomLinksName;
case TileSource::EXPLORE: case TileSource::EXPLORE:
return kHistogramExploreName; return kHistogramExploreName;
case TileSource::REPEATABLE_QUERIES_SERVICE:
return kHistogramRepeatableQueryName;
} }
NOTREACHED(); NOTREACHED();
return std::string(); return std::string();
......
...@@ -179,6 +179,8 @@ bool MostVisitedSites::DoesSourceExist(TileSource source) const { ...@@ -179,6 +179,8 @@ bool MostVisitedSites::DoesSourceExist(TileSource source) const {
return custom_links_ != nullptr; return custom_links_ != nullptr;
case TileSource::EXPLORE: case TileSource::EXPLORE:
return explore_sites_client_ != nullptr; return explore_sites_client_ != nullptr;
case TileSource::REPEATABLE_QUERIES_SERVICE:
return false;
} }
NOTREACHED(); NOTREACHED();
return false; return false;
......
...@@ -28,8 +28,10 @@ enum class TileSource { ...@@ -28,8 +28,10 @@ enum class TileSource {
HOMEPAGE, HOMEPAGE,
// Tile comes from explore sites list. // Tile comes from explore sites list.
EXPLORE, EXPLORE,
// Tile comes from the repeatable queries service, based on search history.
REPEATABLE_QUERIES_SERVICE,
LAST = EXPLORE LAST = REPEATABLE_QUERIES_SERVICE
}; };
} // namespace ntp_tiles } // namespace ntp_tiles
......
...@@ -76,6 +76,7 @@ bool IOSNTPTilesInternalsMessageHandlerBridge::DoesSourceExist( ...@@ -76,6 +76,7 @@ bool IOSNTPTilesInternalsMessageHandlerBridge::DoesSourceExist(
case ntp_tiles::TileSource::CUSTOM_LINKS: case ntp_tiles::TileSource::CUSTOM_LINKS:
case ntp_tiles::TileSource::WHITELIST: case ntp_tiles::TileSource::WHITELIST:
case ntp_tiles::TileSource::EXPLORE: case ntp_tiles::TileSource::EXPLORE:
case ntp_tiles::TileSource::REPEATABLE_QUERIES_SERVICE:
return false; return false;
} }
NOTREACHED(); NOTREACHED();
......
...@@ -11182,6 +11182,7 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -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_baked_in" label="Baked-in, popular suggestions."/>
<suffix name="popular_fetched" <suffix name="popular_fetched"
label="Non-personalized, popular suggestions (fetched from the server)."/> 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"> <suffix name="search_page" label="Google Search page">
<obsolete> <obsolete>
Used for experiment but was never launched, as of 2019-07. 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