Chromium Code Reviews| OLD | NEW |
|---|---|
| 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; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 */ | 338 */ |
| 339 updateEditables: function() { | 339 updateEditables: function() { |
| 340 this.resetInput(); | 340 this.resetInput(); |
| 341 | 341 |
| 342 var settingOption = | 342 var settingOption = |
| 343 this.select.querySelector('[value=\'' + this.setting + '\']'); | 343 this.select.querySelector('[value=\'' + this.setting + '\']'); |
| 344 if (settingOption) | 344 if (settingOption) |
| 345 settingOption.selected = true; | 345 settingOption.selected = true; |
| 346 }, | 346 }, |
| 347 | 347 |
| 348 /** | |
| 349 * Updates UI to indicate that the exception was overruled by a source. | |
| 350 * | |
| 351 * @param {string} overruledBy The source that overrules the exception. | |
| 352 */ | |
| 353 setOverruledBy: function(overruledBy) { | |
| 354 this.classList.toggle('overruled', !!overruledBy); | |
| 355 var textElt = this.querySelector('.exception-pattern .static-text'); | |
| 356 textElt.setAttribute('title', | |
| 357 loadTimeData.getString('exceptionDisabledByPolicy')); | |
| 358 | |
| 359 var indicator = new ControlledSettingIndicator(); | |
|
Bernhard Bauer
2016/05/19 14:20:41
This duplicates a lot of code in lines 208ff. Coul
huangs
2016/05/20 15:16:46
Done; extracted to appendIndicatorElement().
Yeah
| |
| 360 indicator.setAttribute('content-exception', this.contentType); | |
| 361 // Create a synthetic pref change event decorated as | |
| 362 // CoreOptionsHandler::CreateValueForPref() does. | |
| 363 var event = new Event(this.contentType); | |
| 364 event.value = { controlledBy: overruledBy }; | |
| 365 indicator.handlePrefChange(event); | |
| 366 this.appendChild(indicator); | |
| 367 }, | |
| 368 | |
| 348 /** @override */ | 369 /** @override */ |
| 349 get currentInputIsValid() { | 370 get currentInputIsValid() { |
| 350 return this.inputValidityKnown && this.inputIsValid; | 371 return this.inputValidityKnown && this.inputIsValid; |
| 351 }, | 372 }, |
| 352 | 373 |
| 353 /** @override */ | 374 /** @override */ |
| 354 get hasBeenEdited() { | 375 get hasBeenEdited() { |
| 355 var livePattern = this.input.value; | 376 var livePattern = this.input.value; |
| 356 var liveSetting = this.select.value; | 377 var liveSetting = this.select.value; |
| 357 return livePattern != this.pattern || liveSetting != this.setting; | 378 return livePattern != this.pattern || liveSetting != this.setting; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 entry); | 534 entry); |
| 514 } else { | 535 } else { |
| 515 var addRowItem = new ExceptionsAddRowListItem(this.contentType, | 536 var addRowItem = new ExceptionsAddRowListItem(this.contentType, |
| 516 this.mode); | 537 this.mode); |
| 517 addRowItem.deletable = false; | 538 addRowItem.deletable = false; |
| 518 return addRowItem; | 539 return addRowItem; |
| 519 } | 540 } |
| 520 }, | 541 }, |
| 521 | 542 |
| 522 /** | 543 /** |
| 544 * Updates UI to indicate that user exceptions were overruled by a source. | |
| 545 * | |
| 546 * @param {string} overruledBy The source that overrules user exceptions. | |
| 547 */ | |
| 548 setOverruledBy: function(overruledBy) { | |
| 549 for (var index = 0; index < this.dataModel.length; ++index) { | |
| 550 var item = this.getListItemByIndex(index); | |
| 551 if (item.dataItem.source == 'preference') { | |
| 552 item.setOverruledBy(overruledBy); | |
| 553 } | |
| 554 } | |
| 555 }, | |
| 556 | |
| 557 /** | |
| 523 * Sets the exceptions in the js model. | 558 * Sets the exceptions in the js model. |
| 524 * | 559 * |
| 525 * @param {Array<options.Exception>} entries A list of dictionaries of | 560 * @param {Array<options.Exception>} entries A list of dictionaries of |
| 526 * values, each dictionary represents an exception. | 561 * values, each dictionary represents an exception. |
| 527 */ | 562 */ |
| 528 setExceptions: function(entries) { | 563 setExceptions: function(entries) { |
| 529 var deleteCount = this.dataModel.length; | 564 var deleteCount = this.dataModel.length; |
| 530 | 565 |
| 531 if (this.isEditable()) { | 566 if (this.isEditable()) { |
| 532 // We don't want to remove the Add New Exception row. | 567 // We don't want to remove the Add New Exception row. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 } | 731 } |
| 697 }; | 732 }; |
| 698 | 733 |
| 699 return { | 734 return { |
| 700 ExceptionsListItem: ExceptionsListItem, | 735 ExceptionsListItem: ExceptionsListItem, |
| 701 ExceptionsAddRowListItem: ExceptionsAddRowListItem, | 736 ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
| 702 ExceptionsList: ExceptionsList, | 737 ExceptionsList: ExceptionsList, |
| 703 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, | 738 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
| 704 }; | 739 }; |
| 705 }); | 740 }); |
| OLD | NEW |