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
|
<!DOCTYPE HTML>
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
<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;
padding-left: 0;
padding-top: 20px;
position: relative;
box-sizing: border-box;
}
html[dir=rtl] #header {
padding-right: 0;
}
#header h1 {
background: url('../../app/theme/flags_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/flags_section.png') right no-repeat;
padding-right: 95px;
padding-left: 0;
}
h1 {
font-size: 156%;
font-weight: bold;
padding: 0;
margin: 0;
}
#blurb-container {
padding-bottom: 1.5em;
font-size: 120%;
}
#blurb-warning {
color: red;
font-weight: bold;
}
div.content {
font-size: 88%;
margin-top: 5px;
}
.section-header {
background: #ebeff9;
border-top: 1px solid #b5c7de;
font-size: 99%;
padding-bottom: 2px;
padding-left: 5px;
padding-top: 3px;
width: 100%;
}
html[dir=rtl] .section-header {
padding-right: 5px;
padding-left: 0;
}
.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 {
padding-right: 5px;
}
html[dir=rtl] #top {
padding-left: 5px;
padding-right: 0;
}
.experiment-enabled > td {
padding-bottom: 4px;
padding-top: 5px;
}
.experiment {
border-bottom: 1px solid #cdcdcd;
}
/* Indent the text related to each experiment. */
.experiment-text {
padding-left: 5px;
}
html[dir=rtl] .experiment-text {
padding-right: 5px;
padding-left: 0;
}
.experiment-name {
font-weight: bold;
}
.no-experiments {
margin: 6em 0 0;
text-align: center;
font-size: 1.2em;
}
/* Match the indentation of .experiment-text. */
.experiment-actions {
padding-left: 5px;
margin-top: 0.2em;
margin-bottom: 0.2em;
}
html[dir=rtl] .experiment-actions {
padding-right: 5px;
padding-left: 0;
}
div.needs-restart {
padding-top: 10px;
padding-left: 5px;
}
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 flagsExperimentsDataFormat = {
'flagsExperiments': [
{
'internal_name': 'Experiment ID string',
'name': 'Experiment Name',
'description': 'description',
'enabled': true,
/* choices is only set if the experiment has multiple values */
'choices': [
{
'internal_name': 'Experiment ID string',
'description': 'description',
'selected': true
}
]
}
],
'needsRestart': false
};
/**
* Takes the |flagsExperimentsData| input argument which represents data about
* the currently available experiments and populates the html jstemplate
* with that data. It expects an object structure like the above.
* @param {Object} flagsExperimentsData Information about available experiments
*/
function renderTemplate(flagsExperimentsData) {
// This is the javascript code that processes the template:
var input = new JsEvalContext(flagsExperimentsData);
var output = document.getElementById('flagsExperimentTemplate');
jstProcess(input, output);
}
/**
* Asks the C++ FlagsDOMHandler to get details about the available experiments
* and return detailed data about the configuration. The FlagsDOMHandler
* should reply to returnFlagsExperiments() (below).
*/
function requestFlagsExperimentsData() {
chrome.send('requestFlagsExperiments', []);
}
/**
* Asks the C++ FlagsDOMHandler to restart the browser (restoring tabs).
*/
function restartBrowser() {
chrome.send('restartBrowser', []);
}
/**
* Called by the dom_ui to re-populate the page with data representing the
* current state of installed experiments.
*/
function returnFlagsExperiments(flagsExperimentsData){
var bodyContainer = document.getElementById('body-container');
renderTemplate(flagsExperimentsData);
bodyContainer.style.visibility = 'visible';
}
/**
* Handles a 'enable' or 'disable' button getting clicked.
*/
function handleEnableExperiment(node, enable) {
// Tell the C++ FlagsDOMHandler to enable/disable the experiment.
chrome.send('enableFlagsExperiment', [String(node.internal_name),
String(enable)]);
requestFlagsExperimentsData();
}
/**
* Invoked when the selection of a multi-value choice is changed to the
* specified index.
*/
function handleSelectChoiceExperiment(node, index) {
// Tell the C++ FlagsDOMHandler to enable the selected choice.
chrome.send('enableFlagsExperiment',
[String(node.internal_name) + "@" + index, "true"]);
requestFlagsExperimentsData();
}
// Get data and have it displayed upon loading.
document.addEventListener('DOMContentLoaded', requestFlagsExperimentsData);
</script>
</head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div id="body-container" style="visibility:hidden">
<div id="header"><h1 i18n-content="flagsLongTitle">TITLE</h1></div>
<div id="blurb-container">
<span id="blurb-warning" i18n-content="flagsWarningHeader">WARNING</span>
<span i18n-content="flagsBlurb">WARNING TEXT</span>
</div>
<div id="flagsExperimentTemplate">
<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="flagsTableTitle"
>TITLE</span>
</td>
</tr></table>
</div>
</div>
</div>
<div class="content">
<div class="experiment-name no-experiments"
jsdisplay="flagsExperiments.length === 0">
<div i18n-content="flagsNoExperimentsAvailable"
>NO_EXPERIMENTS_ARE_AVAILABLE</div>
</div>
<div jsdisplay="flagsExperiments.length > 0">
<div class="experiment" jsselect="flagsExperiments">
<table width="100%" cellpadding="2" cellspacing="0">
<tr class="experiment-enabled">
<td valign="top">
<div class="experiment-text">
<div>
<span class="experiment-name" dir="ltr"
jscontent="name">NAME</span>
<div>
<span dir="ltr" jsvalues=".innerHTML:description">
</div>
<div jsdisplay="choices && choices.length > 0">
<select jsvalues=".internal_name:internal_name;.disabled:!enabled"
onchange="handleSelectChoiceExperiment(this, this.selectedIndex)">
<option jsvalues=".selected:selected"
jsselect="choices"
jscontent="description">NAME
</option>
</select>
</div>
</div>
</div>
<div class="experiment-actions">
<span>
<a
jsvalues=".internal_name:internal_name"
jsdisplay="enabled"
onclick="handleEnableExperiment(this, false)"
href="javascript:void(0);"
i18n-content="disable"
>DISABLE</a>
<a
jsvalues=".internal_name:internal_name"
jsdisplay="!enabled"
onclick="handleEnableExperiment(this, true)"
href="javascript:void(0);"
i18n-content="enable"
>ENABLE</a>
</span>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="needs-restart" jsdisplay="needsRestart">
<div i18n-content="flagsRestartNotice">NEEDS_RESTART</div>
<button type="button"
onclick="restartBrowser();"
i18n-content="flagsRestartButton">RESTART</button>
</div>
</div>
</div>
</div>
</body>
</html>
|