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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 this.dataItem.source : null; | 171 this.dataItem.source : null; |
172 | 172 |
173 if (controlledBy) { | 173 if (controlledBy) { |
174 this.setAttribute('controlled-by', controlledBy); | 174 this.setAttribute('controlled-by', controlledBy); |
175 this.deletable = false; | 175 this.deletable = false; |
176 this.editable = false; | 176 this.editable = false; |
177 } | 177 } |
178 | 178 |
179 if (controlledBy == 'policy' || controlledBy == 'extension') { | 179 if (controlledBy == 'policy' || controlledBy == 'extension') { |
180 this.querySelector('.row-delete-button').hidden = true; | 180 this.querySelector('.row-delete-button').hidden = true; |
181 var indicator = ControlledSettingIndicator(); | 181 var indicator = new ControlledSettingIndicator(); |
182 indicator.setAttribute('content-exception', this.contentType); | 182 indicator.setAttribute('content-exception', this.contentType); |
183 // Create a synthetic pref change event decorated as | 183 // Create a synthetic pref change event decorated as |
184 // CoreOptionsHandler::CreateValueForPref() does. | 184 // CoreOptionsHandler::CreateValueForPref() does. |
185 var event = new Event(this.contentType); | 185 var event = new Event(this.contentType); |
186 event.value = { controlledBy: controlledBy }; | 186 event.value = { controlledBy: controlledBy }; |
187 indicator.handlePrefChange(event); | 187 indicator.handlePrefChange(event); |
188 this.appendChild(indicator); | 188 this.appendChild(indicator); |
189 } | 189 } |
190 | 190 |
191 // If the exception comes from a hosted app, display the name and the | 191 // If the exception comes from a hosted app, display the name and the |
(...skipping 28 matching lines...) Expand all Loading... | |
220 }, | 220 }, |
221 | 221 |
222 /** | 222 /** |
223 * The pattern (e.g., a URL) for the exception. | 223 * The pattern (e.g., a URL) for the exception. |
224 * | 224 * |
225 * @type {string} | 225 * @type {string} |
226 */ | 226 */ |
227 get pattern() { | 227 get pattern() { |
228 if (!this.isEmbeddingRule()) { | 228 if (!this.isEmbeddingRule()) { |
229 return this.dataItem.origin; | 229 return this.dataItem.origin; |
230 } else { | 230 } else { |
Dan Beam
2014/09/06 02:22:36
nit:
if (!this.isEmbeddingRule())
return th
Vitaly Pavlenko
2014/09/06 22:54:08
Done.
| |
231 return loadTimeData.getStringF('embeddedOnHost', | 231 return loadTimeData.getStringF('embeddedOnHost', |
232 this.dataItem.embeddingOrigin); | 232 this.dataItem.embeddingOrigin); |
233 } | 233 } |
234 | |
235 return this.dataItem.displayPattern; | |
236 }, | 234 }, |
237 set pattern(pattern) { | 235 set pattern(pattern) { |
238 if (!this.editable) | 236 if (!this.editable) |
239 console.error('Tried to change uneditable pattern'); | 237 console.error('Tried to change uneditable pattern'); |
240 | 238 |
241 this.dataItem.displayPattern = pattern; | 239 this.dataItem.displayPattern = pattern; |
242 }, | 240 }, |
243 | 241 |
244 /** | 242 /** |
245 * The setting (allow/block) for the exception. | 243 * The setting (allow/block) for the exception. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 /** | 391 /** |
394 * Creates a new list item for the Add New Item row, which doesn't represent | 392 * Creates a new list item for the Add New Item row, which doesn't represent |
395 * an actual entry in the exceptions list but allows the user to add new | 393 * an actual entry in the exceptions list but allows the user to add new |
396 * exceptions. | 394 * exceptions. |
397 * | 395 * |
398 * @param {string} contentType The type of the list. | 396 * @param {string} contentType The type of the list. |
399 * @param {string} mode The browser mode, 'otr' or 'normal'. | 397 * @param {string} mode The browser mode, 'otr' or 'normal'. |
400 * @param {boolean} enableAskOption Whether to show an 'ask every time' option | 398 * @param {boolean} enableAskOption Whether to show an 'ask every time' option |
401 * in the select. | 399 * in the select. |
402 * @constructor | 400 * @constructor |
403 * @extends {cr.ui.ExceptionsListItem} | 401 * @extends {options.contentSettings.ExceptionsListItem} |
404 */ | 402 */ |
405 function ExceptionsAddRowListItem(contentType, mode, enableAskOption) { | 403 function ExceptionsAddRowListItem(contentType, mode, enableAskOption) { |
406 var el = cr.doc.createElement('div'); | 404 var el = cr.doc.createElement('div'); |
407 el.mode = mode; | 405 el.mode = mode; |
408 el.contentType = contentType; | 406 el.contentType = contentType; |
409 el.enableAskOption = enableAskOption; | 407 el.enableAskOption = enableAskOption; |
410 el.dataItem = []; | 408 el.dataItem = []; |
411 el.__proto__ = ExceptionsAddRowListItem.prototype; | 409 el.__proto__ = ExceptionsAddRowListItem.prototype; |
412 el.decorate(); | 410 el.decorate(); |
413 | 411 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 var args = [0, deleteCount]; | 524 var args = [0, deleteCount]; |
527 args.push.apply(args, entries); | 525 args.push.apply(args, entries); |
528 this.dataModel.splice.apply(this.dataModel, args); | 526 this.dataModel.splice.apply(this.dataModel, args); |
529 }, | 527 }, |
530 | 528 |
531 /** | 529 /** |
532 * The browser has finished checking a pattern for validity. Update the list | 530 * The browser has finished checking a pattern for validity. Update the list |
533 * item to reflect this. | 531 * item to reflect this. |
534 * | 532 * |
535 * @param {string} pattern The pattern. | 533 * @param {string} pattern The pattern. |
536 * @param {bool} valid Whether said pattern is valid in the context of a | 534 * @param {boolean} valid Whether said pattern is valid in the context of a |
537 * content exception setting. | 535 * content exception setting. |
538 */ | 536 */ |
539 patternValidityCheckComplete: function(pattern, valid) { | 537 patternValidityCheckComplete: function(pattern, valid) { |
540 var listItems = this.items; | 538 var listItems = this.items; |
541 for (var i = 0; i < listItems.length; i++) { | 539 for (var i = 0; i < listItems.length; i++) { |
542 var listItem = listItems[i]; | 540 var listItem = listItems[i]; |
543 // Don't do anything for messages for the item if it is not the intended | 541 // Don't do anything for messages for the item if it is not the intended |
544 // recipient, or if the response is stale (i.e. the input value has | 542 // recipient, or if the response is stale (i.e. the input value has |
545 // changed since we sent the request to analyze it). | 543 // changed since we sent the request to analyze it). |
546 if (pattern == listItem.input.value) | 544 if (pattern == listItem.input.value) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
589 }, | 587 }, |
590 }; | 588 }; |
591 | 589 |
592 var Page = cr.ui.pageManager.Page; | 590 var Page = cr.ui.pageManager.Page; |
593 var PageManager = cr.ui.pageManager.PageManager; | 591 var PageManager = cr.ui.pageManager.PageManager; |
594 | 592 |
595 /** | 593 /** |
596 * Encapsulated handling of content settings list subpage. | 594 * Encapsulated handling of content settings list subpage. |
597 * | 595 * |
598 * @constructor | 596 * @constructor |
597 * @extends {cr.ui.pageManager.Page} | |
599 */ | 598 */ |
600 function ContentSettingsExceptionsArea() { | 599 function ContentSettingsExceptionsArea() { |
601 Page.call(this, 'contentExceptions', | 600 Page.call(this, 'contentExceptions', |
602 loadTimeData.getString('contentSettingsPageTabTitle'), | 601 loadTimeData.getString('contentSettingsPageTabTitle'), |
603 'content-settings-exceptions-area'); | 602 'content-settings-exceptions-area'); |
604 } | 603 } |
605 | 604 |
606 cr.addSingletonGetter(ContentSettingsExceptionsArea); | 605 cr.addSingletonGetter(ContentSettingsExceptionsArea); |
607 | 606 |
608 ContentSettingsExceptionsArea.prototype = { | 607 ContentSettingsExceptionsArea.prototype = { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 } | 684 } |
686 }; | 685 }; |
687 | 686 |
688 return { | 687 return { |
689 ExceptionsListItem: ExceptionsListItem, | 688 ExceptionsListItem: ExceptionsListItem, |
690 ExceptionsAddRowListItem: ExceptionsAddRowListItem, | 689 ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
691 ExceptionsList: ExceptionsList, | 690 ExceptionsList: ExceptionsList, |
692 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, | 691 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
693 }; | 692 }; |
694 }); | 693 }); |
OLD | NEW |