summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/extensions_ui.html
blob: 0c9273b1b8c6f678d1036a927e2e7b497a04b690 (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
<!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%;
}

</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]);
}

/**
 * Handles the "Load extension..." button being pressed.
 */
function loadExtension() {
  chrome.send('load', []);
}

/**
 * Handles the "Pack extension..." button being pressed.
 */
function packExtension() {
  chrome.send('pack', []);
}

/**
 * Handles the "Update extensions now" button being pressed.
 */
function autoUpdate() {
  chrome.send('autoupdate', []);
}

</script>
</head>
<body onload="requestExtensionsData();">
  <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="packExtension()">Pack extension...</button><br />
              <button onclick="autoUpdate()">Update extensions now</button>
            </div>
          </td>
        </tr>
      </table>

    </div> <!-- /outside -->
  </body>
</html>