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

Unified Diff: chrome/browser/resources/inspect/inspect.js

Issue 298993003: Show ServiceWorkers in chrome://inspect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix alignment Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/inspect/inspect.html ('k') | chrome/browser/ui/webui/inspect_ui.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/inspect/inspect.js
diff --git a/chrome/browser/resources/inspect/inspect.js b/chrome/browser/resources/inspect/inspect.js
index 3d6fd7982766a64d815ac33bc0943b5965755136..6b3c51f98cc11c232c842ad122fdf317493937bc 100644
--- a/chrome/browser/resources/inspect/inspect.js
+++ b/chrome/browser/resources/inspect/inspect.js
@@ -29,6 +29,14 @@ function sendTargetCommand(command, target) {
sendCommand(command, target.source, target.id);
}
+function sendServiceWorkerCommand(action, partition_path, scope) {
+ $('serviceworker-internals').contentWindow.postMessage({
+ 'action': action,
+ 'partition_path': partition_path,
+ 'scope': scope
+ },'chrome://serviceworker-internals');
+}
+
function removeChildren(element_id) {
var element = $(element_id);
element.textContent = '';
@@ -51,6 +59,15 @@ function onload() {
onHashChange();
initSettings();
sendCommand('init-ui');
+ window.addEventListener('message', onMessage.bind(this), false);
+}
+
+function onMessage(event) {
+ if (event.origin != 'chrome://serviceworker-internals') {
+ return;
+ }
+ populateServiceWorkers(event.data.partition_id,
+ event.data.workers);
}
function onHashChange() {
@@ -87,6 +104,39 @@ function selectTab(id) {
return true;
}
+function populateServiceWorkers(partition_id, workers) {
+ var list = $('service-workers-list-' + partition_id);
Vladislav Kaznacheev 2014/05/23 11:03:28 Do partitions ever go away? This code can only add
horo 2014/05/23 11:21:34 Done. Added removeChild().
+ if (list) {
+ list.textContent = '';
+ } else {
+ list = document.createElement('div');
+ list.id = 'service-workers-list-' + partition_id;
+ list.className = 'list';
+ $('service-workers-list').appendChild(list);
+ }
+ for (var i = 0; i < workers.length; i++) {
+ var worker = workers[i];
+ worker.hasCustomInspectAction = true;
+ var row = addTargetToList(worker, list, ['scope', 'url']);
+ addActionLink(
+ row,
+ 'inspect',
+ sendServiceWorkerCommand.bind(null,
+ 'inspect',
+ worker.partition_path,
+ worker.scope),
+ false);
+ addActionLink(
+ row,
+ 'terminate',
+ sendServiceWorkerCommand.bind(null,
+ 'stop',
+ worker.partition_path,
+ worker.scope),
+ false);
+ }
+}
+
function populateTargets(source, data) {
if (source == 'renderers')
populateWebContentsTargets(data);
@@ -508,8 +558,10 @@ function addTargetToList(data, list, properties) {
actionBox.className = 'actions';
subrowBox.appendChild(actionBox);
- addActionLink(row, 'inspect', sendTargetCommand.bind(null, 'inspect', data),
- data.hasNoUniqueId || data.adbAttachedForeign);
+ if (!data.hasCustomInspectAction) {
+ addActionLink(row, 'inspect', sendTargetCommand.bind(null, 'inspect', data),
+ data.hasNoUniqueId || data.adbAttachedForeign);
+ }
list.appendChild(row);
return row;
« no previous file with comments | « chrome/browser/resources/inspect/inspect.html ('k') | chrome/browser/ui/webui/inspect_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698