Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/renderer/resources/neterror.js

Issue 1129353005: Move Google Cache copy suggestion to an action button in the neterror interstitial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function toggleHelpBox() { 5 function toggleHelpBox() {
6 var helpBoxOuter = document.getElementById('details'); 6 var helpBoxOuter = document.getElementById('details');
7 helpBoxOuter.classList.toggle('hidden'); 7 helpBoxOuter.classList.toggle('hidden');
8 var detailsButton = document.getElementById('details-button'); 8 var detailsButton = document.getElementById('details-button');
9 if (helpBoxOuter.classList.contains('hidden')) 9 if (helpBoxOuter.classList.contains('hidden'))
10 detailsButton.innerText = detailsButton.detailsText; 10 detailsButton.innerText = detailsButton.detailsText;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (window.errorPageController) { 106 if (window.errorPageController) {
107 errorPageController.showSavedCopyButtonClick(); 107 errorPageController.showSavedCopyButtonClick();
108 } 108 }
109 } 109 }
110 110
111 function detailsButtonClick() { 111 function detailsButtonClick() {
112 if (window.errorPageController) 112 if (window.errorPageController)
113 errorPageController.detailsButtonClick(); 113 errorPageController.detailsButtonClick();
114 } 114 }
115 115
116 /**
117 * Replace the reload button with the Google cached copy suggestion.
118 */
119 function setupCachedButton(buttonStrings) {
120 var reloadButton = document.getElementById('reload-button');
121
122 reloadButton.textContent = buttonStrings.msg;
123 reloadButton.url = buttonStrings.cacheUrl;
124 reloadButton.trackingid = buttonStrings.trackingId;
125 reloadButton.removeAttribute('onclick');
126 reloadButton.addEventListener('click', function(e) {
127 e.preventDefault();
128 var el = e.currentTarget;
129 trackClick(el.trackingid);
130 location = el.url;
131 });
132 reloadButton.style.display = '';
133 document.getElementById('control-buttons').hidden = false;
134 }
135
116 var primaryControlOnLeft = true; 136 var primaryControlOnLeft = true;
117 <if expr="is_macosx or is_ios or is_linux or is_android"> 137 <if expr="is_macosx or is_ios or is_linux or is_android">
118 primaryControlOnLeft = false; 138 primaryControlOnLeft = false;
119 </if> 139 </if>
120 140
121 function onDocumentLoad() { 141 function onDocumentLoad() {
122 var buttonsDiv = document.getElementById('buttons');
123 var controlButtonDiv = document.getElementById('control-buttons'); 142 var controlButtonDiv = document.getElementById('control-buttons');
124 var reloadButton = document.getElementById('reload-button'); 143 var reloadButton = document.getElementById('reload-button');
125 var detailsButton = document.getElementById('details-button'); 144 var detailsButton = document.getElementById('details-button');
126 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); 145 var showSavedCopyButton = document.getElementById('show-saved-copy-button');
127 146
128 var primaryButton, secondaryButton; 147 var primaryButton, secondaryButton;
129 if (showSavedCopyButton.primary) { 148 if (showSavedCopyButton.primary) {
130 primaryButton = showSavedCopyButton; 149 primaryButton = showSavedCopyButton;
131 secondaryButton = reloadButton; 150 secondaryButton = reloadButton;
132 } else { 151 } else {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 secondaryButton.classList.add('secondary-button'); 190 secondaryButton.classList.add('secondary-button');
172 } 191 }
173 } 192 }
174 193
175 // Add a main message paragraph. 194 // Add a main message paragraph.
176 if (loadTimeData.valueExists('primaryParagraph')) { 195 if (loadTimeData.valueExists('primaryParagraph')) {
177 var p = document.querySelector('#main-message p'); 196 var p = document.querySelector('#main-message p');
178 p.innerHTML = loadTimeData.getString('primaryParagraph'); 197 p.innerHTML = loadTimeData.getString('primaryParagraph');
179 p.hidden = false; 198 p.hidden = false;
180 } 199 }
200
201 // Check for Google cached copy suggestion.
202 if (loadTimeData.valueExists('cacheButton')) {
203 setupCachedButton(loadTimeData.getValue('cacheButton'));
204 }
181 } 205 }
182 206
183 document.addEventListener('DOMContentLoaded', onDocumentLoad); 207 document.addEventListener('DOMContentLoaded', onDocumentLoad);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698