| 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 InlineEditableItemList = options.InlineEditableItemList; | 6 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
| 7 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 7 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
| 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 8 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 settingLabel.textContent = this.settingForDisplay(); | 57 settingLabel.textContent = this.settingForDisplay(); |
| 58 settingLabel.className = 'exception-setting'; | 58 settingLabel.className = 'exception-setting'; |
| 59 settingLabel.setAttribute('displaymode', 'static'); | 59 settingLabel.setAttribute('displaymode', 'static'); |
| 60 this.contentElement.appendChild(settingLabel); | 60 this.contentElement.appendChild(settingLabel); |
| 61 this.settingLabel = settingLabel; | 61 this.settingLabel = settingLabel; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Setting select element for edit mode. | 64 // Setting select element for edit mode. |
| 65 var select = cr.doc.createElement('select'); | 65 var select = cr.doc.createElement('select'); |
| 66 var optionAllow = cr.doc.createElement('option'); | 66 var optionAllow = cr.doc.createElement('option'); |
| 67 optionAllow.textContent = templateData.allowException; | 67 optionAllow.textContent = loadTimeData.getString('allowException'); |
| 68 optionAllow.value = 'allow'; | 68 optionAllow.value = 'allow'; |
| 69 select.appendChild(optionAllow); | 69 select.appendChild(optionAllow); |
| 70 | 70 |
| 71 if (this.enableAskOption) { | 71 if (this.enableAskOption) { |
| 72 var optionAsk = cr.doc.createElement('option'); | 72 var optionAsk = cr.doc.createElement('option'); |
| 73 optionAsk.textContent = templateData.askException; | 73 optionAsk.textContent = loadTimeData.getString('askException'); |
| 74 optionAsk.value = 'ask'; | 74 optionAsk.value = 'ask'; |
| 75 select.appendChild(optionAsk); | 75 select.appendChild(optionAsk); |
| 76 } | 76 } |
| 77 | 77 |
| 78 if (this.contentType == 'cookies') { | 78 if (this.contentType == 'cookies') { |
| 79 var optionSession = cr.doc.createElement('option'); | 79 var optionSession = cr.doc.createElement('option'); |
| 80 optionSession.textContent = templateData.sessionException; | 80 optionSession.textContent = loadTimeData.getString('sessionException'); |
| 81 optionSession.value = 'session'; | 81 optionSession.value = 'session'; |
| 82 select.appendChild(optionSession); | 82 select.appendChild(optionSession); |
| 83 } | 83 } |
| 84 | 84 |
| 85 if (this.contentType != 'fullscreen') { | 85 if (this.contentType != 'fullscreen') { |
| 86 var optionBlock = cr.doc.createElement('option'); | 86 var optionBlock = cr.doc.createElement('option'); |
| 87 optionBlock.textContent = templateData.blockException; | 87 optionBlock.textContent = loadTimeData.getString('blockException'); |
| 88 optionBlock.value = 'block'; | 88 optionBlock.value = 'block'; |
| 89 select.appendChild(optionBlock); | 89 select.appendChild(optionBlock); |
| 90 } | 90 } |
| 91 | 91 |
| 92 this.contentElement.appendChild(select); | 92 this.contentElement.appendChild(select); |
| 93 select.className = 'exception-setting'; | 93 select.className = 'exception-setting'; |
| 94 if (this.pattern) | 94 if (this.pattern) |
| 95 select.setAttribute('displaymode', 'edit'); | 95 select.setAttribute('displaymode', 'edit'); |
| 96 | 96 |
| 97 // Used to track whether the URL pattern in the input is valid. | 97 // Used to track whether the URL pattern in the input is valid. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 this.dataItem['setting'] = setting; | 162 this.dataItem['setting'] = setting; |
| 163 }, | 163 }, |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * Gets a human-readable setting string. | 166 * Gets a human-readable setting string. |
| 167 * @type {string} | 167 * @type {string} |
| 168 */ | 168 */ |
| 169 settingForDisplay: function() { | 169 settingForDisplay: function() { |
| 170 var setting = this.setting; | 170 var setting = this.setting; |
| 171 if (setting == 'allow') | 171 if (setting == 'allow') |
| 172 return templateData.allowException; | 172 return loadTimeData.getString('allowException'); |
| 173 else if (setting == 'block') | 173 else if (setting == 'block') |
| 174 return templateData.blockException; | 174 return loadTimeData.getString('blockException'); |
| 175 else if (setting == 'ask') | 175 else if (setting == 'ask') |
| 176 return templateData.askException; | 176 return loadTimeData.getString('askException'); |
| 177 else if (setting == 'session') | 177 else if (setting == 'session') |
| 178 return templateData.sessionException; | 178 return loadTimeData.getString('sessionException'); |
| 179 }, | 179 }, |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * Update this list item to reflect whether the input is a valid pattern. | 182 * Update this list item to reflect whether the input is a valid pattern. |
| 183 * @param {boolean} valid Whether said pattern is valid in the context of | 183 * @param {boolean} valid Whether said pattern is valid in the context of |
| 184 * a content exception setting. | 184 * a content exception setting. |
| 185 */ | 185 */ |
| 186 setPatternValid: function(valid) { | 186 setPatternValid: function(valid) { |
| 187 if (valid || !this.input.value) | 187 if (valid || !this.input.value) |
| 188 this.input.setCustomValidity(''); | 188 this.input.setCustomValidity(''); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 292 |
| 293 return el; | 293 return el; |
| 294 } | 294 } |
| 295 | 295 |
| 296 ExceptionsAddRowListItem.prototype = { | 296 ExceptionsAddRowListItem.prototype = { |
| 297 __proto__: ExceptionsListItem.prototype, | 297 __proto__: ExceptionsListItem.prototype, |
| 298 | 298 |
| 299 decorate: function() { | 299 decorate: function() { |
| 300 ExceptionsListItem.prototype.decorate.call(this); | 300 ExceptionsListItem.prototype.decorate.call(this); |
| 301 | 301 |
| 302 this.input.placeholder = templateData.addNewExceptionInstructions; | 302 this.input.placeholder = |
| 303 loadTimeData.getString('addNewExceptionInstructions'); |
| 303 | 304 |
| 304 // Do we always want a default of allow? | 305 // Do we always want a default of allow? |
| 305 this.setting = 'allow'; | 306 this.setting = 'allow'; |
| 306 }, | 307 }, |
| 307 | 308 |
| 308 /** | 309 /** |
| 309 * Clear the <input> and let the placeholder text show again. | 310 * Clear the <input> and let the placeholder text show again. |
| 310 */ | 311 */ |
| 311 resetInput: function() { | 312 resetInput: function() { |
| 312 this.input.value = ''; | 313 this.input.value = ''; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 }; | 466 }; |
| 466 | 467 |
| 467 var OptionsPage = options.OptionsPage; | 468 var OptionsPage = options.OptionsPage; |
| 468 | 469 |
| 469 /** | 470 /** |
| 470 * Encapsulated handling of content settings list subpage. | 471 * Encapsulated handling of content settings list subpage. |
| 471 * @constructor | 472 * @constructor |
| 472 */ | 473 */ |
| 473 function ContentSettingsExceptionsArea() { | 474 function ContentSettingsExceptionsArea() { |
| 474 OptionsPage.call(this, 'contentExceptions', | 475 OptionsPage.call(this, 'contentExceptions', |
| 475 templateData.contentSettingsPageTabTitle, | 476 loadTimeData.getString('contentSettingsPageTabTitle'), |
| 476 'content-settings-exceptions-area'); | 477 'content-settings-exceptions-area'); |
| 477 } | 478 } |
| 478 | 479 |
| 479 cr.addSingletonGetter(ContentSettingsExceptionsArea); | 480 cr.addSingletonGetter(ContentSettingsExceptionsArea); |
| 480 | 481 |
| 481 ContentSettingsExceptionsArea.prototype = { | 482 ContentSettingsExceptionsArea.prototype = { |
| 482 __proto__: OptionsPage.prototype, | 483 __proto__: OptionsPage.prototype, |
| 483 | 484 |
| 484 initializePage: function() { | 485 initializePage: function() { |
| 485 OptionsPage.prototype.initializePage.call(this); | 486 OptionsPage.prototype.initializePage.call(this); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 497 $('content-settings-exceptions-overlay-confirm').onclick = | 498 $('content-settings-exceptions-overlay-confirm').onclick = |
| 498 OptionsPage.closeOverlay.bind(OptionsPage); | 499 OptionsPage.closeOverlay.bind(OptionsPage); |
| 499 }, | 500 }, |
| 500 | 501 |
| 501 /** | 502 /** |
| 502 * Shows one list and hides all others. | 503 * Shows one list and hides all others. |
| 503 * @param {string} type The content type. | 504 * @param {string} type The content type. |
| 504 */ | 505 */ |
| 505 showList: function(type) { | 506 showList: function(type) { |
| 506 var header = this.pageDiv.querySelector('h1'); | 507 var header = this.pageDiv.querySelector('h1'); |
| 507 header.textContent = templateData[type + '_header']; | 508 header.textContent = loadTimeData.getString(type + '_header'); |
| 508 | 509 |
| 509 var divs = this.pageDiv.querySelectorAll('div[contentType]'); | 510 var divs = this.pageDiv.querySelectorAll('div[contentType]'); |
| 510 for (var i = 0; i < divs.length; i++) { | 511 for (var i = 0; i < divs.length; i++) { |
| 511 if (divs[i].getAttribute('contentType') == type) | 512 if (divs[i].getAttribute('contentType') == type) |
| 512 divs[i].hidden = false; | 513 divs[i].hidden = false; |
| 513 else | 514 else |
| 514 divs[i].hidden = true; | 515 divs[i].hidden = true; |
| 515 } | 516 } |
| 516 }, | 517 }, |
| 517 | 518 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 545 } | 546 } |
| 546 }; | 547 }; |
| 547 | 548 |
| 548 return { | 549 return { |
| 549 ExceptionsListItem: ExceptionsListItem, | 550 ExceptionsListItem: ExceptionsListItem, |
| 550 ExceptionsAddRowListItem: ExceptionsAddRowListItem, | 551 ExceptionsAddRowListItem: ExceptionsAddRowListItem, |
| 551 ExceptionsList: ExceptionsList, | 552 ExceptionsList: ExceptionsList, |
| 552 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, | 553 ContentSettingsExceptionsArea: ContentSettingsExceptionsArea, |
| 553 }; | 554 }; |
| 554 }); | 555 }); |
| OLD | NEW |