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

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

Issue 2089423002: [Offline Pages] Connect the offline page logs to the internals page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@i4
Patch Set: style update Created 4 years, 6 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 cell = document.createElement('td'); 75 cell = document.createElement('td');
76 cell.textContent = requests[i].status; 76 cell.textContent = requests[i].status;
77 row.appendChild(cell); 77 row.appendChild(cell);
78 78
79 requestQueueTable.appendChild(row); 79 requestQueueTable.appendChild(row);
80 } 80 }
81 savePageRequests = requests; 81 savePageRequests = requests;
82 } 82 }
83 83
84 /** 84 /**
85 * Fills the event logs section.
86 * @param {!Array<string>} logs A list of log strings.
87 */
88 function fillEventLog(logs) {
89 var element = $('logs');
90 element.textContent = '';
91 for (let log of logs) {
92 var logItem = document.createElement('li');
93 logItem.textContent = log;
94 element.appendChild(logItem);
95 }
96 }
97
98 /**
85 * Refresh all displayed information. 99 * Refresh all displayed information.
86 */ 100 */
87 function refreshAll() { 101 function refreshAll() {
88 browserProxy_.getStoredPages().then(fillStoredPages); 102 browserProxy_.getStoredPages().then(fillStoredPages);
89 browserProxy_.getRequestQueue().then(fillRequestQueue); 103 browserProxy_.getRequestQueue().then(fillRequestQueue);
104 browserProxy_.getEventLogs().then(fillEventLog);
90 } 105 }
91 106
92 /** 107 /**
93 * Delete all pages in the offline store. 108 * Delete all pages in the offline store.
94 */ 109 */
95 function deleteAllPages() { 110 function deleteAllPages() {
96 browserProxy_.deleteAllPages().then(pagesDeleted); 111 browserProxy_.deleteAllPages().then(pagesDeleted);
97 } 112 }
98 113
99 /** 114 /**
(...skipping 28 matching lines...) Expand all
128 var selectedIds = []; 143 var selectedIds = [];
129 144
130 for (var i = 0; i < checkboxes.length; i++) { 145 for (var i = 0; i < checkboxes.length; i++) {
131 if (checkboxes[i].checked) 146 if (checkboxes[i].checked)
132 selectedIds.push(checkboxes[i].value); 147 selectedIds.push(checkboxes[i].value);
133 } 148 }
134 149
135 browserProxy_.deleteSelectedPages(selectedIds).then(pagesDeleted); 150 browserProxy_.deleteSelectedPages(selectedIds).then(pagesDeleted);
136 } 151 }
137 152
153 /**
154 * Turns on logging for stored pages.
155 */
156 function toggleModelOn() {
157 browserProxy_.setRecordPageModel(true);
158 }
159
160 /**
161 * Turns off logging for stored pages.
162 */
163 function toggleModelOff() {
164 browserProxy_.setRecordPageModel(false);
165 }
166
167 /**
168 * Turns on logging for request queue.
169 */
170 function toggleRequestOn() {
171 browserProxy_.setRecordRequestQueue(true);
172 }
173
174 /**
175 * Turns off logging for request queue.
176 */
177 function toggleRequestOff() {
178 browserProxy_.setRecordRequestQueue(false);
179 }
180
181 /**
182 * Refreshes the logs.
183 */
184 function refreshLog() {
185 browserProxy_.getEventLogs().then(fillEventLog);
186 }
187
138 function initialize() { 188 function initialize() {
139 $('clear-all').onclick = deleteAllPages; 189 $('clear-all').onclick = deleteAllPages;
140 $('clear-selected').onclick = deleteSelectedPages; 190 $('clear-selected').onclick = deleteSelectedPages;
141 $('refresh').onclick = refreshAll; 191 $('refresh').onclick = refreshAll;
142 $('download').onclick = download; 192 $('download').onclick = download;
193 $('log-model-on').onclick = toggleModelOn;
dpapad 2016/06/24 20:33:39 Nit: The four different callback methods can be re
chili 2016/06/24 21:43:17 Done.
194 $('log-model-off').onclick = toggleModelOff;
195 $('log-request-on').onclick = toggleRequestOn;
196 $('log-request-off').onclick = toggleRequestOff;
197 $('refresh-logs').onclick = refreshLog;
143 browserProxy_ = 198 browserProxy_ =
144 offlineInternals.OfflineInternalsBrowserProxyImpl.getInstance(); 199 offlineInternals.OfflineInternalsBrowserProxyImpl.getInstance();
145 refreshAll(); 200 refreshAll();
146 } 201 }
147 202
148 // Return an object with all of the exports. 203 // Return an object with all of the exports.
149 return { 204 return {
150 initialize: initialize, 205 initialize: initialize,
151 }; 206 };
152 }); 207 });
153 208
154 document.addEventListener('DOMContentLoaded', offlineInternals.initialize); 209 document.addEventListener('DOMContentLoaded', offlineInternals.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698