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

Side by Side Diff: chrome/browser/resources/offline_pages/offline_internals.js

Issue 2172443004: [Offline Pages] Add network status, save request textbox, and offline url link to offline internals… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update SavePageRequest call after rebase Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 cr.define('offlineInternals', function() { 5 cr.define('offlineInternals', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** @type {!Array<OfflinePage>} */ 8 /** @type {!Array<OfflinePage>} */
9 var offlinePages = []; 9 var offlinePages = [];
10 10
(...skipping 19 matching lines...) Expand all
30 var checkboxCell = document.createElement('td'); 30 var checkboxCell = document.createElement('td');
31 var checkbox = document.createElement('input'); 31 var checkbox = document.createElement('input');
32 checkbox.setAttribute('type', 'checkbox'); 32 checkbox.setAttribute('type', 'checkbox');
33 checkbox.setAttribute('name', 'stored'); 33 checkbox.setAttribute('name', 'stored');
34 checkbox.setAttribute('value', pages[i].id); 34 checkbox.setAttribute('value', pages[i].id);
35 35
36 checkboxCell.appendChild(checkbox); 36 checkboxCell.appendChild(checkbox);
37 row.appendChild(checkboxCell); 37 row.appendChild(checkboxCell);
38 38
39 var cell = document.createElement('td'); 39 var cell = document.createElement('td');
40 cell.textContent = pages[i].onlineUrl; 40 var link = document.createElement('a');
41 link.setAttribute('href', pages[i].filePath);
42 link.textContent = pages[i].onlineUrl;
43 cell.appendChild(link);
41 row.appendChild(cell); 44 row.appendChild(cell);
42 45
43 cell = document.createElement('td'); 46 cell = document.createElement('td');
44 cell.textContent = pages[i].namespace; 47 cell.textContent = pages[i].namespace;
45 row.appendChild(cell); 48 row.appendChild(cell);
46 49
47 cell = document.createElement('td'); 50 cell = document.createElement('td');
48 cell.textContent = Math.round(pages[i].size / 1024); 51 cell.textContent = Math.round(pages[i].size / 1024);
49 row.appendChild(cell); 52 row.appendChild(cell);
50 53
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 element.appendChild(logItem); 102 element.appendChild(logItem);
100 } 103 }
101 } 104 }
102 105
103 /** 106 /**
104 * Refresh all displayed information. 107 * Refresh all displayed information.
105 */ 108 */
106 function refreshAll() { 109 function refreshAll() {
107 browserProxy_.getStoredPages().then(fillStoredPages); 110 browserProxy_.getStoredPages().then(fillStoredPages);
108 browserProxy_.getRequestQueue().then(fillRequestQueue); 111 browserProxy_.getRequestQueue().then(fillRequestQueue);
112 browserProxy_.getNetworkStatus().then(function(networkStatus) {
113 $('current-status').textContent = networkStatus;
114 });
109 refreshLog(); 115 refreshLog();
110 } 116 }
111 117
112 /** 118 /**
113 * Delete all pages in the offline store. 119 * Delete all pages in the offline store.
114 */ 120 */
115 function deleteAllPages() { 121 function deleteAllPages() {
116 browserProxy_.deleteAllPages().then(pagesDeleted); 122 browserProxy_.deleteAllPages().then(pagesDeleted);
117 } 123 }
118 124
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 172
167 /** 173 /**
168 * Refreshes the logs. 174 * Refreshes the logs.
169 */ 175 */
170 function refreshLog() { 176 function refreshLog() {
171 browserProxy_.getEventLogs().then(fillEventLog); 177 browserProxy_.getEventLogs().then(fillEventLog);
172 browserProxy_.getLoggingState().then(updateLogStatus); 178 browserProxy_.getLoggingState().then(updateLogStatus);
173 } 179 }
174 180
175 function initialize() { 181 function initialize() {
182 /**
183 * @param {!boolean} enabled Whether to enable Logging.
184 */
185 function togglePageModelLog(enabled) {
186 browserProxy_.setRecordPageModel(enabled);
187 $('model-status').textContent = enabled ? 'On' : 'Off';
188 }
189
190 /**
191 * @param {!boolean} enabled Whether to enable Logging.
192 */
193 function toggleRequestQueueLog(enabled) {
194 browserProxy_.setRecordRequestQueue(enabled);
195 $('request-status').textContent = enabled ? 'On' : 'Off';
196 }
197
176 $('clear-all').onclick = deleteAllPages; 198 $('clear-all').onclick = deleteAllPages;
177 $('clear-selected').onclick = deleteSelectedPages; 199 $('clear-selected').onclick = deleteSelectedPages;
178 $('refresh').onclick = refreshAll; 200 $('refresh').onclick = refreshAll;
179 $('download').onclick = download; 201 $('download').onclick = download;
180 $('log-model-on').onclick = 202 $('log-model-on').onclick = togglePageModelLog.bind(this, true);
181 browserProxy_.setRecordPageModel.bind(browserProxy_, true); 203 $('log-model-off').onclick = togglePageModelLog.bind(this, false);
182 $('log-model-off').onclick = 204 $('log-request-on').onclick = toggleRequestQueueLog.bind(this, true);
183 browserProxy_.setRecordPageModel.bind(browserProxy_, false); 205 $('log-request-off').onclick = toggleRequestQueueLog.bind(this, false);
184 $('log-request-on').onclick =
185 browserProxy_.setRecordRequestQueue.bind(browserProxy_, true);
186 $('log-request-off').onclick =
187 browserProxy_.setRecordRequestQueue.bind(browserProxy_, false);
188 $('refresh-logs').onclick = refreshLog; 206 $('refresh-logs').onclick = refreshLog;
207 $('add-to-queue').onclick = function() {
208 var saveUrl = $('url').value;
209 browserProxy_.addToRequestQueue(saveUrl)
210 .then(function(state) {
211 if (state) {
212 $('save-url-state').textContent =
213 saveUrl + ' has been added to queue.';
214 $('url').value = '';
215 browserProxy_.getRequestQueue().then(fillRequestQueue);
216 } else {
217 $('save-url-state').textContent =
218 saveUrl + ' failed to be added to queue.';
219 }
220 });
221 };
222
189 refreshAll(); 223 refreshAll();
190 } 224 }
191 225
192 // Return an object with all of the exports. 226 // Return an object with all of the exports.
193 return { 227 return {
194 initialize: initialize, 228 initialize: initialize,
195 }; 229 };
196 }); 230 });
197 231
198 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); 232 document.addEventListener('DOMContentLoaded', offlineInternals.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698