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() { ...@@ -241,10 +241,10 @@ customBackgrounds.setMenuVisibility = function() {
customBackgrounds.setAttribution = function( customBackgrounds.setAttribution = function(
attributionLine1, attributionLine2, attributionActionUrl) { attributionLine1, attributionLine2, attributionActionUrl) {
const attributionBox = $(customBackgrounds.IDS.ATTRIBUTIONS); const attributionBox = $(customBackgrounds.IDS.ATTRIBUTIONS);
const attr1 = document.createElement('div'); const attr1 = document.createElement('span');
attr1.setAttribute('id', customBackgrounds.IDS.ATTR1); attr1.id = customBackgrounds.IDS.ATTR1;
const attr2 = document.createElement('div'); const attr2 = document.createElement('span');
attr2.setAttribute('id', customBackgrounds.IDS.ATTR2); attr2.id = customBackgrounds.IDS.ATTR2;
if (attributionLine1 !== '') { if (attributionLine1 !== '') {
// Shouldn't be changed from textContent for security assurances. // Shouldn't be changed from textContent for security assurances.
...@@ -272,8 +272,8 @@ customBackgrounds.setAttribution = function( ...@@ -272,8 +272,8 @@ customBackgrounds.setAttribution = function(
attr.insertBefore(linkIcon, attr.firstChild); attr.insertBefore(linkIcon, attr.firstChild);
attributionBox.classList.add(customBackgrounds.CLASSES.ATTR_LINK); attributionBox.classList.add(customBackgrounds.CLASSES.ATTR_LINK);
attributionBox.href = attributionActionUrl;
attributionBox.onclick = function() { attributionBox.onclick = function() {
window.open(attributionActionUrl, '_blank');
ntpApiHandle.logEvent( ntpApiHandle.logEvent(
BACKGROUND_CUSTOMIZATION_LOG_TYPE.NTP_CUSTOMIZE_ATTRIBUTION_CLICKED); BACKGROUND_CUSTOMIZATION_LOG_TYPE.NTP_CUSTOMIZE_ATTRIBUTION_CLICKED);
}; };
...@@ -283,6 +283,9 @@ customBackgrounds.setAttribution = function( ...@@ -283,6 +283,9 @@ customBackgrounds.setAttribution = function(
customBackgrounds.clearAttribution = function() { customBackgrounds.clearAttribution = function() {
const attributions = $(customBackgrounds.IDS.ATTRIBUTIONS); const attributions = $(customBackgrounds.IDS.ATTRIBUTIONS);
attributions.removeAttribute('href');
attributions.className = '';
attributions.style.cursor = 'none';
while (attributions.firstChild) { while (attributions.firstChild) {
attributions.removeChild(attributions.firstChild); attributions.removeChild(attributions.firstChild);
} }
......
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
<span id="edit-bg-text"></span> <span id="edit-bg-text"></span>
</div> </div>
<div id="custom-bg-attr"></div> <a id="custom-bg-attr"></a>
</div> </div>
<dialog div id="edit-bg-dialog"> <dialog div id="edit-bg-dialog">
......
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<span id="edit-bg-text"></span> <span id="edit-bg-text"></span>
</div> </div>
<div id="custom-bg-attr"></div> <a id="custom-bg-attr"></a>
</div> </div>
<dialog div id="edit-bg-dialog" class="customize-dialog"> <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