1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title i18n-content="title">About extensions</title>
<style>
body {
font-size: 84%;
font-family: Arial, Helvetica, sans-serif;
padding: 0.75em;
margin: 0;
min-width: 45em;
}
a {
color: black;
}
div#header {
padding: 0.75em 1em;
padding-top: 0.6em;
padding-left: 0;
margin-bottom: 0.75em;
position: relative;
overflow: hidden;
background: #5296de;
-webkit-background-size: 100%;
border: 1px solid #3a75bd;
-webkit-border-radius: 6px;
color: white;
}
div#header h1 {
padding-left: 37px;
margin: 0;
display: inline;
background: url('gear.png') 12px 60% no-repeat;
color: white;
}
h1 {
font-size: 110%;
font-weight: bold;
color: #4a8ee6;
padding: 0;
margin: 0;
}
div#outside {
margin-left:2px;
}
div.content {
font-size:84%;
}
.sidebar-content {
font-size:84%;
white-space:nowrap;
margin-top:-5px;
margin-right:2px;
}
.sidebar-content button {
-webkit-box-sizing:border-box;
width:100%;
}
h2 {
font-size: 110%;
letter-spacing: -1px;
font-weight: normal;
color: #3a75bd;
margin-bottom:2em;
}
.extension-details {
margin:1em 25px 4em;
line-height:1.5em;
}
.extension-name-row {
border-top:1px solid #b5c7de;
background:#eff7ff;
padding:3px 25px;
}
.extension-name {
font-weight:bold;
}
.extension-version {
margin-left: 1ex;
}
.extension-description {
margin:0.5em 0;
}
.extension-views {
margin:0 0 0.75em;
margin-left:2ex;
padding:0;
list-style-type:none;
}
.extension-actions {
margin-top:0.5em;
}
button {
font-size:100%;
}
#dialogBackground, #dialogBackground div {
display: -webkit-box;
-webkit-box-align: center;
}
#dialog input[type="button"] {
font-size: 12px;
height: 25px;
width: 100px;
}
#dialog input[type="text"] {
width: 220px;
font-size: 12px;
font-family: Arial, Helvetica, sans-serif;
}
#dialogBackground {
background-color: rgba(0, 0, 0, .2);
display: none;
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 1;
-webkit-box-orient: vertical;
-webkit-user-select:none;
}
#dialogHBackground {
height: 100%;
-webkit-box-orient: horizontal;
}
#dialog {
background-color: #5296DE;
border: 1px solid #3A75BD;
border-radius: 6px 6px;
font-size: 12px;
width: 500px;
-webkit-box-orient: vertical;
}
#dialogHeader {
background-color: rgba(0,0,0,0);
color: white;
margin: 4px;
width: 100%;
}
#dialogBody {
background-color: rgb(240, 240, 240);
border: 1px solid #3A75BD;
border-bottom-left-radius: 4px 4px;
border-bottom-right-radius: 4px 4px;
margin: 0px 2px 2px 2px;
-webkit-box-orient: vertical;
}
#dialogContentHeader {
margin: 16px;
}
.dialogBrowseRow {
margin-left: -24px;
width: 100%;
-webkit-box-orient: horizontal;
-webkit-box-pack: end;
}
.dialogBrowseRow>* {
margin: 2px
}
#dialogContentFooter {
margin-bottom: 6px;
margin-left: -12px;
margin-top: 20px;
}
</style>
<script>
/**
* This variable structure is here to document the structure that the template
* expects to correctly populate the page.
*/
var extensionDataFormat = {
"extensions": [
{
"id": "0000000000000000000000000000000000000000",
"name": "Google Chrome",
"description": "Extension long format description",
"version": "1.0.231",
"enabled": "true",
"content_scripts": [
{
"js": ["script1_file1.js", "script1_file2.js"],
"css": ["script1_file1.css", "script1_file2.css"],
"matches": ["http://*/*", "http://other.com/*"]
},
{
"js": ["script2_file1.js", "script2_file2.js"],
"css": ["script2_file1.css", "script2_file2.css"],
"matches": ["http://*/*", "http://other.com/*"]
}
],
// TODO(aa): It would be nice to also render what type of view each one
// is, like 'toolstrip', 'background', etc. Eventually, if we can also
// debug and inspect content scripts, maybe we don't need to list the
// components, just the views.
"views": [
{
"path": "toolstrip.html",
"renderViewId": 1,
"renderProcessId": 1
},
{
"path": "background.html",
"renderViewId": 2,
"renderProcessId": 1
}
]
},
{
"id": "0000000000000000000000000000000000000001",
"name": "RSS Subscriber",
"description": "Extension long format description",
"version": "1.0.231",
"enabled": "true",
"content_scripts": [
{
"js": ["script1_file1.js", "script1_file2.js"],
"css": ["script1_file1.css", "script1_file2.css"],
"matches": ["http://*/*", "http://other.com/*"]
},
{
"js": ["script2_file1.js", "script2_file2.js"],
"css": ["script2_file1.css", "script2_file2.css"],
"matches": ["http://*/*", "http://other.com/*"]
}
],
"views": [
{
"path": "foo/bar/toolstrip.html",
"renderViewId": 3,
"renderProcessId": 1
}
]
}
]
};
/**
* Takes the |extensionsData| input argument which represents data about the
* currently installed/running extensions and populates the html jstemplate with
* that data. It expects an object structure like the above.
* @param {Object} extensionsData Detailed info about installed extensions
*/
function showExtensionsData(extensionsData) {
// Sort by extension name (case-insensitive)
extensionsData.extensions.sort(function(a, b) {
a = a.name.toLowerCase();
b = b.name.toLowerCase();
return a < b ? -1 : (a > b ? 1 : 0);
});
// This is the javascript code that processes the template:
var input = new JsEvalContext(extensionsData);
var output = document.getElementById('extensionTemplate');
jstProcess(input, output);
}
/*
* Asks the C++ ExtensionDOMHandler to get details about the installed
* extensions and return detailed data about the configuration. The
* ExtensionDOMHandler should reply to returnExtensionsData() (below).
*/
function requestExtensionsData() {
chrome.send("requestExtensionsData", []);
}
// Used for observing function of the backend datasource for this page by
// tests.
window.domui_responded_ = false;
function returnExtensionsData(extensionsData) {
window.domui_responded_ = true;
showExtensionsData(extensionsData);
// We are currently hiding the body because the first call to jstProcess() to
// insert localized strings happens prior to this call which runs during the
// body.onload event, causes a flickering.
document.getElementById('body-container').style.display = "inline";
}
/**
* Tell the C++ ExtensionDOMHandler to inspect the page detailed in |viewData|.
*/
function sendInspectMessage(viewData) {
// TODO(aa): This is ghetto, but DOMUIBindings doesn't support sending
// anything other than arrays of strings, and this is all going to get
// replaced with V8 extensions soon anyway.
chrome.send('inspect', [
String(viewData.renderProcessId), String(viewData.renderViewId)
]);
}
/**
* Handles a 'reload' button getting clicked.
*/
function handleReloadExtension(node) {
// Tell the C++ ExtensionDOMHandler to reload the extension.
chrome.send('reload', [node.extensionId]);
}
/**
* Handles a 'enable' or 'disable' button getting clicked.
*/
function handleEnableExtension(node, enable) {
// Tell the C++ ExtensionDOMHandler to reload the extension.
chrome.send('enable', [node.extensionId, String(enable)]);
requestExtensionsData();
}
/**
* Handles an 'uninstall' button getting clicked.
*/
function handleUninstallExtension(node) {
// Tell the C++ ExtensionDOMHandler to uninstall an extension.
chrome.send('uninstall', [node.extensionId]);
}
/**
* Utility function which asks the C++ to show a platform-specific file select
* dialog, and fire |callback| with the |filePath| that resulted. |selectType|
* can be either 'file' or 'folder'. |operation| can be 'load', 'packRoot',
* or 'pem' which are signals to the C++ to do some operation-specific
* configuration.
*/
function showFileDialog(selectType, operation, callback) {
handleFilePathSelected = function(filePath) {
callback(filePath);
handleFilePathSelected = function() {};
};
chrome.send('selectFilePath', [selectType, operation]);
}
/**
* Handles the "Load extension..." button being pressed.
*/
function loadExtension() {
showFileDialog('folder', 'load', function(filePath) {
chrome.send('load', [String(filePath)]);
});
}
/**
* Handles the "Pack extension..." button being pressed.
*/
function packExtension() {
var extensionPath = document.getElementById('extensionPathText').value;
var privateKeyPath = document.getElementById('privateKeyPath').value;
chrome.send('pack', [extensionPath, privateKeyPath]);
}
/**
* Shows to modal HTML pack dialog.
*/
function showPackDialog() {
document.getElementById('dialogBackground').style.display="-webkit-box";
}
/**
* Hides the pack dialog.
*/
function hidePackDialog() {
document.getElementById('dialogBackground').style.display="none"
}
/**
* Pop up a select dialog to capture the extension path.
*/
function selectExtensionPath() {
showFileDialog('folder', 'packRoot', function(filePath) {
document.getElementById('extensionPathText').value = filePath;
});
}
/**
* Pop up a select dialog to capture the private key path.
*/
function selectPrivateKeyPath() {
showFileDialog('file', 'pem', function(filePath) {
document.getElementById('privateKeyPath').value = filePath;
});
}
/**
* Handles the "Update extensions now" button being pressed.
*/
function autoUpdate() {
chrome.send('autoupdate', []);
}
</script>
</head>
<body onload="requestExtensionsData();">
<div id="dialogBackground">
<div id="dialogHBackground">
<div id="dialog">
<div id="dialogHeader">
Pack Extension
</div>
<div id="dialogBody">
<div id="dialogContentHeader" i18n-content="packDialogHeading">
HEADING
</div>
<div class="dialogBrowseRow">
<div i18n-content="rootDirectoryLabel">
ROOT_DIR
</div>
<div>
<input type="text" id="extensionPathText">
</div>
<div>
<input type="button" value="BROWSE"
i18n-values="value:packDialogBrowse"
onclick="selectExtensionPath();">
</div>
</div>
<div class="dialogBrowseRow">
<div i18n-content="privateKeyLabel">
PRIVATE_KEY
</div>
<div>
<input type="text" id="privateKeyPath">
</div>
<div>
<input type="button" value="BROWSE"
i18n-values="value:packDialogBrowse"
onclick="selectPrivateKeyPath();">
</div>
</div>
<div class="dialogBrowseRow" id="dialogContentFooter">
<div>
<input type="button" value="OK" onclick="packExtension();">
</div>
<div>
<input type="button" value="Cancel" onclick="hidePackDialog();">
</div>
</div>
</div>
</div>
</div>
</div>
<div id="body-container" style="display:none;">
<div id="header"><h1>About extensions</h1></div>
<div id="outside">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="100%" valign="top" align="left">
<h2>Installed extensions</h2>
<div class="content">
<div id="extensionTemplate">
<div class="extension-name" jsdisplay="extensions.length === 0">
No extensions installed</div>
<div jsdisplay="extensions.length > 0">
<div class="extension" jsselect="extensions">
<div class="extension-name-row">
<span class="extension-name" jscontent="name">Extension Name</span>
<span class="extension-version" jscontent="version">x.x.x.x</span>
<span jsdisplay="!enabled">(Disabled)</span>
</div>
<div class="extension-details">
<div class="extension-id">ID: <span jscontent="id"></div>
<div class="extension-description" jscontent="description"></div>
Active views:
<ul class="extension-views">
<li jsselect="views"><span jscontent="path"></span> -
<a jsvalues=".extensionView:$this" href="#"
onclick="sendInspectMessage(this.extensionView); return false;"
>Inspect</a>
</ul>
<div class="extension-actions">
<button
jsvalues=".extensionId:id"
jsdisplay="enabled"
onclick="handleEnableExtension(this, false)"
>Disable</button>
<button
jsvalues=".extensionId:id"
jsdisplay="!enabled"
onclick="handleEnableExtension(this, true)"
>Enable</button>
<button
jsvalues=".extensionId:id"
jsdisplay="enabled"
onclick="handleReloadExtension(this)"
>Reload</button>
<button
jsvalues=".extensionId:id"
onclick="handleUninstallExtension(this)"
>Uninstall</button>
</div>
</div>
</div>
</div>
</div>
</div>
</td>
<td style="min-width:20px"></td>
<td valign="top">
<h2>Tools</h2>
<div class="sidebar-content">
<button onclick="loadExtension()">Load unpacked extension...</button><br />
<button onclick="showPackDialog()">Pack extension...</button><br />
<button onclick="autoUpdate()">Update extensions now</button>
</div>
</td>
</tr>
</table>
</div> <!-- /outside -->
</body>
</html>
|