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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 this.dataItem.source : null; | 198 this.dataItem.source : null; |
| 199 | 199 |
| 200 if (controlledBy) { | 200 if (controlledBy) { |
| 201 this.setAttribute('controlled-by', controlledBy); | 201 this.setAttribute('controlled-by', controlledBy); |
| 202 this.deletable = false; | 202 this.deletable = false; |
| 203 this.editable = false; | 203 this.editable = false; |
| 204 } | 204 } |
| 205 | 205 |
| 206 if (controlledBy == 'policy' || controlledBy == 'extension') { | 206 if (controlledBy == 'policy' || controlledBy == 'extension') { |
| 207 this.querySelector('.row-delete-button').hidden = true; | 207 this.querySelector('.row-delete-button').hidden = true; |
| 208 var indicator = new ControlledSettingIndicator(); | 208 var indicator = new ControlledSettingIndicator(); |
|
Bernhard Bauer
2016/05/19 14:20:40
This appears to duplicate the code you added. Coul
huangs
2016/05/20 15:16:46
Done.
| |
| 209 indicator.setAttribute('content-exception', this.contentType); | 209 indicator.setAttribute('content-exception', this.contentType); |
| 210 // Create a synthetic pref change event decorated as | 210 // Create a synthetic pref change event decorated as |
| 211 // CoreOptionsHandler::CreateValueForPref() does. | 211 // CoreOptionsHandler::CreateValueForPref() does. |
| 212 var event = new Event(this.contentType); | 212 var event = new Event(this.contentType); |
| 213 event.value = { controlledBy: controlledBy }; | 213 event.value = { controlledBy: controlledBy }; |
| 214 indicator.handlePrefChange(event); | 214 indicator.handlePrefChange(event); |
| 215 this.appendChild(indicator); | 215 this.appendChild(indicator); |
| 216 } | 216 } |
| 217 | 217 |
| 218 // If the exception comes from a hosted app, display the name and the | 218 // If the exception comes from a hosted app, display the name and the |
| (...skipping 119 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(); | |
| 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); | |
|
Bernhard Bauer
2016/05/18 09:55:13
What happens if this is called multiple times (e.g
huangs
2016/05/18 13:52:49
If content settings change then the entire list ge
| |
| 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') { | |
|
Bernhard Bauer
2016/05/18 09:55:13
Doesn't this mean that any preference rule is mark
huangs
2016/05/18 13:52:49
The "overruled" concept only applies to Policy Def
Bernhard Bauer
2016/05/19 14:20:40
I don't really want to get into a product discussi
huangs
2016/05/20 15:16:46
I think treating default as "super wildcard except
Bernhard Bauer
2016/05/23 13:34:11
I'm not sure what you are trying to say. This UI w
huangs
2016/05/24 05:02:00
By "bug" do you mean:
(1) Code is not doing what
Bernhard Bauer
2016/05/24 16:54:34
Yes, that's what I mean.
| |
| 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 |