Commit 0d779c08 authored by Kyle Milka's avatar Kyle Milka Committed by Commit Bot

[NTP] Change custom bg attribution to an <a href...> tag

This gives the attribution link the proper context menu.

Screencast: http://go/scrcast/NTkxNDI0NDY2MDg1NDc4NHwyOGZhZTViMy1jMQ

Bug: 963399
Change-Id: Iadccc1a9457b3c7ac6f1093197c937190815821b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1616998Reviewed-by: default avatarGayane Petrosyan <gayane@chromium.org>
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661054}
parent 397fe008
......@@ -241,10 +241,10 @@ customBackgrounds.setMenuVisibility = function() {
customBackgrounds.setAttribution = function(
attributionLine1, attributionLine2, attributionActionUrl) {
const attributionBox = $(customBackgrounds.IDS.ATTRIBUTIONS);
const attr1 = document.createElement('div');
attr1.setAttribute('id', customBackgrounds.IDS.ATTR1);
const attr2 = document.createElement('div');
attr2.setAttribute('id', customBackgrounds.IDS.ATTR2);
const attr1 = document.createElement('span');
attr1.id = customBackgrounds.IDS.ATTR1;
const attr2 = document.createElement('span');
attr2.id = customBackgrounds.IDS.ATTR2;
if (attributionLine1 !== '') {
// Shouldn't be changed from textContent for security assurances.
......@@ -272,8 +272,8 @@ customBackgrounds.setAttribution = function(
attr.insertBefore(linkIcon, attr.firstChild);
attributionBox.classList.add(customBackgrounds.CLASSES.ATTR_LINK);
attributionBox.href = attributionActionUrl;
attributionBox.onclick = function() {
window.open(attributionActionUrl, '_blank');
ntpApiHandle.logEvent(
BACKGROUND_CUSTOMIZATION_LOG_TYPE.NTP_CUSTOMIZE_ATTRIBUTION_CLICKED);
};
......@@ -283,6 +283,9 @@ customBackgrounds.setAttribution = function(
customBackgrounds.clearAttribution = function() {
const attributions = $(customBackgrounds.IDS.ATTRIBUTIONS);
attributions.removeAttribute('href');
attributions.className = '';
attributions.style.cursor = 'none';
while (attributions.firstChild) {
attributions.removeChild(attributions.firstChild);
}
......
......@@ -109,7 +109,7 @@
<span id="edit-bg-text"></span>
</div>
<div id="custom-bg-attr"></div>
<a id="custom-bg-attr"></a>
</div>
<dialog div id="edit-bg-dialog">
......
......@@ -95,7 +95,7 @@
<span id="edit-bg-text"></span>
</div>
<div id="custom-bg-attr"></div>
<a id="custom-bg-attr"></a>
</div>
<dialog div id="edit-bg-dialog" class="customize-dialog">
......
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