<commit_before>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

cr.define('options', function() {

  var OptionsPage = options.OptionsPage;

  //////////////////////////////////////////////////////////////////////////////
  // ContentSettings class:

  /**
   * Encapsulated handling of content settings page.
   * @constructor
   */
  function ContentSettings() {
    this.activeNavTab = null;
    OptionsPage.call(this, 'content', templateData.contentSettingsPage,
                     'contentSettingsPage');
  }

  cr.addSingletonGetter(ContentSettings);

  ContentSettings.prototype = {
    __proto__: OptionsPage.prototype,

    initializePage: function() {
      OptionsPage.prototype.initializePage.call(this);

      chrome.send('getContentFilterSettings');

      var exceptionsLists = this.pageDiv.querySelectorAll('list');
      for (var i = 0; i < exceptionsLists.length; i++) {
        options.contentSettings.ExceptionsList.decorate(exceptionsLists[i]);
      }
      ContentSettings.hideOTRLists();

      this.addEventListener('visibleChange', function(event) {
        for (var i = 0; i < exceptionsLists.length; i++) {
          exceptionsLists[i].redraw();
        }
      });

      // Cookies filter page ---------------------------------------------------
      $('block-third-party-cookies').onclick = function(event) {
        chrome.send('setAllowThirdPartyCookies',
                    [String($('block-third-party-cookies').checked)]);
      };

      $('show-cookies-button').onclick = function(event) {
        chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']);
        OptionsPage.showPageByName('cookiesView');
      };

      $('plugins-tab').onclick = function(event) {
        chrome.send('openPluginsTab');
      };

      if (!templateData.enable_click_to_play)
        $('click_to_play').style.display = 'none';
    },

    /**
     * Handles a hash value in the URL (such as bar in
     * chrome://options/foo#bar). Overrides the default action of showing an
     * overlay by instead navigating to a particular subtab.
     * @param {string} hash The hash value.
     */
    handleHash: function(hash) {
      // TODO(estade): show subpage for hash.
    },
  };

  /**
   * Sets the values for all the content settings radios.
   * @param {Object} dict A mapping from radio groups to the checked value for
   *     that group.
   */
  ContentSettings.setContentFilterSettingsValue = function(dict) {
    for (var group in dict) {
      document.querySelector('input[type=radio][name=' + group +
                             '][value=' + dict[group] + ']').checked = true;
    }
  };

  /**
   * 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).
   */
  ContentSettings.setExceptions = function(type, list) {
    var exceptionsList =
        document.querySelector('div[contentType=' + type + ']' +
                               ' list[mode=normal]');

    exceptionsList.clear();
    for (var i = 0; i < list.length; i++) {
      exceptionsList.addException(list[i]);
    }
    exceptionsList.redraw();
  };

  ContentSettings.setOTRExceptions = function(type, list) {
    var exceptionsList =
        document.querySelector('div[contentType=' + type + ']' +

    exceptionsList.parentNode.classList.remove('hidden');

    exceptionsList.clear();
    for (var i = 0; i < list.length; i++) {
      exceptionsList.addException(list[i]);
    }
    exceptionsList.redraw();
  };

  /**
   * Called when the last incognito window is closed.<commit_msg>[tabbed options] reinstate a line I accidentally deleted.<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

cr.define('options', function() {

  var OptionsPage = options.OptionsPage;

  //////////////////////////////////////////////////////////////////////////////
  // ContentSettings class:

  /**
   * Encapsulated handling of content settings page.
   * @constructor
   */
  function ContentSettings() {
    this.activeNavTab = null;
    OptionsPage.call(this, 'content', templateData.contentSettingsPage,
                     'contentSettingsPage');
  }

  cr.addSingletonGetter(ContentSettings);

  ContentSettings.prototype = {
    __proto__: OptionsPage.prototype,

    initializePage: function() {
      OptionsPage.prototype.initializePage.call(this);

      chrome.send('getContentFilterSettings');

      var exceptionsLists = this.pageDiv.querySelectorAll('list');
      for (var i = 0; i < exceptionsLists.length; i++) {
        options.contentSettings.ExceptionsList.decorate(exceptionsLists[i]);
      }
      ContentSettings.hideOTRLists();

      this.addEventListener('visibleChange', function(event) {
        for (var i = 0; i < exceptionsLists.length; i++) {
          exceptionsLists[i].redraw();
        }
      });

      // Cookies filter page ---------------------------------------------------
      $('block-third-party-cookies').onclick = function(event) {
        chrome.send('setAllowThirdPartyCookies',
                    [String($('block-third-party-cookies').checked)]);
      };

      $('show-cookies-button').onclick = function(event) {
        chrome.send('coreOptionsUserMetricsAction', ['Options_ShowCookies']);
        OptionsPage.showPageByName('cookiesView');
      };

      $('plugins-tab').onclick = function(event) {
        chrome.send('openPluginsTab');
      };

      if (!templateData.enable_click_to_play)
        $('click_to_play').style.display = 'none';
    },

    /**
     * Handles a hash value in the URL (such as bar in
     * chrome://options/foo#bar). Overrides the default action of showing an
     * overlay by instead navigating to a particular subtab.
     * @param {string} hash The hash value.
     */
    handleHash: function(hash) {
      // TODO(estade): show subpage for hash.
    },
  };

  /**
   * Sets the values for all the content settings radios.
   * @param {Object} dict A mapping from radio groups to the checked value for
   *     that group.
   */
  ContentSettings.setContentFilterSettingsValue = function(dict) {
    for (var group in dict) {
      document.querySelector('input[type=radio][name=' + group +
                             '][value=' + dict[group] + ']').checked = true;
    }
  };

  /**
   * 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).
   */
  ContentSettings.setExceptions = function(type, list) {
    var exceptionsList =
        document.querySelector('div[contentType=' + type + ']' +
                               ' list[mode=normal]');

    exceptionsList.clear();
    for (var i = 0; i < list.length; i++) {
      exceptionsList.addException(list[i]);
    }
    exceptionsList.redraw();
  };

  ContentSettings.setOTRExceptions = function(type, list) {
    var exceptionsList =
        document.querySelector('div[contentType=' + type + ']' +
                               ' div list[mode=normal]');

    exceptionsList.parentNode.classList.remove('hidden');

    exceptionsList.clear();
    for (var i = 0; i < list.length; i++) {
      exceptionsList.addException(list[i]);
    }
    exceptionsList.redraw();
  };

  /**
   * Called when the last incognito window is closed.
{'fraction_non_alphanumeric': 0.15447780343854248, 'fraction_numerical': 0.002052861175263023, 'mean_word_length': 2.4354341119435876, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7482184', 'n_tokens_mistral': 2173, 'n_tokens_neox': 2097, 'n_words': 532}