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

Side by Side Diff: chrome/browser/resources/options/content_settings_exceptions_area.js

Issue 796543002: Plugin Power Saver: Implement option in Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restore 'ask' to list of allowed settings for policy settings Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options.contentSettings', function() { 5 cr.define('options.contentSettings', function() {
6 /** @const */ var ControlledSettingIndicator = 6 /** @const */ var ControlledSettingIndicator =
7 options.ControlledSettingIndicator; 7 options.ControlledSettingIndicator;
8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList;
9 /** @const */ var InlineEditableItem = options.InlineEditableItem; 9 /** @const */ var InlineEditableItem = options.InlineEditableItem;
10 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; 10 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel;
11 11
12 /** 12 /**
13 * Creates a new exceptions list item. 13 * Creates a new exceptions list item.
14 * 14 *
15 * @param {string} contentType The type of the list. 15 * @param {string} contentType The type of the list.
16 * @param {string} mode The browser mode, 'otr' or 'normal'. 16 * @param {string} mode The browser mode, 'otr' or 'normal'.
17 * @param {boolean} enableAskOption Whether to show an 'ask every time'
18 * option in the select.
19 * @param {Object} exception A dictionary that contains the data of the 17 * @param {Object} exception A dictionary that contains the data of the
20 * exception. 18 * exception.
21 * @constructor 19 * @constructor
22 * @extends {options.InlineEditableItem} 20 * @extends {options.InlineEditableItem}
23 */ 21 */
24 function ExceptionsListItem(contentType, mode, enableAskOption, exception) { 22 function ExceptionsListItem(contentType, mode, exception) {
25 var el = cr.doc.createElement('div'); 23 var el = cr.doc.createElement('div');
26 el.mode = mode; 24 el.mode = mode;
27 el.contentType = contentType; 25 el.contentType = contentType;
28 el.enableAskOption = enableAskOption;
29 el.dataItem = exception; 26 el.dataItem = exception;
30 el.__proto__ = ExceptionsListItem.prototype; 27 el.__proto__ = ExceptionsListItem.prototype;
31 el.decorate(); 28 el.decorate();
32 29
33 return el; 30 return el;
34 } 31 }
35 32
36 ExceptionsListItem.prototype = { 33 ExceptionsListItem.prototype = {
37 __proto__: InlineEditableItem.prototype, 34 __proto__: InlineEditableItem.prototype,
38 35
(...skipping 25 matching lines...) Expand all
64 this.settingLabel = settingLabel; 61 this.settingLabel = settingLabel;
65 } 62 }
66 63
67 // Setting select element for edit mode. 64 // Setting select element for edit mode.
68 var select = cr.doc.createElement('select'); 65 var select = cr.doc.createElement('select');
69 var optionAllow = cr.doc.createElement('option'); 66 var optionAllow = cr.doc.createElement('option');
70 optionAllow.textContent = loadTimeData.getString('allowException'); 67 optionAllow.textContent = loadTimeData.getString('allowException');
71 optionAllow.value = 'allow'; 68 optionAllow.value = 'allow';
72 select.appendChild(optionAllow); 69 select.appendChild(optionAllow);
73 70
74 if (this.enableAskOption) { 71 if (this.contentType == 'plugins') {
75 var optionAsk = cr.doc.createElement('option'); 72 var optionDetect = cr.doc.createElement('option');
76 optionAsk.textContent = loadTimeData.getString('askException'); 73 optionDetect.textContent = loadTimeData.getString('detectException');
77 optionAsk.value = 'ask'; 74 optionDetect.value = 'detect';
78 select.appendChild(optionAsk); 75 select.appendChild(optionDetect);
79 } 76 }
80 77
81 if (this.contentType == 'cookies') { 78 if (this.contentType == 'cookies') {
82 var optionSession = cr.doc.createElement('option'); 79 var optionSession = cr.doc.createElement('option');
83 optionSession.textContent = loadTimeData.getString('sessionException'); 80 optionSession.textContent = loadTimeData.getString('sessionException');
84 optionSession.value = 'session'; 81 optionSession.value = 'session';
85 select.appendChild(optionSession); 82 select.appendChild(optionSession);
86 } 83 }
87 84
88 if (this.contentType != 'fullscreen') { 85 if (this.contentType != 'fullscreen') {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 */ 274 */
278 getDisplayStringForSetting: function(setting) { 275 getDisplayStringForSetting: function(setting) {
279 if (setting == 'allow') 276 if (setting == 'allow')
280 return loadTimeData.getString('allowException'); 277 return loadTimeData.getString('allowException');
281 else if (setting == 'block') 278 else if (setting == 'block')
282 return loadTimeData.getString('blockException'); 279 return loadTimeData.getString('blockException');
283 else if (setting == 'ask') 280 else if (setting == 'ask')
284 return loadTimeData.getString('askException'); 281 return loadTimeData.getString('askException');
285 else if (setting == 'session') 282 else if (setting == 'session')
286 return loadTimeData.getString('sessionException'); 283 return loadTimeData.getString('sessionException');
284 else if (setting == 'detect')
285 return loadTimeData.getString('detectException');
287 else if (setting == 'default') 286 else if (setting == 'default')
288 return ''; 287 return '';
289 288
290 console.error('Unknown setting: [' + setting + ']'); 289 console.error('Unknown setting: [' + setting + ']');
291 return ''; 290 return '';
292 }, 291 },
293 292
294 /** 293 /**
295 * Update this list item to reflect whether the input is a valid pattern. 294 * Update this list item to reflect whether the input is a valid pattern.
296 * 295 *
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 }, 386 },
388 }; 387 };
389 388
390 /** 389 /**
391 * Creates a new list item for the Add New Item row, which doesn't represent 390 * Creates a new list item for the Add New Item row, which doesn't represent
392 * an actual entry in the exceptions list but allows the user to add new 391 * an actual entry in the exceptions list but allows the user to add new
393 * exceptions. 392 * exceptions.
394 * 393 *
395 * @param {string} contentType The type of the list. 394 * @param {string} contentType The type of the list.
396 * @param {string} mode The browser mode, 'otr' or 'normal'. 395 * @param {string} mode The browser mode, 'otr' or 'normal'.
397 * @param {boolean} enableAskOption Whether to show an 'ask every time' option
398 * in the select.
399 * @constructor 396 * @constructor
400 * @extends {options.contentSettings.ExceptionsListItem} 397 * @extends {options.contentSettings.ExceptionsListItem}
401 */ 398 */
402 function ExceptionsAddRowListItem(contentType, mode, enableAskOption) { 399 function ExceptionsAddRowListItem(contentType, mode) {
403 var el = cr.doc.createElement('div'); 400 var el = cr.doc.createElement('div');
404 el.mode = mode; 401 el.mode = mode;
405 el.contentType = contentType; 402 el.contentType = contentType;
406 el.enableAskOption = enableAskOption;
407 el.dataItem = []; 403 el.dataItem = [];
408 el.__proto__ = ExceptionsAddRowListItem.prototype; 404 el.__proto__ = ExceptionsAddRowListItem.prototype;
409 el.decorate(); 405 el.decorate();
410 406
411 return el; 407 return el;
412 } 408 }
413 409
414 ExceptionsAddRowListItem.prototype = { 410 ExceptionsAddRowListItem.prototype = {
415 __proto__: ExceptionsListItem.prototype, 411 __proto__: ExceptionsListItem.prototype,
416 412
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 467
472 for (var parentNode = this.parentNode; parentNode; 468 for (var parentNode = this.parentNode; parentNode;
473 parentNode = parentNode.parentNode) { 469 parentNode = parentNode.parentNode) {
474 if (parentNode.hasAttribute('contentType')) { 470 if (parentNode.hasAttribute('contentType')) {
475 this.contentType = parentNode.getAttribute('contentType'); 471 this.contentType = parentNode.getAttribute('contentType');
476 break; 472 break;
477 } 473 }
478 } 474 }
479 475
480 this.mode = this.getAttribute('mode'); 476 this.mode = this.getAttribute('mode');
481
482 // Whether the exceptions in this list allow an 'Ask every time' option.
483 this.enableAskOption = this.contentType == 'plugins';
484
485 this.autoExpands = true; 477 this.autoExpands = true;
486 this.reset(); 478 this.reset();
487 }, 479 },
488 480
489 /** 481 /**
490 * Creates an item to go in the list. 482 * Creates an item to go in the list.
491 * 483 *
492 * @param {Object} entry The element from the data model for this row. 484 * @param {Object} entry The element from the data model for this row.
493 */ 485 */
494 createItem: function(entry) { 486 createItem: function(entry) {
495 if (entry) { 487 if (entry) {
496 return new ExceptionsListItem(this.contentType, 488 return new ExceptionsListItem(this.contentType,
497 this.mode, 489 this.mode,
498 this.enableAskOption,
499 entry); 490 entry);
500 } else { 491 } else {
501 var addRowItem = new ExceptionsAddRowListItem(this.contentType, 492 var addRowItem = new ExceptionsAddRowListItem(this.contentType,
502 this.mode, 493 this.mode);
503 this.enableAskOption);
504 addRowItem.deletable = false; 494 addRowItem.deletable = false;
505 return addRowItem; 495 return addRowItem;
506 } 496 }
507 }, 497 },
508 498
509 /** 499 /**
510 * Sets the exceptions in the js model. 500 * Sets the exceptions in the js model.
511 * 501 *
512 * @param {Array.<options.Exception>} entries A list of dictionaries of 502 * @param {Array.<options.Exception>} entries A list of dictionaries of
513 * values, each dictionary represents an exception. 503 * values, each dictionary represents an exception.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 669 }
680 }; 670 };
681 671
682 return { 672 return {
683 ExceptionsListItem: ExceptionsListItem, 673 ExceptionsListItem: ExceptionsListItem,
684 ExceptionsAddRowListItem: ExceptionsAddRowListItem, 674 ExceptionsAddRowListItem: ExceptionsAddRowListItem,
685 ExceptionsList: ExceptionsList, 675 ExceptionsList: ExceptionsList,
686 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, 676 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea,
687 }; 677 };
688 }); 678 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698