tree: 9854aea9d9d2078a0309351bc798f4ed26453a4b [path history] [tgz]
  1. add_site_dialog.html
  2. add_site_dialog.ts
  3. ads_page.html
  4. ads_page.ts
  5. all_sites.html
  6. all_sites.ts
  7. all_sites_icons.html
  8. ar_page.html
  9. ar_page.ts
  10. auto_picture_in_picture_page.html
  11. auto_picture_in_picture_page.ts
  12. automatic_downloads_page.html
  13. automatic_downloads_page.ts
  14. automatic_full_screen_page.html
  15. automatic_full_screen_page.ts
  16. background_sync_page.html
  17. background_sync_page.ts
  18. bluetooth_scanning_page.html
  19. bluetooth_scanning_page.ts
  20. captured_surface_control_page.html
  21. captured_surface_control_page.ts
  22. category_setting_exceptions.html
  23. category_setting_exceptions.ts
  24. chooser_exception_list.html
  25. chooser_exception_list.ts
  26. chooser_exception_list_entry.html
  27. chooser_exception_list_entry.ts
  28. clear_storage_dialog_shared.css
  29. clipboard_page.html
  30. clipboard_page.ts
  31. constants.ts
  32. edit_exception_dialog.html
  33. edit_exception_dialog.ts
  34. file_system_site_details.html
  35. file_system_site_details.ts
  36. file_system_site_entry.html
  37. file_system_site_entry.ts
  38. file_system_site_entry_item.html
  39. file_system_site_entry_item.ts
  40. file_system_site_list.html
  41. file_system_site_list.ts
  42. geolocation_page.html
  43. geolocation_page.ts
  44. hand_tracking_page.html
  45. hand_tracking_page.ts
  46. idle_detection_page.html
  47. idle_detection_page.ts
  48. javascript_page.html
  49. javascript_page.ts
  50. keyboard_lock_page.html
  51. keyboard_lock_page.ts
  52. local_fonts_page.html
  53. local_fonts_page.ts
  54. local_network_access_page.html
  55. local_network_access_page.ts
  56. media_picker.html
  57. media_picker.ts
  58. midi_devices_page.html
  59. midi_devices_page.ts
  60. notifications_page.html
  61. notifications_page.ts
  62. OWNERS
  63. payment_handler_page.html
  64. payment_handler_page.ts
  65. pdf_documents_page.html
  66. pdf_documents_page.ts
  67. popups_page.html
  68. popups_page.ts
  69. protected_content_page.html
  70. protected_content_page.ts
  71. protocol_handlers.html
  72. protocol_handlers.ts
  73. README.md
  74. sensors_page.html
  75. sensors_page.ts
  76. settings_category_default_radio_group.html
  77. settings_category_default_radio_group.ts
  78. site_data.html
  79. site_data.ts
  80. site_details.html
  81. site_details.ts
  82. site_details_permission.html
  83. site_details_permission.ts
  84. site_details_permission_device_entry.html
  85. site_details_permission_device_entry.ts
  86. site_entry.html
  87. site_entry.ts
  88. site_list.html
  89. site_list.ts
  90. site_list_entry.html
  91. site_list_entry.ts
  92. site_settings_mixin.ts
  93. site_settings_prefs_browser_proxy.ts
  94. site_settings_shared.css
  95. site_settings_util.ts
  96. smart_card_readers_page.html
  97. smart_card_readers_page.ts
  98. storage_access_page.html
  99. storage_access_page.ts
  100. storage_access_site_list.html
  101. storage_access_site_list.ts
  102. storage_access_site_list_entry.html
  103. storage_access_site_list_entry.ts
  104. storage_access_static_site_list_entry.html
  105. storage_access_static_site_list_entry.ts
  106. v8_page.html
  107. v8_page.ts
  108. vr_page.html
  109. vr_page.ts
  110. web_applications_page.html
  111. web_applications_page.ts
  112. web_printing_page.html
  113. web_printing_page.ts
  114. website_usage_browser_proxy.ts
  115. window_management_page.html
  116. window_management_page.ts
  117. zoom_levels.html
  118. 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="is_chromeos">
  <link rel="import" href="android_info_browser_proxy.html">
</if>
<if expr="is_chromeos">
  <template is="dom-if" if="[[settingsAppAvailable_]]">
    <cr-link-row on-click="onManageAndroidAppsClick_"
        label="$i18n{androidAppsManageAppLinks}" external></cr-link-row>
  </template>
</if>