summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/plugins.html
blob: cb0a164bd9abf21f6b9decd3b0350f685aca4d9b (plain)
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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
<title i18n-content="pluginsTitle"></title>
<style>
body {
  margin: 10px;
  min-width: 47em;
}

a {
  color: blue;
  font-size: 103%;
}

div#header {
  margin-bottom: 1.05em;
  /* 67px is the height of the header's background image. */
  min-height: 67px;
  overflow: hidden;
  padding-bottom: 20px;
  -webkit-padding-start: 0;
  padding-top: 20px;
  position: relative;
  box-sizing: border-box;
}

#header h1 {
  background: url('../../app/theme/extensions_section.png') 0px 20px no-repeat;
  display: inline;
  margin: 0;
  padding-bottom: 43px;
  padding-left: 75px;
  padding-top: 40px;
}

html[dir=rtl] #header h1 {
  background: url('../../app/theme/extensions_section.png') right no-repeat;
  padding-right: 95px;
  padding-left: 0;
}

h1 {
  font-size: 156%;
  font-weight: bold;
  padding: 0;
  margin: 0;
}

div.content {
  font-size: 88%;
  margin-top: 5px;
}

.section-header {
  background: #ebeff9;
  border-top: 1px solid #b5c7de;
  font-size: 99%;
  padding-bottom: 2px;
  -webkit-padding-start: 5px;
  padding-top: 3px;
  width: 100%;
}

.section-header > table tr td:first-child {
  width: 100%;
}

.section-header > table {
  width: 100%;
}

.section-header-title {
  font-weight: bold;
}

.vbox-container {
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.wbox {
  display: -webkit-box;
  -webkit-box-align: stretch;
  -webkit-box-flex: 1;
}

#top {
  -webkit-padding-end: 5px;
}

.showInTmiMode {
  overflow: hidden;
}

body.hideTmiModeInitial .showInTmiMode {
  height: 0 !important;
  opacity: 0;
}

body.hideTmiMode .showInTmiMode {
  height: 0 !important;
  opacity: 0;
  -webkit-transition: all .1s ease-out;
}

body.showTmiModeInitial .showInTmiMode {
  opacity: 1;
}

body.showTmiMode .showInTmiMode {
  opacity: 1;
  -webkit-transition: all .1s ease-in;
}

.wbox-tmi-mode {
  -webkit-box-align: stretch;
  -webkit-box-flex: 1;
}

.tmi-mode-image {
  margin-top: 2px;
  padding-left: 5px;
  padding-right: 5px;
}

.tmi-mode-link {
  margin-right: 3px;
  white-space: nowrap;
}

.tmi-mode-link a {
  font-size: 97%;
}

.tmi-mode {
  background: #f4f6fc;
  border-bottom: 1px solid #edeff5;
  font-size: 89%;
  padding-bottom: 0.8em;
  -webkit-padding-start: 10px;
  padding-top: 0.8em;
  width: 100%;
}

.plugin-disabled > td {
  background-color: #f0f0f0;
  color: #a0a0a0;
  padding-bottom: 4px;
  padding-top: 5px;
}

.plugin-enabled > td {
  padding-bottom: 4px;
  padding-top: 5px;
}

.plugin-file-disabled {
  background-color: #f0f0f0;
  color: #a0a0a0;
  padding-top: 5px;
  padding-bottom: 5px;
}

.plugin-file-enabled {
  padding-top: 5px;
  padding-bottom: 5px;
}

.plugin {
  border-bottom: 1px solid #cdcdcd;
}

.critical {
  color: red;
}

/* Indent the text related to each plug-in. */
.plugin-text {
  -webkit-padding-start: 5px;
}

.plugin-name {
  font-weight: bold;
}

.no-plugins {
  margin: 6em 0 0;
  text-align: center;
  font-size: 1.2em;
}

/* Use tables for layout, so eliminate extra spacing. */
.plugin-details table {
  -webkit-border-horizontal-spacing: 0;
  -webkit-border-vertical-spacing: 0;
}

.plugin-details {
  -webkit-padding-start: 1em;
}

/* Separate the inital line, Description, Location, and MIME Types lines. */
.plugin-details > div {
  padding-top: 0.1em
}

/* Align rows of tables along the top. */
.plugin-details tr {
  vertical-align: top;
}

/* Separate columns by 1em for the most part. */
.plugin-details td+td {
  -webkit-padding-start: 1em;
}

/* Make the MIME Types tables smaller. */
.plugin-details .mime-types {
  font-size: 95%;
}

/* Separate the header from the contents in each MIME Types table. */
.plugin-details .mime-types .header td {
  padding-bottom: 0.1em;
  border-bottom: 1px solid;
}

/* Separate the columns for tables used for horizontal listings only a bit. */
.hlisting td+td {
  -webkit-padding-start: 0.4em;
}

/* Match the indentation of .plugin-text. */
.plugin-actions {
  -webkit-padding-start: 5px;
  margin-top: 0.2em;
  margin-bottom: 0.2em;
}

button {
  font-size: 104%;
}

</style>
<script>

/**
 * This variable structure is here to document the structure that the template
 * expects to correctly populate the page.
 */
var pluginDataFormat = {
  'plugins': [
    {
      'name': 'Group Name',
      'description': 'description',
      'version': 'version',
      'update_url': 'http://update/',
      'critical': true,
      'enabled': true,
      'plugin_files': [
        {
          'path': '/blahblah/blahblah/MyCrappyPlugin.plugin',
          'name': 'MyCrappyPlugin',
          'version': '1.2.3',
          'description': 'My crappy plugin',
          'mimeTypes': [
            { 'description': 'Foo Media',
              'fileExtensions': [ 'foo' ],
              'mimeType': 'application/x-my-foo' },
            { 'description': 'Bar Stuff',
              'fileExtensions': [ 'bar','baz' ],
              'mimeType': 'application/my-bar' }
          ],
          'enabledMode': 'enabled'
        },
        {
          'path': '/foobar/baz/YourGreatPlugin.plugin',
          'name': 'YourGreatPlugin',
          'version': '4.5',
          'description': 'Your great plugin',
          'mimeTypes': [
            { 'description': 'Baz Stuff',
              'fileExtensions': [ 'baz' ],
              'mimeType': 'application/x-your-baz' }
          ],
          'enabledMode': 'disabledByUser'
        },
        {
          'path': '/foobiz/bar/HisGreatPlugin.plugin',
          'name': 'HisGreatPlugin',
          'version': '1.2',
          'description': 'His great plugin',
          'mimeTypes': [
            { 'description': 'More baz Stuff',
              'fileExtensions': [ 'bor' ],
              'mimeType': 'application/x-his-bor' }
          ],
          'enabledMode': 'disabledByPolicy'
        }
      ]
    }
  ]
};

/**
 * Takes the |pluginsData| input argument which represents data about the
 * currently installed/running plugins and populates the html jstemplate with
 * that data. It expects an object structure like the above.
 * @param {Object} pluginsData Detailed info about installed plugins
 */
function renderTemplate(pluginsData) {
  // This is the javascript code that processes the template:
  var input = new JsEvalContext(pluginsData);
  var output = document.getElementById('pluginTemplate');
  jstProcess(input, output);
}

/**
 * Asks the C++ PluginsDOMHandler to get details about the installed plugins and
 * return detailed data about the configuration. The PluginsDOMHandler should
 * reply to returnPluginsData() (below).
 */
function requestPluginsData() {
  chrome.send('requestPluginsData', []);
}

/**
 * Asks the C++ PluginsDOMHandler to show the terms of service (about:terms).
 */
function showTermsOfService() {
  chrome.send('showTermsOfService', []);
}

/**
 * Called by the dom_ui_ to re-populate the page with data representing the
 * current state of installed plugins.
 */
function returnPluginsData(pluginsData){
  var bodyContainer = document.getElementById('body-container');
  var body = document.body;

  // Set all page content to be visible so we can measure heights.
  bodyContainer.style.visibility = 'hidden';
  body.className = '';
  var slidables = document.getElementsByClassName('showInTmiMode');
  for (var i = 0; i < slidables.length; i++)
    slidables[i].style.height = 'auto';

  renderTemplate(pluginsData);

  // Make sure the left column (with "Description:", "Location:", etc.) is the
  // same size for all plugins.
  var labels = document.getElementsByClassName('plugin-details-label');
  var maxLabelWidth = 0;
  for (var i = 0; i < labels.length; i++)
    labels[i].style.width = 'auto';
  for (var i = 0; i < labels.length; i++)
    maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth);
  for (var i = 0; i < labels.length; i++)
    labels[i].style.width = maxLabelWidth + 'px';

  // Explicitly set the height for each element that wants to be "slid" in and
  // out when the tmiModeExpanded is toggled.
  var slidables = document.getElementsByClassName('showInTmiMode');
  for (var i = 0; i < slidables.length; i++)
    slidables[i].style.height = slidables[i].offsetHeight + 'px';

  // Reset visibility of page based on the current tmi mode.
  document.getElementById('collapse').style.display =
     tmiModeExpanded ? 'inline' : 'none';
  document.getElementById('expand').style.display =
     tmiModeExpanded ? 'none' : 'inline';
  bodyContainer.style.visibility = 'visible';
  body.className = tmiModeExpanded ?
     'showTmiModeInitial' : 'hideTmiModeInitial';
}

/**
 * Handles a 'enable' or 'disable' button getting clicked.
 */
function handleEnablePlugin(node, enable, isGroup) {
  // Tell the C++ PluginsDOMHandler to enable/disable the plugin.
  chrome.send('enablePlugin', [String(node.path), String(enable),
              String(isGroup)]);
}

// Keeps track of whether details have been made visible (expanded) or not.
var tmiModeExpanded = false;

/*
 * Toggles visibility of details.
 */
function toggleTmiMode() {
  tmiModeExpanded = !tmiModeExpanded;

  document.getElementById('collapse').style.display =
      tmiModeExpanded ? 'inline' : 'none';
  document.getElementById('expand').style.display =
      tmiModeExpanded ? 'none' : 'inline';

  document.body.className =
      tmiModeExpanded ? 'showTmiMode' : 'hideTmiMode';
}

/**
 * Determines whether a plugin's version should be displayed.
 */
function shouldDisplayPluginVersion(plugin) {
  return !!plugin.version && plugin.version != '0';
}

/**
 * Determines whether a plugin's description should be displayed.
 */
function shouldDisplayPluginDescription(plugin) {
  // Only display the description if it's not blank and if it's not just the
  // name, version, or combination thereof.
  return plugin.description &&
         plugin.description != plugin.name &&
         plugin.description != plugin.version &&
         plugin.description != 'Version ' + plugin.version &&
         plugin.description != plugin.name + ' ' + plugin.version;
}

// Unfortunately, we don't have notifications for plugin (list) status changes
// (yet), so in the meanwhile just update regularly.
setInterval(requestPluginsData, 30000);

// Get data and have it displayed upon loading.
document.addEventListener('DOMContentLoaded', requestPluginsData);

</script>
</head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div id="body-container" style="visibility:hidden">

  <div id="header"><h1 i18n-content="pluginsTitle">TITLE</h1></div>

  <div id="pluginTemplate">

    <div id="container" class="vbox-container">
    <div id="top" class="wbox">

      <div class="section-header">
        <table cellpadding="0" cellspacing="0"><tr valign="center">
          <td>
            <span class="section-header-title" i18n-content="pluginsTitle"
              >TITLE</span>
            <span class="section-header-title"
                  jsdisplay="plugins.length > 0">(<span
                  jscontent="plugins.length"></span>)</span>
          </td>
          <td width="18">
            <img id="collapse" class="tmi-mode-image"
                 style="display:none" onclick="toggleTmiMode();"
                 src="shared/images/minus.png">
            <img id="expand" class="tmi-mode-image"
                 onclick="toggleTmiMode();" src="shared/images/plus.png">
          </td>
          <td>
            <div class="tmi-mode-link">
              <a onclick="toggleTmiMode();" style="cursor: default"
                 i18n-content="pluginsDetailsModeLink">DETAILS</a>
            </div>
          </td>
        </tr></table>
      </div>

    </div>
    </div>

    <div class="content">
      <div class="plugin-name no-plugins" jsdisplay="plugins.length === 0">
        <div i18n-content="noPlugins">NO_PLUGINS_ARE_INSTALLED</div>
      </div>

      <div jsdisplay="plugins.length > 0">
      <div class="plugin" jsselect="plugins">
        <table width="100%" cellpadding="2" cellspacing="0">
        <tr jsvalues=
            ".className:enabledMode == 'enabled' ? 'plugin-enabled' : 'plugin-disabled'">
        <td valign="top">
          <div class="plugin-text">
            <div>
              <span class="plugin-name" dir="ltr"
                    jscontent="name">NAME</span>
              <span jsdisplay="plugin_files.length > 1"
                  jscontent="'(' + plugin_files.length +' files)'">(x)</span>
              <span jsdisplay="shouldDisplayPluginVersion($this)">
                - <span i18n-content="pluginVersion">VERSION</span>
                <span jsvalues=".className:critical? 'critical': ''"
                    dir="ltr" jscontent="version">x.x.x.x</span>
              </span>
              <a jsdisplay="critical" jsvalues=".href:update_url"
                    i18n-content="pluginDownload">DOWNLOAD UPDATE</a>
              <span jsdisplay="enabledMode == 'disabledByUser'"
                    i18n-content="pluginDisabled">(DISABLED)</span>
              <span jsdisplay="enabledMode == 'disabledByPolicy'"
                    i18n-content="pluginDisabledByPolicy">(DISABLED_BY_POLICY)</span>
              <div jsdisplay="shouldDisplayPluginDescription($this)">
                <span dir="ltr" jsvalues=".innerHTML:description">
              </div>
            </div>
            <div jsselect="plugin_files" class="plugin-details">
              <div class="showInTmiMode">
                <div jsvalues=
                  ".className:enabledMode == 'enabled' ? 'plugin-file-enabled' : 'plugin-file-disabled'">
                  <div><table><tr>
                    <td class="plugin-details-label"
                        i18n-content="pluginName">NAME:</td>
                    <td><span dir="ltr" jscontent="name">NAME</span></td>
                  </tr></table></div>
                  <div><table>
                    <tr jsdisplay="shouldDisplayPluginDescription($this)">
                      <td class="plugin-details-label"
                          i18n-content="pluginDescription">DESCRIPTION:</td>
                      <td>
                        <span dir="ltr" jsvalues=".innerHTML:description">
                      </td>
                    </tr>
                  </table></div>
                  <div><table><tr>
                    <td class="plugin-details-label"
                        i18n-content="pluginVersion">VERSION:</td>
                    <td><span dir="ltr" jscontent="version">x.x.x.x</span></td>
                  </tr></table></div>
                  <div><table><tr>
                    <td class="plugin-details-label"
                        i18n-content="pluginPriority">PRIORITY:</td>
                    <td><span dir="ltr" jscontent="priority">x</span></td>
                  </tr></table></div>
                  <div><table><tr>
                    <td class="plugin-details-label"
                        i18n-content="pluginPath">PATH:</td>
                    <td><span dir="ltr" jscontent="path"></span></td>
                  </tr></table></div>
                  <div><table><tr>
                    <td class="plugin-details-label">&nbsp;</td>
                    <td>
                      <span jsdisplay="enabledMode == 'disabledByUser'"
                          i18n-content="pluginDisabled">(DISABLED)</span>
                      <span jsdisplay="enabledMode == 'disabledByPolicy'"
                          i18n-content="pluginDisabled">(DISABLED_BY_POLICY)</span>
                      <span>
                        <a
                          jsvalues=".path:path"
                          jsdisplay="enabledMode == 'enabled'"
                          onclick="handleEnablePlugin(this, false, false)"
                          href="javascript:void(0);"
                          i18n-content="disable"
                          >DISABLE</a>
                        <a
                          jsvalues=".path:path"
                          jsdisplay="enabledMode == 'disabledByUser'"
                          onclick="handleEnablePlugin(this, true, false)"
                          href="javascript:void(0);"
                          i18n-content="enable"
                          >ENABLE</a>
                        <span
                          jsdisplay="enabledMode == 'disabledByPolicy'"
                          i18n-content="pluginCannotBeEnabledDueToPolicy"
                          >CANNOT_ENABLE</span>
                      </span>
                    </td>
                  </tr></table></div>
                  <table><tr jsdisplay="mimeTypes.length > 0">
                    <td class="plugin-details-label"
                        i18n-content="pluginMimeTypes">MIME_TYPES:</td>
                    <td><table width="100%" class="mime-types">
                      <tr class="header">
                        <td i18n-content="pluginMimeTypesMimeType"
                            >MIME type</td>
                        <td i18n-content="pluginMimeTypesDescription"
                            >DESCRIPTION</td>
                        <td i18n-content="pluginMimeTypesFileExtensions"
                            >FILE_EXTENSIONS</td>
                      </tr>
                      <tr jsselect="mimeTypes">
                        <td><span dir="ltr"
                                  jscontent="mimeType"></span></td>
                        <td><span dir="ltr"
                                  jsvalues=".innerHTML:description"></span></td>
                        <td><table jsdisplay="fileExtensions.length > 0"
                                   class="hlisting">
                          <tr><td jsselect="fileExtensions">
                            <span dir="ltr" jscontent="'.' + $this">
                          </td></tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr></table>
                </div>
              </div>
            </div>
          </div>
          <div class="plugin-actions">
            <span>
              <a
                jsvalues=".path:name"
                jsdisplay="enabledMode == 'enabled'"
                onclick="handleEnablePlugin(this, false, true)"
                href="javascript:void(0);"
                i18n-content="disable"
                >DISABLE</a>
              <a
                jsvalues=".path:name"
                jsdisplay="enabledMode == 'disabledByUser'"
                onclick="handleEnablePlugin(this, true, true)"
                href="javascript:void(0);"
                i18n-content="enable"
                >ENABLE</a>
              <span
                jsdisplay="enabledMode == 'disabledByPolicy'"
                i18n-content="pluginCannotBeEnabledDueToPolicy"
                >CANNOT_ENABLE</span>
            </span>
          </div>
        </td>
        </tr>
        </table>
      </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>