Commit 5b5dcbd5 authored by Kristi Park's avatar Kristi Park Committed by Commit Bot

[NTP Cleanup] Rename tid to rid

The tile's restricted ID is referenced in multiple places as "rid" and
"tid". Standardize naming by changing all references of "tid" to "rid".

Change-Id: I285d7b21abb404adb0c97cdecad38c38ae3a39d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1642235Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666472}
parent a9191e06
...@@ -197,7 +197,7 @@ function closeDialog() { ...@@ -197,7 +197,7 @@ function closeDialog() {
*/ */
function focusBackOnCancel(event) { function focusBackOnCancel(event) {
if (event.keyCode === KEYCODES.ENTER || event.keyCode === KEYCODES.SPACE) { if (event.keyCode === KEYCODES.ENTER || event.keyCode === KEYCODES.SPACE) {
const message = {cmd: 'focusMenu', tid: prepopulatedLink.rid}; const message = {cmd: 'focusMenu', rid: prepopulatedLink.rid};
window.parent.postMessage(message, DOMAIN_ORIGIN); window.parent.postMessage(message, DOMAIN_ORIGIN);
event.preventDefault(); event.preventDefault();
closeDialog(); closeDialog();
...@@ -222,10 +222,10 @@ function handlePostMessage(event) { ...@@ -222,10 +222,10 @@ function handlePostMessage(event) {
const cmd = event.data.cmd; const cmd = event.data.cmd;
const args = event.data; const args = event.data;
if (cmd === 'linkData') { if (cmd === 'linkData') {
if (args.tid) { // We are editing a link, prepopulate the link data. if (args.rid) { // We are editing a link, prepopulate the link data.
document.title = editLinkTitle; document.title = editLinkTitle;
$(IDS.DIALOG_TITLE).textContent = editLinkTitle; $(IDS.DIALOG_TITLE).textContent = editLinkTitle;
prepopulateFields(args.tid); prepopulateFields(args.rid);
} else { // We are adding a link, disable the delete button. } else { // We are adding a link, disable the delete button.
document.title = addLinkTitle; document.title = addLinkTitle;
$(IDS.DIALOG_TITLE).textContent = addLinkTitle; $(IDS.DIALOG_TITLE).textContent = addLinkTitle;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* InstantMostVisitedItem * InstantMostVisitedItem
* @typedef {{dataGenerationTime: Date, * @typedef {{dataGenerationTime: Date,
* isAddButton: boolean, * isAddButton: boolean,
* tid: number, * rid: number,
* tileSource: number, * tileSource: number,
* tileTitleSource: number, * tileTitleSource: number,
* title: ?, * title: ?,
...@@ -170,7 +170,7 @@ window.chrome.embeddedSearch.newTabPage.blacklistSearchSuggestion; ...@@ -170,7 +170,7 @@ window.chrome.embeddedSearch.newTabPage.blacklistSearchSuggestion;
window.chrome.embeddedSearch.newTabPage.blacklistSearchSuggestionWithHash; window.chrome.embeddedSearch.newTabPage.blacklistSearchSuggestionWithHash;
/** /**
* @param {number} tid * @param {number} rid
*/ */
window.chrome.embeddedSearch.newTabPage.deleteMostVisitedItem; window.chrome.embeddedSearch.newTabPage.deleteMostVisitedItem;
...@@ -180,7 +180,7 @@ window.chrome.embeddedSearch.newTabPage.deleteMostVisitedItem; ...@@ -180,7 +180,7 @@ window.chrome.embeddedSearch.newTabPage.deleteMostVisitedItem;
window.chrome.embeddedSearch.newTabPage.fixupAndValidateUrl; window.chrome.embeddedSearch.newTabPage.fixupAndValidateUrl;
/** /**
* @param {number} tid * @param {number} rid
*/ */
window.chrome.embeddedSearch.newTabPage.getMostVisitedItemData; window.chrome.embeddedSearch.newTabPage.getMostVisitedItemData;
......
...@@ -1029,14 +1029,14 @@ function handlePostMessage(event) { ...@@ -1029,14 +1029,14 @@ function handlePostMessage(event) {
showNotification( showNotification(
configData.translatedStrings.thumbnailRemovedNotification); configData.translatedStrings.thumbnailRemovedNotification);
} }
lastBlacklistedTile = args.tid; lastBlacklistedTile = args.rid;
ntpApiHandle.deleteMostVisitedItem(args.tid); ntpApiHandle.deleteMostVisitedItem(args.rid);
} else if (cmd === 'resizeDoodle') { } else if (cmd === 'resizeDoodle') {
doodles.resizeDoodleHandler(args); doodles.resizeDoodleHandler(args);
} else if (cmd === 'startEditLink') { } else if (cmd === 'startEditLink') {
$(IDS.CUSTOM_LINKS_EDIT_IFRAME) $(IDS.CUSTOM_LINKS_EDIT_IFRAME)
.contentWindow.postMessage({cmd: 'linkData', tid: args.tid}, '*'); .contentWindow.postMessage({cmd: 'linkData', rid: args.rid}, '*');
// Small delay to allow the dialog to finish setting up before displaying. // Small delay to allow the dialog to finish setting up before displaying.
window.setTimeout(function() { window.setTimeout(function() {
$(IDS.CUSTOM_LINKS_EDIT_IFRAME_DIALOG).showModal(); $(IDS.CUSTOM_LINKS_EDIT_IFRAME_DIALOG).showModal();
...@@ -1047,7 +1047,7 @@ function handlePostMessage(event) { ...@@ -1047,7 +1047,7 @@ function handlePostMessage(event) {
// Focus the edited tile's menu or the add shortcut tile after closing the // Focus the edited tile's menu or the add shortcut tile after closing the
// custom link edit dialog without saving. // custom link edit dialog without saving.
$(IDS.TILES_IFRAME) $(IDS.TILES_IFRAME)
.contentWindow.postMessage({cmd: 'focusMenu', tid: args.tid}, '*'); .contentWindow.postMessage({cmd: 'focusMenu', rid: args.rid}, '*');
} }
} }
......
...@@ -903,8 +903,8 @@ function updateTheme(info) { ...@@ -903,8 +903,8 @@ function updateTheme(info) {
* @param {!Object} info Data received in the message. * @param {!Object} info Data received in the message.
*/ */
function focusTileMenu(info) { function focusTileMenu(info) {
const tile = document.querySelector(`a.md-tile[data-tid="${info.tid}"]`); const tile = document.querySelector(`a.md-tile[data-rid="${info.rid}"]`);
if (info.tid === -1 /* Add shortcut tile */) { if (info.rid === -1 /* Add shortcut tile */) {
tile.focus(); tile.focus();
} else { } else {
tile.parentNode.childNodes[1].focus(); tile.parentNode.childNodes[1].focus();
...@@ -937,7 +937,7 @@ function swapInNewTiles() { ...@@ -937,7 +937,7 @@ function swapInNewTiles() {
// number of tiles. // number of tiles.
if (isCustomLinksEnabled && cur.childNodes.length < maxNumTiles) { if (isCustomLinksEnabled && cur.childNodes.length < maxNumTiles) {
const data = { const data = {
'tid': -1, 'rid': -1,
'title': queryArgs['addLink'], 'title': queryArgs['addLink'],
'url': '', 'url': '',
'isAddButton': true, 'isAddButton': true,
...@@ -1033,10 +1033,9 @@ function addTile(args) { ...@@ -1033,10 +1033,9 @@ function addTile(args) {
return; return;
} }
data.tid = data.rid;
if (!data.faviconUrl) { if (!data.faviconUrl) {
data.faviconUrl = 'chrome-search://favicon/size/16@' + data.faviconUrl = 'chrome-search://favicon/size/16@' +
window.devicePixelRatio + 'x/' + data.renderViewId + '/' + data.tid; window.devicePixelRatio + 'x/' + data.renderViewId + '/' + data.rid;
} }
tiles.appendChild(renderTile(data)); tiles.appendChild(renderTile(data));
} else { } else {
...@@ -1052,10 +1051,10 @@ function addTile(args) { ...@@ -1052,10 +1051,10 @@ function addTile(args) {
* @param {Element} tile DOM node of the tile we want to remove. * @param {Element} tile DOM node of the tile we want to remove.
*/ */
function blacklistTile(tile) { function blacklistTile(tile) {
const tid = Number(tile.firstChild.getAttribute('data-tid')); const rid = Number(tile.firstChild.getAttribute('data-rid'));
if (isCustomLinksEnabled) { if (isCustomLinksEnabled) {
chrome.embeddedSearch.newTabPage.deleteMostVisitedItem(tid); chrome.embeddedSearch.newTabPage.deleteMostVisitedItem(rid);
} else { } else {
tile.classList.add('blacklisted'); tile.classList.add('blacklisted');
tile.addEventListener('transitionend', function(ev) { tile.addEventListener('transitionend', function(ev) {
...@@ -1063,7 +1062,7 @@ function blacklistTile(tile) { ...@@ -1063,7 +1062,7 @@ function blacklistTile(tile) {
return; return;
} }
window.parent.postMessage( window.parent.postMessage(
{cmd: 'tileBlacklisted', tid: Number(tid)}, DOMAIN_ORIGIN); {cmd: 'tileBlacklisted', rid: Number(rid)}, DOMAIN_ORIGIN);
}); });
} }
} }
...@@ -1072,10 +1071,10 @@ function blacklistTile(tile) { ...@@ -1072,10 +1071,10 @@ function blacklistTile(tile) {
/** /**
* Starts edit custom link flow. Tells host page to show the edit custom link * Starts edit custom link flow. Tells host page to show the edit custom link
* dialog and pre-populate it with data obtained using the link's id. * dialog and pre-populate it with data obtained using the link's id.
* @param {?number} tid Restricted id of the tile we want to edit. * @param {?number} rid Restricted id of the tile we want to edit.
*/ */
function editCustomLink(tid) { function editCustomLink(rid) {
window.parent.postMessage({cmd: 'startEditLink', tid: tid}, DOMAIN_ORIGIN); window.parent.postMessage({cmd: 'startEditLink', rid: rid}, DOMAIN_ORIGIN);
} }
...@@ -1117,7 +1116,7 @@ function stopReorder(tile) { ...@@ -1117,7 +1116,7 @@ function stopReorder(tile) {
allTiles[i].setAttribute('data-pos', i); allTiles[i].setAttribute('data-pos', i);
} }
chrome.embeddedSearch.newTabPage.reorderCustomLink( chrome.embeddedSearch.newTabPage.reorderCustomLink(
Number(tile.firstChild.getAttribute('data-tid')), Number(tile.firstChild.getAttribute('data-rid')),
Number(tile.firstChild.getAttribute('data-pos'))); Number(tile.firstChild.getAttribute('data-pos')));
} }
...@@ -1225,7 +1224,7 @@ function renderMaterialDesignTile(data) { ...@@ -1225,7 +1224,7 @@ function renderMaterialDesignTile(data) {
const mdTile = document.createElement('a'); const mdTile = document.createElement('a');
mdTile.className = CLASSES.MD_TILE; mdTile.className = CLASSES.MD_TILE;
mdTile.tabIndex = 0; mdTile.tabIndex = 0;
mdTile.setAttribute('data-tid', data.tid); mdTile.setAttribute('data-rid', data.rid);
mdTile.setAttribute('data-pos', position); mdTile.setAttribute('data-pos', position);
if (utils.isSchemeAllowed(data.url)) { if (utils.isSchemeAllowed(data.url)) {
mdTile.href = data.url; mdTile.href = data.url;
...@@ -1355,7 +1354,7 @@ function renderMaterialDesignTile(data) { ...@@ -1355,7 +1354,7 @@ function renderMaterialDesignTile(data) {
'aria-label', 'aria-label',
(queryArgs['editLinkTooltip'] || '') + ' ' + data.title); (queryArgs['editLinkTooltip'] || '') + ' ' + data.title);
mdMenu.addEventListener('click', function(ev) { mdMenu.addEventListener('click', function(ev) {
editCustomLink(data.tid); editCustomLink(data.rid);
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
logEvent(LOG_TYPE.NTP_CUSTOMIZE_EDIT_SHORTCUT_CLICKED); logEvent(LOG_TYPE.NTP_CUSTOMIZE_EDIT_SHORTCUT_CLICKED);
...@@ -1383,7 +1382,7 @@ function renderMaterialDesignTile(data) { ...@@ -1383,7 +1382,7 @@ function renderMaterialDesignTile(data) {
if (isGridEnabled) { if (isGridEnabled) {
return currGrid.createGridTile( return currGrid.createGridTile(
mdTileContainer, data.tid, !!data.isAddButton); mdTileContainer, data.rid, !!data.isAddButton);
} else { } else {
// Enable reordering. // Enable reordering.
if (isCustomLinksEnabled && !data.isAddButton) { if (isCustomLinksEnabled && !data.isAddButton) {
......
...@@ -610,15 +610,15 @@ IN_PROC_BROWSER_TEST_F(LocalNTPTest, ReorderCustomLinks) { ...@@ -610,15 +610,15 @@ IN_PROC_BROWSER_TEST_F(LocalNTPTest, ReorderCustomLinks) {
&title)); &title));
// Move the tile to the front. // Move the tile to the front.
std::string tid; std::string rid;
ASSERT_TRUE(instant_test_utils::GetStringFromJS( ASSERT_TRUE(instant_test_utils::GetStringFromJS(
iframe, iframe,
"document.querySelectorAll('#mv-tiles " "document.querySelectorAll('#mv-tiles "
".md-tile')[1].getAttribute('data-tid')", ".md-tile')[1].getAttribute('data-rid')",
&tid)); &rid));
local_ntp_test_utils::ExecuteScriptOnNTPAndWaitUntilLoaded( local_ntp_test_utils::ExecuteScriptOnNTPAndWaitUntilLoaded(
iframe, "window.chrome.embeddedSearch.newTabPage.reorderCustomLink(" + iframe, "window.chrome.embeddedSearch.newTabPage.reorderCustomLink(" +
tid + ", 0)"); rid + ", 0)");
// Check that the first tile is the tile that was moved. // Check that the first tile is the tile that was moved.
std::string new_title; std::string new_title;
...@@ -632,11 +632,11 @@ IN_PROC_BROWSER_TEST_F(LocalNTPTest, ReorderCustomLinks) { ...@@ -632,11 +632,11 @@ IN_PROC_BROWSER_TEST_F(LocalNTPTest, ReorderCustomLinks) {
ASSERT_TRUE(instant_test_utils::GetStringFromJS( ASSERT_TRUE(instant_test_utils::GetStringFromJS(
iframe, iframe,
"document.querySelectorAll('#mv-tiles " "document.querySelectorAll('#mv-tiles "
".md-tile')[0].getAttribute('data-tid')", ".md-tile')[0].getAttribute('data-rid')",
&tid)); &rid));
local_ntp_test_utils::ExecuteScriptOnNTPAndWaitUntilLoaded( local_ntp_test_utils::ExecuteScriptOnNTPAndWaitUntilLoaded(
iframe, "window.chrome.embeddedSearch.newTabPage.reorderCustomLink(" + iframe, "window.chrome.embeddedSearch.newTabPage.reorderCustomLink(" +
tid + ", " + end_index + ")"); rid + ", " + end_index + ")");
// Check that the last tile is the tile that was moved. // Check that the last tile is the tile that was moved.
new_title = std::string(); new_title = std::string();
......
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