diff options
Diffstat (limited to 'chromium/chrome/browser/resources/options/content_settings.js')
-rw-r--r-- | chromium/chrome/browser/resources/options/content_settings.js | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/chromium/chrome/browser/resources/options/content_settings.js b/chromium/chrome/browser/resources/options/content_settings.js index 160d36f6d79..44ae39f1f8a 100644 --- a/chromium/chrome/browser/resources/options/content_settings.js +++ b/chromium/chrome/browser/resources/options/content_settings.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -if (!loadTimeData.getBoolean('newContentSettings')) { - cr.define('options', function() { /** @const */ var OptionsPage = options.OptionsPage; @@ -39,17 +37,11 @@ cr.define('options', function() { // history so back/forward and tab restore works. var hash = event.currentTarget.getAttribute('contentType'); var url = page.name + '#' + hash; - window.history.pushState({pageName: page.name}, - page.title, - '/' + url); + uber.pushState({pageName: page.name}, url); - // Navigate after the history has been replaced in order to have the - // correct hash loaded. + // Navigate after the local history has been replaced in order to have + // the correct hash loaded. OptionsPage.showPageByName('contentExceptions', false); - - uber.invokeMethodOnParent('setPath', {path: url}); - uber.invokeMethodOnParent('setTitle', - {title: loadTimeData.getString(hash + 'TabTitle')}); }; } @@ -60,10 +52,6 @@ cr.define('options', function() { }; } - $('manage-galleries-button').onclick = function(event) { - OptionsPage.navigateToPage('manageGalleries'); - }; - if (cr.isChromeOS) UIAccountTweaks.applyGuestModeVisibility(document); @@ -121,8 +109,9 @@ cr.define('options', function() { value: dict[group].value, controlledBy: controlledBy, }; - for (var i = 0; i < indicators.length; i++) + for (var i = 0; i < indicators.length; i++) { indicators[i].handlePrefChange(event); + } } }; @@ -170,31 +159,36 @@ cr.define('options', function() { /** * Initializes an exceptions list. * @param {string} type The content type that we are setting exceptions for. - * @param {Array} list An array of pairs, where the first element of each pair - * is the filter string, and the second is the setting (allow/block). + * @param {Array} exceptions An array of pairs, where the first element of + * each pair is the filter string, and the second is the setting + * (allow/block). */ - ContentSettings.setExceptions = function(type, list) { - var exceptionsList = - document.querySelector('div[contentType=' + type + ']' + - ' list[mode=normal]'); - exceptionsList.setExceptions(list); + ContentSettings.setExceptions = function(type, exceptions) { + this.getExceptionsList(type, 'normal').setExceptions(exceptions); }; - ContentSettings.setHandlers = function(list) { - $('handlers-list').setHandlers(list); + ContentSettings.setHandlers = function(handlers) { + $('handlers-list').setHandlers(handlers); }; - ContentSettings.setIgnoredHandlers = function(list) { - $('ignored-handlers-list').setHandlers(list); + ContentSettings.setIgnoredHandlers = function(ignoredHandlers) { + $('ignored-handlers-list').setHandlers(ignoredHandlers); }; - ContentSettings.setOTRExceptions = function(type, list) { - var exceptionsList = - document.querySelector('div[contentType=' + type + ']' + - ' list[mode=otr]'); - + ContentSettings.setOTRExceptions = function(type, otrExceptions) { + var exceptionsList = this.getExceptionsList(type, 'otr'); exceptionsList.parentNode.hidden = false; - exceptionsList.setExceptions(list); + exceptionsList.setExceptions(otrExceptions); + }; + + /** + * @param {string} type The type of exceptions (e.g. "location") to get. + * @param {string} mode The mode of the desired exceptions list (e.g. otr). + * @return {?ExceptionsList} The corresponding exceptions list or null. + */ + ContentSettings.getExceptionsList = function(type, mode) { + return document.querySelector( + 'div[contentType=' + type + '] list[mode=' + mode + ']'); }; /** @@ -208,10 +202,8 @@ cr.define('options', function() { */ ContentSettings.patternValidityCheckComplete = function(type, mode, pattern, valid) { - var exceptionsList = - document.querySelector('div[contentType=' + type + '] ' + - 'list[mode=' + mode + ']'); - exceptionsList.patternValidityCheckComplete(pattern, valid); + this.getExceptionsList(type, mode).patternValidityCheckComplete(pattern, + valid); }; /** @@ -222,7 +214,7 @@ cr.define('options', function() { */ ContentSettings.showMediaPepperFlashDefaultLink = function(show) { $('media-pepper-flash-default').hidden = !show; - } + }; /** * Shows/hides the link to the Pepper Flash camera and microphone @@ -232,7 +224,7 @@ cr.define('options', function() { */ ContentSettings.showMediaPepperFlashExceptionsLink = function(show) { $('media-pepper-flash-exceptions').hidden = !show; - } + }; /** * Shows/hides the whole Web MIDI settings. @@ -240,7 +232,7 @@ cr.define('options', function() { */ ContentSettings.showExperimentalWebMIDISettings = function(show) { $('experimental-web-midi-settings').hidden = !show; - } + }; /** * Updates the microphone/camera devices menu with the given entries. @@ -281,10 +273,9 @@ cr.define('options', function() { */ ContentSettings.enableProtectedContentExceptions = function(enable) { var exceptionsButton = $('protected-content-exceptions'); - if (exceptionsButton) { + if (exceptionsButton) exceptionsButton.disabled = !enable; - } - } + }; /** * Set the default microphone device based on the popup selection. @@ -310,5 +301,3 @@ cr.define('options', function() { }; }); - -} |