tree: 89809bf0ae63e22a7201a9db0028246dd452c71e [path history] [tgz]
  1. add_site_dialog.html
  2. add_site_dialog.ts
  3. all_sites.html
  4. all_sites.ts
  5. all_sites_icons.html
  6. category_setting_exceptions.html
  7. category_setting_exceptions.ts
  8. chooser_exception_list.html
  9. chooser_exception_list.ts
  10. chooser_exception_list_entry.html
  11. chooser_exception_list_entry.ts
  12. clear_storage_dialog_shared.css
  13. constants.ts
  14. edit_exception_dialog.html
  15. edit_exception_dialog.ts
  16. file_system_site_details.html
  17. file_system_site_details.ts
  18. file_system_site_entry.html
  19. file_system_site_entry.ts
  20. file_system_site_entry_item.html
  21. file_system_site_entry_item.ts
  22. file_system_site_list.html
  23. file_system_site_list.ts
  24. media_picker.html
  25. media_picker.ts
  26. OWNERS
  27. pdf_documents.html
  28. pdf_documents.ts
  29. protocol_handlers.html
  30. protocol_handlers.ts
  31. README.md
  32. review_notification_permissions.html
  33. review_notification_permissions.ts
  34. settings_category_default_radio_group.html
  35. settings_category_default_radio_group.ts
  36. site_data.html
  37. site_data.ts
  38. site_details.html
  39. site_details.ts
  40. site_details_permission.html
  41. site_details_permission.ts
  42. site_details_permission_device_entry.html
  43. site_details_permission_device_entry.ts
  44. site_entry.html
  45. site_entry.ts
  46. site_list.html
  47. site_list.ts
  48. site_list_entry.html
  49. site_list_entry.ts
  50. site_settings_mixin.ts
  51. site_settings_prefs_browser_proxy.ts
  52. storage_access_site_list.html
  53. storage_access_site_list.ts
  54. storage_access_site_list_entry.html
  55. storage_access_site_list_entry.ts
  56. storage_access_static_site_list_entry.html
  57. storage_access_static_site_list_entry.ts
  58. website_usage_browser_proxy.ts
  59. zoom_levels.html
  60. zoom_levels.ts
chrome/browser/resources/settings/site_settings/README.md

Content Settings UI in Desktop

Overview

Content Settings are settings pages that live under chrome://settings/content. They are intended to provide the user with information about the status of sites' capabilities as well as to allow them to tweak these settings as they see fit.

Behind the scenes, these are simple “html” pages using the polymer JavaScript library.

All content settings pages live under this folder and under the ../site_settings_page folder. Arguably, the most important pages are:

Here are some common patterns/coding practices/tips that you might find useful:

Strings

Any and all strings that are displayed to the user need to go through internationalization (i18n) functions to ensure the string is correctly localized to the language settings of the user. Examples:

<site-details-permission
  category="{{ContentSettingsTypes.SITE_SETTINGS_SOUND}}"
  icon="settings:volume-up" id="siteSettingsSound"
  label="$i18n{siteSettingsSound}">
</site-details-permission>
<option value="[[sortMethods_.STORAGE]]">
  $i18n{siteSettingsAllSitesSortMethodStorage}
</option>
<cr-button class="action-button" on-click="onResetSettings_">
  $i18n{siteSettingsSiteResetAll}
</cr-button>
<div slot="body">
  [[i18n('siteSettingsSiteResetConfirmation', pageTitle)]]
</div>

The string ids are mapped in settings_localized_strings_provider.cc to IDS_ chrome resource strings ids.

Updating prefs

If a toggle simply controls a pref there is a built-in control that allows you to do this easily: settings-toggle-button.

Examples:

<settings-toggle-button id="toggle" class="two-line"
  label="$i18n{siteSettingsPdfDownloadPdfs}"
  pref="{{prefs.plugins.always_open_pdf_externally}}">
</settings-toggle-button>

or with a dynamically selected pref:

<settings-toggle-button id="toggle"
  pref="{{controlParams_}}"
  label="[[optionLabel_]]" sub-label="[[optionDescription_]]"
  disabled$="[[isToggleDisabled_(category)]]">
</settings-toggle-button>

If you need something more complicated than a simple true/false pref you can make use of the this.browserProxy object which allows you to communicate with the browser.

The class is declared in site_settings_prefs_browser_proxy.js and the browser implementation resides in site_settings_handler.h. Make sure to register your message so that everything is properly bound.

Hide specific sections

Often a particular section of a page only needs to be displayed only under specific circumstances. In this case make liberal use of the dom-if template.

Examples:

// html:

<template is="dom-if" if="[[enableInsecureContentContentSetting_]]">
  <site-details-permission category="{{ContentSettingsTypes.MIXEDSCRIPT}}"
    icon="settings:insecure-content" id="mixed-script"
    label="$i18n{siteSettingsInsecureContent}">
  </site-details-permission>
</template>
// js:

Polymer({

// ...

properties: {
  /** @private */ enableInsecureContentContentSetting_: {
    type: Boolean,
    value() {
      return loadTimeData.getBoolean('enableInsecureContentContentSetting');
    }
  },

  // ...

Platform specific elements

You can limit the visibility of an element to a certain platform, by using the available expressions.

Examples:

<if expr="chromeos_ash">
  <link rel="import" href="android_info_browser_proxy.html">
</if>
<if expr="chromeos_ash">
  <template is="dom-if" if="[[settingsAppAvailable_]]">
    <cr-link-row on-click="onManageAndroidAppsClick_"
        label="$i18n{androidAppsManageAppLinks}" external></cr-link-row>
  </template>
</if>