summaryrefslogtreecommitdiff
path: root/chromium/components/neterror
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 15:05:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:33:47 +0000
commite684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch)
treed55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/components/neterror
parent2b94bfe47ccb6c08047959d1c26e392919550e86 (diff)
downloadqtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/components/neterror')
-rw-r--r--chromium/components/neterror/resources/neterror.css85
-rw-r--r--chromium/components/neterror/resources/neterror.html29
-rw-r--r--chromium/components/neterror/resources/neterror.js72
-rw-r--r--chromium/components/neterror/resources/offline.js27
4 files changed, 176 insertions, 37 deletions
diff --git a/chromium/components/neterror/resources/neterror.css b/chromium/components/neterror/resources/neterror.css
index b0cfddabad2..dd8798dcdf9 100644
--- a/chromium/components/neterror/resources/neterror.css
+++ b/chromium/components/neterror/resources/neterror.css
@@ -343,14 +343,46 @@ a {
opacity: 0;
}
-.offline-content-list-title {
- color: rgb(95, 99, 104);
+#offline-content-list-visibility-card {
+ border: 1px solid white;
+ border-radius: 8px;
+ display: flex;
font-size: .8em;
+ justify-content: space-between;
line-height: 1;
- margin-bottom: .8em;
}
-#offline-content-suggestions {
+#offline-content-list.list-hidden #offline-content-list-visibility-card {
+ border-color: rgb(218, 220, 224);
+}
+
+#offline-content-list-visibility-card > div {
+ padding: 1em;
+}
+
+#offline-content-list-title {
+ color: var(--google-gray-700);
+}
+
+#offline-content-list-show-text, #offline-content-list-hide-text {
+ color: rgb(66, 133, 244);
+}
+
+/* Hides "hide" text div, the offline content list itself and the action button
+ * to show the downloads home when the offline content list is collapsed/hidden.
+ */
+#offline-content-list.list-hidden #offline-content-suggestions,
+#offline-content-list.list-hidden #offline-content-list-action,
+#offline-content-list.list-hidden #offline-content-list-hide-text {
+ display: none;
+}
+
+/* Hides the "show" div when the offline content list is expanded/shown. */
+#offline-content-list:not(.list-hidden) #offline-content-list-show-text {
+ display: none;
+}
+
+#offline-content-list {
margin-inline-start: -5%;
width: 110%;
}
@@ -358,21 +390,15 @@ a {
/* The selectors below adjust the "overflow" of the suggestion cards contents
* based on the same screen size based strategy used for the main frame, which
* is applied by the `interstitial-wrapper` class. */
-@media (max-width: 700px) {
- #offline-content-suggestions {
- margin-inline-start: -5%;
- width: 110%;
- }
-}
@media (max-width: 420px) {
- #offline-content-suggestions {
+ #offline-content-list {
margin-inline-start: -2.5%;
width: 105%;
}
}
@media (max-width: 420px) and (orientation: portrait),
(max-height: 560px) {
- #offline-content-suggestions {
+ #offline-content-list {
margin-inline-start: -12px;
width: calc(100% + 24px);
}
@@ -390,14 +416,14 @@ a {
#offline-content-list:not(.is-rtl) .suggestion-with-image
.offline-content-suggestion-visual > img {
- border-bottom-right-radius: 8px;
- border-top-right-radius: 8px;
+ border-bottom-right-radius: 7px;
+ border-top-right-radius: 7px;
}
#offline-content-list.is-rtl .suggestion-with-image
.offline-content-suggestion-visual > img {
- border-bottom-left-radius: 8px;
- border-top-left-radius: 8px;
+ border-bottom-left-radius: 7px;
+ border-top-left-radius: 7px;
}
.suggestion-with-icon .offline-content-suggestion-visual {
@@ -460,10 +486,8 @@ a {
div.offline-content-suggestion {
align-items: stretch;
- border-color: rgb(218, 220, 224);
+ border: 1px solid rgb(218, 220, 224);
border-radius: 8px;
- border-style: solid;
- border-width: 1px;
display: flex;
justify-content: space-between;
margin-bottom: .8em;
@@ -540,15 +564,13 @@ div.offline-content-suggestion {
width: 1.4em;
}
-.offline-content-list-action {
+#offline-content-list-action {
text-align: center;
}
#offline-content-summary {
- border-color: rgb(241, 243, 244);
+ border: 1px solid rgb(241, 243, 244);
border-radius: 12px;
- border-style: solid;
- border-width: 1px;
padding: 12px;
text-align: center;
}
@@ -584,6 +606,23 @@ div.offline-content-suggestion {
padding-top: 12px;
}
+#cancel-save-page-button {
+ border: 1px solid var(--google-gray-300);
+ border-radius: 5px;
+ color: var(--google-gray-700);
+ padding: 16px;
+ text-align: center;
+}
+
+#save-page-for-later-button {
+ display: flex;
+ justify-content: center;
+}
+
+.hidden#save-page-for-later-button {
+ display: none;
+}
+
/* Don't allow overflow when in a subframe. */
html[subframe] body {
overflow: hidden;
diff --git a/chromium/components/neterror/resources/neterror.html b/chromium/components/neterror/resources/neterror.html
index 25c98f9b51f..c989aac3768 100644
--- a/chromium/components/neterror/resources/neterror.html
+++ b/chromium/components/neterror/resources/neterror.html
@@ -63,10 +63,22 @@
</div>
</div>
<div id="offline-content-list" hidden>
- <div class="offline-content-list-title" jsselect="offlineContentList"
- jscontent="title"></div>
+ <div id="offline-content-list-visibility-card"
+ onclick="toggleOfflineContentListVisibility(true)">
+ <div id="offline-content-list-title"
+ jsselect="offlineContentList" jscontent="title">
+ </div>
+ <div>
+ <div id="offline-content-list-show-text"
+ jsselect="offlineContentList" jscontent="showText">
+ </div>
+ <div id="offline-content-list-hide-text"
+ jsselect="offlineContentList" jscontent="hideText">
+ </div>
+ </div>
+ </div>
<div id="offline-content-suggestions"></div>
- <div class="offline-content-list-action">
+ <div id="offline-content-list-action">
<a class="link-button" onclick="launchDownloadsPage()"
jsselect="offlineContentList" jscontent="actionText">
</a>
@@ -117,6 +129,17 @@
jsselect="downloadButton"
jscontent="msg" jsvalues=".disabledText:disabledMsg">
</button>
+ <div id="save-page-for-later-button" class="hidden">
+ <a class="link-button" onclick="savePageLaterClick()"
+ jsselect="savePageLater"
+ jscontent="savePageMsg">
+ </a>
+ </div>
+ <div id="cancel-save-page-button" class="hidden"
+ onclick="cancelSavePageClick()"
+ jsselect="savePageLater"
+ jsvalues=".innerHTML:cancelMsg">
+ </div>
</div>
<button id="details-button" class="secondary-button text-button small-link"
onclick="detailsButtonClick(); toggleHelpBox()" jscontent="details"
diff --git a/chromium/components/neterror/resources/neterror.js b/chromium/components/neterror/resources/neterror.js
index bbbe8e77cb3..f265c596a6a 100644
--- a/chromium/components/neterror/resources/neterror.js
+++ b/chromium/components/neterror/resources/neterror.js
@@ -2,6 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Decodes a UTF16 string that is encoded as base64.
+function decodeUTF16Base64ToString(encoded_text) {
+ var data = atob(encoded_text);
+ var result = '';
+ for (var i = 0; i < data.length; i += 2) {
+ result +=
+ String.fromCharCode(data.charCodeAt(i) * 256 + data.charCodeAt(i + 1));
+ }
+ return result;
+}
+
function toggleHelpBox() {
var helpBoxOuter = document.getElementById('details');
helpBoxOuter.classList.toggle(HIDDEN_CLASS);
@@ -159,6 +170,26 @@ var primaryControlOnLeft = true;
primaryControlOnLeft = false;
// </if>
+function setAutoFetchState(scheduled, can_schedule) {
+ document.getElementById('cancel-save-page-button')
+ .classList.toggle(HIDDEN_CLASS, !scheduled);
+ document.getElementById('save-page-for-later-button')
+ .classList.toggle(HIDDEN_CLASS, scheduled || !can_schedule);
+}
+
+function savePageLaterClick() {
+ errorPageController.savePageForLater();
+ // savePageForLater will eventually trigger a call to setAutoFetchState() when
+ // it completes.
+}
+
+function cancelSavePageClick() {
+ errorPageController.cancelSavePage();
+ // setAutoFetchState is not called in response to cancelSavePage(), so do it
+ // now.
+ setAutoFetchState(false, true);
+}
+
function toggleErrorInformationPopup() {
document.getElementById('error-information-popup-container')
.classList.toggle(HIDDEN_CLASS);
@@ -203,6 +234,8 @@ function getIconForSuggestedItem(item) {
function getSuggestedContentDiv(item, index) {
// Note: See AvailableContentToValue in available_offline_content_helper.cc
// for the data contained in an |item|.
+ // TODO(carlosk): Present |snippet_base64| when that content becomes
+ // available.
var visual = '';
var extraContainerClasses = [];
// html_inline.py will try to replace src attributes with data URIs using a
@@ -217,7 +250,7 @@ function getSuggestedContentDiv(item, index) {
visual = `<div><img class="${iconClass}"></div>`;
}
- if (!item.attribution)
+ if (!item.attribution_base64)
extraContainerClasses.push('no-attribution');
return `
@@ -246,10 +279,10 @@ function getSuggestedContentDiv(item, index) {
// Populates a list of suggested offline content.
// Note: For security reasons all content downloaded from the web is considered
-// unsafe and must be securely handled to be presented on the dino page. The
-// image content is already safely re-encoded after being downloaded but the
-// textual content, like title and attribution, must be properly handled here.
-function offlineContentAvailable(suggestions) {
+// unsafe and must be securely handled to be presented on the dino page. Images
+// have already been safely re-encoded but textual content -- like title and
+// attribution -- must be properly handled here.
+function offlineContentAvailable(isShown, suggestions) {
if (!suggestions || !loadTimeData.valueExists('offlineContentList'))
return;
@@ -264,17 +297,34 @@ function offlineContentAvailable(suggestions) {
// plain text.
for (var index = 0; index < suggestions.length; index++) {
document.getElementById(`offline-content-suggestion-title-${index}`)
- .textContent = suggestions[index].title;
+ .textContent =
+ decodeUTF16Base64ToString(suggestions[index].title_base64);
document.getElementById(`offline-content-suggestion-attribution-${index}`)
- .textContent = suggestions[index].attribution;
+ .textContent =
+ decodeUTF16Base64ToString(suggestions[index].attribution_base64);
}
var contentListElement = document.getElementById('offline-content-list');
if (document.dir == 'rtl')
contentListElement.classList.add('is-rtl');
+ // The list is configured as shown by default. Hide if needed.
+ if (!isShown)
+ toggleOfflineContentListVisibility(false);
contentListElement.hidden = false;
}
+function toggleOfflineContentListVisibility(updatePref) {
+ if (!loadTimeData.valueExists('offlineContentList'))
+ return;
+
+ var contentListElement = document.getElementById('offline-content-list');
+ var isVisible = !contentListElement.classList.toggle('list-hidden');
+
+ if (updatePref && window.errorPageController) {
+ errorPageController.listVisibilityChanged(isVisible);
+ }
+}
+
function onDocumentLoad() {
var controlButtonDiv = document.getElementById('control-buttons');
var reloadButton = document.getElementById('reload-button');
@@ -287,8 +337,7 @@ function onDocumentLoad() {
var showSavedCopyButtonVisible =
loadTimeData.valueExists('showSavedCopyButton') &&
loadTimeData.getValue('showSavedCopyButton').msg;
- var downloadButtonVisible =
- loadTimeData.valueExists('downloadButton') &&
+ var downloadButtonVisible = loadTimeData.valueExists('downloadButton') &&
loadTimeData.getValue('downloadButton').msg;
// If offline content suggestions will be visible, the usual buttons will not
@@ -341,9 +390,12 @@ function onDocumentLoad() {
detailsButton.classList.add('singular');
}
+ var attemptAutoFetch = loadTimeData.valueExists('attemptAutoFetch') &&
+ loadTimeData.getValue('attemptAutoFetch');
+
// Show control buttons.
if (reloadButtonVisible || showSavedCopyButtonVisible ||
- downloadButtonVisible) {
+ downloadButtonVisible || attemptAutoFetch) {
controlButtonDiv.hidden = false;
// Set the secondary button state in the cases of two call to actions.
diff --git a/chromium/components/neterror/resources/offline.js b/chromium/components/neterror/resources/offline.js
index a1e3d885e05..a678165c861 100644
--- a/chromium/components/neterror/resources/offline.js
+++ b/chromium/components/neterror/resources/offline.js
@@ -36,6 +36,7 @@ function Runner(outerContainerId, opt_config) {
this.distanceRan = 0;
this.highestScore = 0;
+ this.syncHighestScore = false;
this.time = 0;
this.runningTime = 0;
@@ -69,11 +70,13 @@ function Runner(outerContainerId, opt_config) {
this.setupDisabledRunner();
} else {
this.loadImages();
+
+ window['initializeEasterEggHighScore'] =
+ this.initializeHighScore.bind(this);
}
}
window['Runner'] = Runner;
-
/**
* Default game width.
* @const
@@ -779,6 +782,23 @@ Runner.prototype = {
},
/**
+ * Set the initial high score as stored in the user's profile.
+ * @param {integer} highScore
+ */
+ initializeHighScore: function(highScore) {
+ this.syncHighestScore = true;
+ highScore = Math.ceil(highScore);
+ if (highScore < this.highestScore) {
+ if (window.errorPageController) {
+ errorPageController.updateEasterEggHighScore(this.highestScore);
+ }
+ return;
+ }
+ this.highestScore = highScore;
+ this.distanceMeter.setHighScore(this.highestScore);
+ },
+
+ /**
* Game over state.
*/
gameOver: function() {
@@ -804,6 +824,11 @@ Runner.prototype = {
if (this.distanceRan > this.highestScore) {
this.highestScore = Math.ceil(this.distanceRan);
this.distanceMeter.setHighScore(this.highestScore);
+
+ // Store the new high score in the profile.
+ if (this.syncHighestScore && window.errorPageController) {
+ errorPageController.updateEasterEggHighScore(this.highestScore);
+ }
}
// Reset the time clock.