diff options
Diffstat (limited to 'chromium/chrome/browser/resources/settings/site_settings')
50 files changed, 0 insertions, 6670 deletions
diff --git a/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html b/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html deleted file mode 100644 index 6b38253df50..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.html +++ /dev/null @@ -1,50 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_settings_behavior.html"> - -<dom-module id="add-site-dialog"> - <template> - <style include="settings-shared"> - #incognito { - padding-bottom: 10px; - } - </style> - <cr-dialog id="dialog" close-text="$i18n{close}"> - <div slot="title">$i18n{addSiteTitle}</div> - <div slot="body"> - <cr-input id="site" label="$i18n{addSite}" - placeholder="$i18n{addSiteExceptionPlaceholder}" - value="{{site_}}" on-input="validate_" - error-message="{{errorMessage_}}" spellcheck="false" - autofocus></cr-input> - <cr-checkbox id="incognito" - hidden$="[[!showIncognitoSessionOnly_(hasIncognito, - contentSetting)]]"> - $i18n{incognitoSiteOnly} - </cr-checkbox> - <cr-checkbox id="thirdParties" - hidden$="[[shouldHideThirdPartyCookieCheckbox_(category)]]"> - $i18n{siteSettingsCookiesThirdPartyExceptionLabel} - </cr-checkbox> - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCancelTap_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" id="add" on-click="onSubmit_" - disabled> - $i18n{add} - </cr-button> - </div> - </cr-dialog> - </template> - <script src="add_site_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.js b/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.js deleted file mode 100644 index a9962dde633..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/add_site_dialog.js +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'add-site-dialog' provides a dialog to add exceptions for a given Content - * Settings category. - */ -Polymer({ - is: 'add-site-dialog', - - behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], - - properties: { - /** - * What kind of setting, e.g. Location, Camera, Cookies, and so on. - * @type {settings.ContentSettingsTypes} - */ - category: String, - - /** - * Whether this is about an Allow, Block, SessionOnly, or other. - * @type {settings.ContentSetting} - */ - contentSetting: String, - - /** @private */ - hasIncognito: { - type: Boolean, - observer: 'hasIncognitoChanged_', - }, - - /** - * The site to add an exception for. - * @private - */ - site_: String, - - /** - * The error message to display when the pattern is invalid. - * @private - */ - errorMessage_: String, - }, - - /** @override */ - attached: function() { - assert(this.category); - assert(this.contentSetting); - assert(typeof this.hasIncognito != 'undefined'); - - this.$.dialog.showModal(); - }, - - /** - * Validates that the pattern entered is valid. - * @private - */ - validate_: function() { - // If input is empty, disable the action button, but don't show the red - // invalid message. - if (this.$.site.value.trim() == '') { - this.$.site.invalid = false; - this.$.add.disabled = true; - return; - } - - this.browserProxy.isPatternValidForType(this.site_, this.category) - .then(({isValid, reason}) => { - this.$.site.invalid = !isValid; - this.$.add.disabled = !isValid; - this.errorMessage_ = reason || ''; - }); - }, - - /** @private */ - onCancelTap_: function() { - this.$.dialog.cancel(); - }, - - /** - * The tap handler for the Add [Site] button (adds the pattern and closes - * the dialog). - * @private - */ - onSubmit_: function() { - assert(!this.$.add.disabled); - let primaryPattern = this.site_; - let secondaryPattern = settings.SITE_EXCEPTION_WILDCARD; - - if (this.$.thirdParties.checked) { - primaryPattern = settings.SITE_EXCEPTION_WILDCARD; - secondaryPattern = this.site_; - } - - this.browserProxy.setCategoryPermissionForPattern( - primaryPattern, secondaryPattern, this.category, this.contentSetting, - this.$.incognito.checked); - - this.$.dialog.close(); - }, - - /** @private */ - showIncognitoSessionOnly_: function() { - return this.hasIncognito && !loadTimeData.getBoolean('isGuest') && - this.contentSetting != settings.ContentSetting.SESSION_ONLY; - }, - - /** @private */ - hasIncognitoChanged_: function() { - if (!this.hasIncognito) { - this.$.incognito.checked = false; - } - }, - - /** - * @return {boolean} - * @private - */ - shouldHideThirdPartyCookieCheckbox_: function() { - return this.category !== settings.ContentSettingsTypes.COOKIES || - !loadTimeData.getBoolean('showImprovedCookieControlsForThirdParties'); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/all_sites.html b/chromium/chrome/browser/resources/settings/site_settings/all_sites.html deleted file mode 100644 index 53a046e4490..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/all_sites.html +++ /dev/null @@ -1,137 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_search_field.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> -<link rel="import" href="../global_scroll_target_behavior.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="site_entry.html"> -<link rel="import" href="site_settings_behavior.html"> - -<dom-module id="all-sites"> - <template> - <style include="settings-shared md-select"> - #sort { - align-items: center; - display: flex; - margin: 0 var(--cr-icon-button-margin-start); - margin-bottom: 50px; - padding: 0 var(--cr-section-padding); - } - - #sortMethod { - margin-inline-start: 1em; - } - - /* There is only one top-level heading for All Sites, so remove the - * additional leading padding used for lists. */ - .list-frame.without-heading { - padding-inline-start: var(--cr-section-padding); - } - </style> - <div id="sort"> - <label id="sortLabel">$i18n{siteSettingsAllSitesSort}</label> - <select id="sortMethod" class="md-select" aria-labelledby="sortLabel" - on-change="onSortMethodChanged_"> - <option value="[[sortMethods_.MOST_VISITED]]"> - $i18n{siteSettingsAllSitesSortMethodMostVisited} - </option> - <option value="[[sortMethods_.STORAGE]]"> - $i18n{siteSettingsAllSitesSortMethodStorage} - </option> - <option value="[[sortMethods_.NAME]]"> - $i18n{siteSettingsAllSitesSortMethodName} - </option> - </select> - </div> - <div class="list-frame" hidden$="[[!siteGroupMapEmpty_(siteGroupMap)]]"> - <div class="list-item secondary">$i18n{emptyAllSitesPage}</div> - </div> - <div class="list-frame" hidden$="[[!noSearchResultFound_(filteredList_)]]"> - <div class="list-item secondary">$i18n{noSitesFound}</div> - </div> - <div class="list-frame without-heading" id="listContainer"> - <iron-list id="allSitesList" - items="[[filteredList_]]" - scroll-target="[[subpageScrollTarget]]"> - <template> - <site-entry site-group="[[item]]" list-index="[[index]]" - iron-list-tab-index="[[tabIndex]]" - tabindex$="[[tabIndex]]" - last-focused="{{lastFocused_}}" - list-blurred="{{listBlurred_}}" - sort-method="[[sortMethod_]]"> - </site-entry> - </template> - </iron-list> - </div> - - <!-- Overflow menu. --> - <cr-lazy-render id="menu"> - <template> - <cr-action-menu> - <button class="dropdown-item" role="menuitem" - on-click="onConfirmResetSettings_"> - $i18n{siteSettingsSiteGroupReset} - </button> - <button class="dropdown-item" role="menuitem" - on-click="onConfirmClearData_"> - $i18n{siteSettingsSiteGroupDelete} - </button> - </cr-action-menu> - </template> - </cr-lazy-render> - - <!-- Confirm reset settings dialog. --> - <cr-lazy-render id="confirmResetSettings"> - <template> - <cr-dialog close-text="$i18n{close}"> - <div slot="title"> - $i18n{siteSettingsSiteGroupResetDialogTitle} - </div> - <div slot="body"> - [[getFormatString_( - '$i18nPolymer{siteSettingsSiteGroupResetConfirmation}', - actionMenuModel_.item.etldPlus1)]] - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCloseDialog_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onResetSettings_"> - $i18n{siteSettingsSiteResetAll} - </cr-button> - </div> - </cr-dialog> - </template> - </cr-lazy-render> - - <!-- Confirm clear data dialog. --> - <cr-lazy-render id="confirmClearData"> - <template> - <cr-dialog close-text="$i18n{close}"> - <div slot="title"> - $i18n{siteSettingsSiteGroupDeleteDialogTitle} - </div> - <div slot="body"> - [[getFormatString_( - '$i18nPolymer{siteSettingsSiteGroupDeleteConfirmation}', - actionMenuModel_.item.etldPlus1)]] - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCloseDialog_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onClearData_"> - $i18n{siteSettingsSiteClearStorage} - </cr-button> - </div> - </cr-dialog> - </template> - </cr-lazy-render> - </template> - <script src="all_sites.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/all_sites.js b/chromium/chrome/browser/resources/settings/site_settings/all_sites.js deleted file mode 100644 index 7f74c3bb909..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/all_sites.js +++ /dev/null @@ -1,511 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'all-sites' is the polymer element for showing the list of all sites under - * Site Settings. - */ -Polymer({ - is: 'all-sites', - - behaviors: [ - SiteSettingsBehavior, - WebUIListenerBehavior, - settings.RouteObserverBehavior, - settings.GlobalScrollTargetBehavior, - ], - - properties: { - /** - * Map containing sites to display in the widget, grouped into their - * eTLD+1 names. - * @type {!Map<string, !SiteGroup>} - */ - siteGroupMap: { - type: Object, - value: function() { - return new Map(); - }, - }, - - /** - * Filtered site group list. - * @type {!Array<SiteGroup>} - * @private - */ - filteredList_: { - type: Array, - }, - - /** - * Needed by GlobalScrollTargetBehavior. - * @override - */ - subpageRoute: { - type: Object, - value: settings.routes.SITE_SETTINGS_ALL, - readOnly: true, - }, - - /** - * The search query entered into the All Sites search textbox. Used to - * filter the All Sites list. - * @private - */ - filter: { - type: String, - value: '', - observer: 'forceListUpdate_', - }, - - /** - * All possible sort methods. - * @type {!{name: string, mostVisited: string, storage: string}} - * @private - */ - sortMethods_: { - type: Object, - value: settings.SortMethod, - readOnly: true, - }, - - /** - * Stores the last selected item in the All Sites list. - * @type {?{item: !SiteGroup, index: number}} - * @private - */ - selectedItem_: Object, - - /** - * @private - * Used to track the last-focused element across rows for the - * focusRowBehavior. - */ - lastFocused_: Object, - - /** - * @private - * Used to track whether the list of row items has been blurred for the - * focusRowBehavior. - */ - listBlurred_: Boolean, - - /** - * @private {?{ - * index: number, - * item: !SiteGroup, - * path: string, - * target: !HTMLElement - * }} - */ - actionMenuModel_: Object, - - /** - * The selected sort method. - * @type {!settings.SortMethod|undefined} - * @private - */ - sortMethod_: String, - }, - - /** @private {?settings.LocalDataBrowserProxy} */ - localDataBrowserProxy_: null, - - /** @override */ - created: function() { - this.localDataBrowserProxy_ = - settings.LocalDataBrowserProxyImpl.getInstance(); - }, - - listeners: { - 'open-menu': 'onOpenMenu_', - }, - - /** @override */ - ready: function() { - this.addWebUIListener( - 'onStorageListFetched', this.onStorageListFetched.bind(this)); - this.addEventListener('site-entry-selected', e => { - const event = - /** @type {!CustomEvent<!{item: !SiteGroup, index: number}>} */ (e); - this.selectedItem_ = event.detail; - }); - this.addEventListener('site-entry-storage-updated', () => { - this.debounce('site-entry-storage-updated', () => { - if (this.sortMethods_ && - this.$.sortMethod.value == settings.SortMethod.STORAGE) { - this.onSortMethodChanged_(); - } - }, 500); - }); - this.sortMethod_ = this.$.sortMethod.value; - }, - - /** @override */ - attached: function() { - // Set scrollOffset so the iron-list scrolling accounts for the space the - // title takes. - Polymer.RenderStatus.afterNextRender(this, () => { - this.$.allSitesList.scrollOffset = this.$.allSitesList.offsetTop; - }); - }, - - /** - * Reload the site list when the all sites page is visited. - * - * settings.RouteObserverBehavior - * @param {!settings.Route} currentRoute - * @protected - */ - currentRouteChanged: function(currentRoute) { - settings.GlobalScrollTargetBehaviorImpl.currentRouteChanged.call( - this, currentRoute); - if (currentRoute == settings.routes.SITE_SETTINGS_ALL) { - this.populateList_(); - } - }, - - /** - * Retrieves a list of all known sites with site details. - * @private - */ - populateList_: function() { - /** @type {!Array<settings.ContentSettingsTypes>} */ - const contentTypes = this.getCategoryList(); - // Make sure to include cookies, because All Sites handles data storage + - // cookies as well as regular settings.ContentSettingsTypes. - if (!contentTypes.includes(settings.ContentSettingsTypes.COOKIES)) { - contentTypes.push(settings.ContentSettingsTypes.COOKIES); - } - - this.browserProxy.getAllSites(contentTypes).then((response) => { - // Create a new map to make an observable change. - const newMap = /** @type {!Map<string, !SiteGroup>} */ - (new Map(this.siteGroupMap)); - response.forEach(siteGroup => { - newMap.set(siteGroup.etldPlus1, siteGroup); - }); - this.siteGroupMap = newMap; - this.forceListUpdate_(); - }); - }, - - /** - * Integrate sites using storage into the existing sites map, as there - * may be overlap between the existing sites. - * @param {!Array<!SiteGroup>} list The list of sites using storage. - */ - onStorageListFetched: function(list) { - // Create a new map to make an observable change. - const newMap = /** @type {!Map<string, !SiteGroup>} */ - (new Map(this.siteGroupMap)); - list.forEach(storageSiteGroup => { - newMap.set(storageSiteGroup.etldPlus1, storageSiteGroup); - }); - this.siteGroupMap = newMap; - this.forceListUpdate_(); - this.focusOnLastSelectedEntry_(); - }, - - /** - * Filters the all sites list with the given search query text. - * @param {!Map<string, !SiteGroup>} siteGroupMap The map of sites to filter. - * @param {string} searchQuery The filter text. - * @return {!Array<!SiteGroup>} - * @private - */ - filterPopulatedList_: function(siteGroupMap, searchQuery) { - const result = []; - for (const [etldPlus1, siteGroup] of siteGroupMap) { - if (siteGroup.origins.find( - originInfo => originInfo.origin.includes(searchQuery))) { - result.push(siteGroup); - } - } - return this.sortSiteGroupList_(result); - }, - - /** - * Sorts the given SiteGroup list with the currently selected sort method. - * @param {!Array<!SiteGroup>} siteGroupList The list of sites to sort. - * @return {!Array<!SiteGroup>} - * @private - */ - sortSiteGroupList_: function(siteGroupList) { - const sortMethod = this.$.sortMethod.value; - if (!this.sortMethods_) { - return siteGroupList; - } - - if (sortMethod == settings.SortMethod.MOST_VISITED) { - siteGroupList.sort(this.mostVisitedComparator_); - } else if (sortMethod == settings.SortMethod.STORAGE) { - siteGroupList.sort(this.storageComparator_); - } else if (sortMethod == settings.SortMethod.NAME) { - siteGroupList.sort(this.nameComparator_); - } - return siteGroupList; - }, - - /** - * Comparator used to sort SiteGroups by the amount of engagement the user has - * with the origins listed inside it. Note only the maximum engagement is used - * for each SiteGroup (as opposed to the sum) in order to prevent domains with - * higher numbers of origins from always floating to the top of the list. - * @param {!SiteGroup} siteGroup1 - * @param {!SiteGroup} siteGroup2 - * @private - */ - mostVisitedComparator_: function(siteGroup1, siteGroup2) { - const getMaxEngagement = (max, originInfo) => { - return (max > originInfo.engagement) ? max : originInfo.engagement; - }; - const score1 = siteGroup1.origins.reduce(getMaxEngagement, 0); - const score2 = siteGroup2.origins.reduce(getMaxEngagement, 0); - return score2 - score1; - }, - - /** - * Comparator used to sort SiteGroups by the amount of storage they use. Note - * this sorts in descending order. - * @param {!SiteGroup} siteGroup1 - * @param {!SiteGroup} siteGroup2 - * @private - */ - storageComparator_: function(siteGroup1, siteGroup2) { - const getOverallUsage = siteGroup => { - let usage = 0; - siteGroup.origins.forEach(originInfo => { - usage += originInfo.usage; - }); - return usage; - }; - - const siteGroup1Size = getOverallUsage(siteGroup1); - const siteGroup2Size = getOverallUsage(siteGroup2); - // Use the number of cookies as a tie breaker. - return siteGroup2Size - siteGroup1Size || - siteGroup2.numCookies - siteGroup1.numCookies; - }, - - /** - * Comparator used to sort SiteGroups by their eTLD+1 name (domain). - * @param {!SiteGroup} siteGroup1 - * @param {!SiteGroup} siteGroup2 - * @private - */ - nameComparator_: function(siteGroup1, siteGroup2) { - return siteGroup1.etldPlus1.localeCompare(siteGroup2.etldPlus1); - }, - - /** - * Called when the user chooses a different sort method to the default. - * @private - */ - onSortMethodChanged_: function() { - this.sortMethod_ = this.$.sortMethod.value; - this.filteredList_ = - this.sortSiteGroupList_(this.filteredList_); - // Force the iron-list to rerender its items, as the order has changed. - this.$.allSitesList.fire('iron-resize'); - }, - - /** - * Forces the all sites list to update its list of items, taking into account - * the search query and the sort method, then re-renders it. - * @private - */ - forceListUpdate_: function() { - this.filteredList_ = - this.filterPopulatedList_(this.siteGroupMap, this.filter); - this.$.allSitesList.fire('iron-resize'); - }, - - /** - * Whether the |siteGroupMap| is empty. - * @return {boolean} - * @private - */ - siteGroupMapEmpty_: function() { - return !this.siteGroupMap.size; - }, - - /** - * Whether the |filteredList_| is empty due to searching. - * @return {boolean} - * @private - */ - noSearchResultFound_: function() { - return !this.filteredList_.length && !this.siteGroupMapEmpty_(); - }, - - /** - * Focus on previously selected entry. - * @private - */ - focusOnLastSelectedEntry_: function() { - if (this.selectedItem_ == null || this.siteGroupMap.size == 0) { - return; - } - // Focus the site-entry to ensure the iron-list renders it, otherwise - // the query selector will not be able to find it. Note the index is - // used here instead of the item, in case the item was already removed. - const index = - Math.max(0, Math.min(this.selectedItem_.index, this.siteGroupMap.size)); - this.$.allSitesList.focusItem(index); - this.selectedItem_ = null; - }, - - /** - * Open the overflow menu and ensure that the item is visible in the scroll - * pane when its menu is opened (it is possible to open off-screen items using - * keyboard shortcuts). - * @param {!CustomEvent<{ - * index: number, item: !SiteGroup, - * path: string, target: !HTMLElement - * }>} e - * @private - */ - onOpenMenu_: function(e) { - const index = e.detail.index; - const list = /** @type {IronListElement} */ (this.$['allSitesList']); - if (index < list.firstVisibleIndex || index > list.lastVisibleIndex) { - list.scrollToIndex(index); - } - const target = e.detail.target; - this.actionMenuModel_ = e.detail; - const menu = /** @type {CrActionMenuElement} */ (this.$.menu.get()); - menu.showAt(target); - }, - - /** - * Confirms the resetting of all content settings for an origin. - * @param {!Event} e - * @private - */ - onConfirmResetSettings_: function(e) { - e.preventDefault(); - this.$.confirmResetSettings.get().showModal(); - }, - - /** - * Confirms the clearing of all storage data for an etld+1. - * @param {!Event} e - * @private - */ - onConfirmClearData_: function(e) { - e.preventDefault(); - this.$.confirmClearData.get().showModal(); - }, - - /** @private */ - onCloseDialog_: function(e) { - e.target.closest('cr-dialog').close(); - this.actionMenuModel_ = null; - this.$.menu.get().close(); - }, - - /** - * Formats the |label| string with |name|, using $<num> as markers. - * @param {string} label - * @param {string} name - * @return {string} - * @private - */ - getFormatString_: function(label, name) { - return loadTimeData.substituteString(label, name); - }, - - /** - * Resets all permissions for all origins listed in |siteGroup.origins|. - * @param {!Event} e - * @private - */ - onResetSettings_: function(e) { - const contentSettingsTypes = this.getCategoryList(); - const index = this.actionMenuModel_.index; - this.browserProxy.recordAction(settings.AllSitesAction.RESET_PERMISSIONS); - if (this.actionMenuModel_.item.etldPlus1 != - this.filteredList_[index].etldPlus1) { - return; - } - for (let i = 0; i < this.filteredList_[index].origins.length; ++i) { - const origin = this.filteredList_[index].origins[i].origin; - this.browserProxy.setOriginPermissions( - origin, contentSettingsTypes, settings.ContentSetting.DEFAULT); - if (contentSettingsTypes.includes( - settings.ContentSettingsTypes.PLUGINS)) { - this.browserProxy.clearFlashPref(origin); - } - this.filteredList_[index].origins[i].hasPermissionSettings = false; - } - const updatedSiteGroup = { - etldPlus1: this.filteredList_[index].etldPlus1, - numCookies: this.filteredList_[index].numCookies, - origins: [] - }; - for (let i = 0; i < this.filteredList_[index].origins.length; ++i) { - const updatedOrigin = - Object.assign({}, this.filteredList_[index].origins[i]); - if (updatedOrigin.numCookies > 0 || updatedOrigin.usage > 0) { - updatedOrigin.hasPermissionSettings = false; - updatedSiteGroup.origins.push(updatedOrigin); - } - } - if (updatedSiteGroup.origins.length > 0) { - this.set('filteredList_.' + index, updatedSiteGroup); - } else if (this.filteredList_[index].numCookies > 0) { - // If there is no origin for this site group that has any data, - // but the ETLD+1 has cookies in use, create a origin placeholder - // for display purposes. - const originPlaceHolder = { - origin: 'http://' + this.filteredList_[index].etldPlus1 + '/', - engagement: 0, - usage: 0, - numCookies: this.filteredList_[index].numCookies, - hasPermissionSettings: false - }; - updatedSiteGroup.origins.push(originPlaceHolder); - this.set('filteredList_.' + index, updatedSiteGroup); - } else { - this.splice('filteredList_', index, 1); - } - this.$.allSitesList.fire('iron-resize'); - this.onCloseDialog_(e); - }, - - /** - * Clear data and cookies for an etldPlus1. - * @param {!Event} e - * @private - */ - onClearData_: function(e) { - const index = this.actionMenuModel_.index; - // Clean up the SiteGroup. - this.browserProxy.clearEtldPlus1DataAndCookies( - this.filteredList_[index].etldPlus1); - const updatedSiteGroup = { - etldPlus1: this.filteredList_[index].etldPlus1, - numCookies: 0, - origins: [] - }; - for (let i = 0; i < this.filteredList_[index].origins.length; ++i) { - const updatedOrigin = - Object.assign({}, this.filteredList_[index].origins[i]); - if (updatedOrigin.hasPermissionSettings) { - updatedOrigin.numCookies = 0; - updatedOrigin.usage = 0; - updatedSiteGroup.origins.push(updatedOrigin); - } - } - if (updatedSiteGroup.origins.length > 0) { - this.set('filteredList_.' + index, updatedSiteGroup); - } else { - this.splice('filteredList_', index, 1); - } - this.$.allSitesList.fire('iron-resize'); - this.onCloseDialog_(e); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.html b/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.html deleted file mode 100644 index f39ca2af2e8..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.html +++ /dev/null @@ -1,28 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../controls/settings_toggle_button.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="category-default-setting"> - <template> - <style include="settings-shared"></style> - <settings-toggle-button id="toggle" - class="first" - pref="{{controlParams_}}" label="[[optionLabel_]]" - sub-label="[[optionDescription]]" - disabled$="[[isToggleDisabled_(category)]]"> - </settings-toggle-button> - <template is="dom-if" if="[[subOptionLabel]]"> - <settings-toggle-button id="subOptionToggle" - pref="{{subControlParams_}}" - label="[[subOptionLabel]]" sub-label="[[subOptionDescription]]" - disabled$="[[!controlParams_.value]]"> - </settings-toggle-button> - </template> - </template> - <script src="category_default_setting.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js b/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js deleted file mode 100644 index a3e2d3277eb..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'category-default-setting' is the polymer element for showing a certain - * category under Site Settings. - */ -Polymer({ - is: 'category-default-setting', - - behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], - - properties: { - /* The second line, shown under the |optionLabel_| line. (optional) */ - optionDescription: String, - - /* The second line, shown under the |subOptionLabel| line. (optional) */ - subOptionDescription: String, - - /* The sub-option is a separate toggle. Setting this label will show the - * additional toggle. Shown above |subOptionDescription|. (optional) */ - subOptionLabel: String, - - /* The on/off text for |optionLabel_| below. */ - toggleOffLabel: String, - toggleOnLabel: String, - - /** @private {chrome.settingsPrivate.PrefObject} */ - controlParams_: { - type: Object, - value: function() { - return /** @type {chrome.settingsPrivate.PrefObject} */ ({}); - }, - }, - - /** - * The label to be shown next to the toggle (above |optionDescription|). - * This will be either toggleOffLabel or toggleOnLabel. - * @private - */ - optionLabel_: String, - - /** @private {!DefaultContentSetting} */ - priorDefaultContentSetting_: { - type: Object, - value: function() { - return /** @type {DefaultContentSetting} */ ({}); - }, - }, - - /** - * Cookies and Flash settings have a sub-control that is used to mimic a - * tri-state value. - * @private {chrome.settingsPrivate.PrefObject} - */ - subControlParams_: { - type: Object, - value: function() { - return /** @type {chrome.settingsPrivate.PrefObject} */ ({}); - }, - }, - }, - - observers: [ - 'onCategoryChanged_(category)', - 'onChangePermissionControl_(category, controlParams_.value, ' + - 'subControlParams_.value)', - ], - - /** @override */ - ready: function() { - this.addWebUIListener( - 'contentSettingCategoryChanged', this.onCategoryChanged_.bind(this)); - }, - - /** @return {boolean} */ - get categoryEnabled() { - return !!assert(this.controlParams_).value; - }, - - /** - * A handler for changing the default permission value for a content type. - * This is also called during page setup after we get the default state. - * @private - */ - onChangePermissionControl_: function() { - if (this.category === undefined || - this.controlParams_.value === undefined || - this.subControlParams_.value === undefined) { - // Do nothing unless all dependencies are defined. - return; - } - - // Don't override user settings with enforced settings. - if (this.controlParams_.enforcement == - chrome.settingsPrivate.Enforcement.ENFORCED) { - return; - } - switch (this.category) { - case settings.ContentSettingsTypes.ADS: - case settings.ContentSettingsTypes.BACKGROUND_SYNC: - case settings.ContentSettingsTypes.IMAGES: - case settings.ContentSettingsTypes.JAVASCRIPT: - case settings.ContentSettingsTypes.MIXEDSCRIPT: - case settings.ContentSettingsTypes.SOUND: - case settings.ContentSettingsTypes.SENSORS: - case settings.ContentSettingsTypes.PAYMENT_HANDLER: - case settings.ContentSettingsTypes.POPUPS: - case settings.ContentSettingsTypes.PROTOCOL_HANDLERS: - - // "Allowed" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, - this.categoryEnabled ? settings.ContentSetting.ALLOW : - settings.ContentSetting.BLOCK); - break; - case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS: - case settings.ContentSettingsTypes.CAMERA: - case settings.ContentSettingsTypes.CLIPBOARD: - case settings.ContentSettingsTypes.GEOLOCATION: - case settings.ContentSettingsTypes.MIC: - case settings.ContentSettingsTypes.NOTIFICATIONS: - case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS: - case settings.ContentSettingsTypes.MIDI_DEVICES: - case settings.ContentSettingsTypes.USB_DEVICES: - case settings.ContentSettingsTypes.SERIAL_PORTS: - case settings.ContentSettingsTypes.BLUETOOTH_SCANNING: - case settings.ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE: - // "Ask" vs "Blocked". - this.browserProxy.setDefaultValueForContentType( - this.category, - this.categoryEnabled ? settings.ContentSetting.ASK : - settings.ContentSetting.BLOCK); - break; - case settings.ContentSettingsTypes.COOKIES: - // This category is tri-state: "Allow", "Block", "Keep data until - // browser quits". - let value = settings.ContentSetting.BLOCK; - if (this.categoryEnabled) { - value = this.subControlParams_.value ? - settings.ContentSetting.SESSION_ONLY : - settings.ContentSetting.ALLOW; - } - this.browserProxy.setDefaultValueForContentType(this.category, value); - break; - case settings.ContentSettingsTypes.PLUGINS: - // "Run important content" vs. "Block". - this.browserProxy.setDefaultValueForContentType( - this.category, - this.categoryEnabled ? settings.ContentSetting.IMPORTANT_CONTENT : - settings.ContentSetting.BLOCK); - break; - default: - assertNotReached('Invalid category: ' + this.category); - } - }, - - /** - * Update the control parameter values from the content settings. - * @param {!DefaultContentSetting} update - * @private - */ - updateControlParams_: function(update) { - // Early out if there is no actual change. - if (this.priorDefaultContentSetting_.setting == update.setting && - this.priorDefaultContentSetting_.source == update.source) { - return; - } - this.priorDefaultContentSetting_ = update; - - const basePref = { - 'key': 'controlParams', - 'type': chrome.settingsPrivate.PrefType.BOOLEAN, - }; - if (update.source !== undefined && - update.source != ContentSettingProvider.PREFERENCE) { - basePref.enforcement = chrome.settingsPrivate.Enforcement.ENFORCED; - switch (update.source) { - case ContentSettingProvider.POLICY: - basePref.controlledBy = - chrome.settingsPrivate.ControlledBy.DEVICE_POLICY; - break; - case ContentSettingProvider.SUPERVISED_USER: - basePref.controlledBy = chrome.settingsPrivate.ControlledBy.PARENT; - break; - case ContentSettingProvider.EXTENSION: - basePref.controlledBy = chrome.settingsPrivate.ControlledBy.EXTENSION; - break; - default: - basePref.controlledBy = - chrome.settingsPrivate.ControlledBy.USER_POLICY; - break; - } - } - - const prefValue = this.computeIsSettingEnabled(update.setting); - // The controlParams_ must be replaced (rather than just value changes) so - // that observers will be notified of the change. - this.controlParams_ = /** @type {chrome.settingsPrivate.PrefObject} */ ( - Object.assign({'value': prefValue}, basePref)); - - const subPrefValue = - this.category == settings.ContentSettingsTypes.COOKIES && - update.setting == settings.ContentSetting.SESSION_ONLY; - // The subControlParams_ must be replaced (rather than just value changes) - // so that observers will be notified of the change. - this.subControlParams_ = /** @type {chrome.settingsPrivate.PrefObject} */ ( - Object.assign({'value': subPrefValue}, basePref)); - }, - - /** - * Handles changes to the category pref and the |category| member variable. - * @private - */ - onCategoryChanged_: function() { - this.browserProxy.getDefaultValueForContentType(this.category) - .then(defaultValue => { - this.updateControlParams_(defaultValue); - - const categoryEnabled = - this.computeIsSettingEnabled(defaultValue.setting); - this.optionLabel_ = - categoryEnabled ? this.toggleOnLabel : this.toggleOffLabel; - }); - }, - - /** - * @return {boolean} - * @private - */ - isToggleDisabled_: function() { - return this.category == settings.ContentSettingsTypes.POPUPS && - loadTimeData.getBoolean('isGuest'); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/category_setting_exceptions.html b/chromium/chrome/browser/resources/settings/site_settings/category_setting_exceptions.html deleted file mode 100644 index 6fb8781c59a..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/category_setting_exceptions.html +++ /dev/null @@ -1,35 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_list.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="category-setting-exceptions"> - <template> - <site-list - category="[[category]]" - category-subtype="[[ContentSetting.BLOCK]]" - category-header="[[blockHeader]]" - read-only-list="[[getReadOnlyList_(readOnlyList, defaultManaged_)]]" - search-filter="[[searchFilter]]" - hidden$="[[!showBlockSiteList_]]"> - </site-list> - <site-list - category="[[category]]" - category-subtype="[[ContentSetting.SESSION_ONLY]]" - category-header="$i18n{siteSettingsSessionOnly}" - read-only-list="[[getReadOnlyList_(readOnlyList, defaultManaged_)]]" - search-filter="[[searchFilter]]"> - </site-list> - <site-list - category="[[category]]" - category-subtype="[[ContentSetting.ALLOW]]" - category-header="$i18n{siteSettingsAllow}" - read-only-list="[[getReadOnlyList_(readOnlyList, defaultManaged_)]]" - search-filter="[[searchFilter]]" - hidden$="[[!showAllowSiteList_]]"> - </site-list> - </template> - <script src="category_setting_exceptions.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/category_setting_exceptions.js b/chromium/chrome/browser/resources/settings/site_settings/category_setting_exceptions.js deleted file mode 100644 index 44997259653..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/category_setting_exceptions.js +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2015 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. - -/** - * @fileoverview - * 'category-setting-exceptions' is the polymer element for showing a certain - * category of exceptions under Site Settings. - */ -Polymer({ - is: 'category-setting-exceptions', - - behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], - - properties: { - - /** - * The string ID of the category that this element is displaying data for. - * See site_settings/constants.js for possible values. - * @type {!settings.ContentSettingsTypes} - */ - category: String, - - /** - * Some content types (like Location) do not allow the user to manually - * edit the exception list from within Settings. - * @private - */ - readOnlyList: { - type: Boolean, - value: false, - }, - - /** - * True if the default value is managed by a policy. - * @private - */ - defaultManaged_: Boolean, - - /** - * The heading text for the blocked exception list. - */ - blockHeader: String, - - searchFilter: String, - - /** - * If true, displays the Allow site list. Defaults to true. - * @private - */ - showAllowSiteList_: { - type: Boolean, - computed: 'computeShowAllowSiteList_(category)', - }, - - /** - * If true, displays the Block site list. Defaults to true. - */ - showBlockSiteList_: { - type: Boolean, - value: true, - }, - }, - - observers: [ - 'updateDefaultManaged_(category)', - ], - - /** @override */ - ready: function() { - this.ContentSetting = settings.ContentSetting; - this.addWebUIListener( - 'contentSettingCategoryChanged', this.updateDefaultManaged_.bind(this)); - }, - - /** - * Hides particular category subtypes if |this.category| does not support the - * content setting of that type. - * @return {boolean} - * @private - */ - computeShowAllowSiteList_: function() { - return this.category != - settings.ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE; - }, - - /** - * Updates whether or not the default value is managed by a policy. - * @private - */ - updateDefaultManaged_: function() { - if (this.category === undefined) { - return; - } - - this.browserProxy.getDefaultValueForContentType(this.category) - .then(update => { - this.defaultManaged_ = - update.source === settings.SiteSettingSource.POLICY; - }); - }, - - /** - * Returns true if this list is explicitly marked as readonly by a consumer - * of this component or if the default value for these exceptions are managed - * by a policy. User should not be able to set exceptions to managed default - * values. - * @return {boolean} - * @private - */ - getReadOnlyList_: function() { - return this.readOnlyList || this.defaultManaged_; - } -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list.html b/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list.html deleted file mode 100644 index af0304159c7..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list.html +++ /dev/null @@ -1,39 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/list_property_update_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-tooltip/paper-tooltip.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="chooser_exception_list_entry.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="chooser-exception-list"> - <template> - <style include="settings-shared"> - paper-tooltip { - --paper-tooltip: var(--cr-tooltip); - } - </style> - - <div class="list-frame" id="empty-list-message" - hidden$="[[hasExceptions_(chooserExceptions.*)]]"> - <div class="list-item secondary">[[emptyListMessage_]]</div> - </div> - - <template is="dom-repeat" items="[[chooserExceptions]]"> - <chooser-exception-list-entry exception="[[item]]" - on-show-tooltip="onShowTooltip_"> - </chooser-exception-list-entry> - </template> - - <paper-tooltip id="tooltip" manual-mode position="top"> - [[tooltipText_]] - </paper-tooltip> - </template> - <script src="chooser_exception_list.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list.js b/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list.js deleted file mode 100644 index 79c7539ca33..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list.js +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2018 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. - -/** - * @fileoverview - * 'chooser-exception-list' shows a list of chooser exceptions for a given - * chooser type. - */ -Polymer({ - is: 'chooser-exception-list', - - behaviors: [ - I18nBehavior, - ListPropertyUpdateBehavior, - SiteSettingsBehavior, - WebUIListenerBehavior, - ], - - properties: { - /** - * Array of chooser exceptions to display in the widget. - * @type {!Array<ChooserException>} - */ - chooserExceptions: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * The string ID of the chooser type that this element is displaying data - * for. - * See site_settings/constants.js for possible values. - * @type {!settings.ChooserType} - */ - chooserType: { - observer: 'chooserTypeChanged_', - type: String, - value: settings.ChooserType.NONE, - }, - - /** @private */ - emptyListMessage_: { - type: String, - value: '', - }, - - /** @private */ - hasIncognito_: Boolean, - - /** @private */ - tooltipText_: String, - }, - - /** @override */ - created: function() { - this.browserProxy_ = - settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); - }, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'contentSettingChooserPermissionChanged', - this.objectWithinChooserTypeChanged_.bind(this)); - this.addWebUIListener( - 'onIncognitoStatusChanged', this.onIncognitoStatusChanged_.bind(this)); - this.browserProxy.updateIncognitoStatus(); - }, - - /** - * Called when a chooser exception changes permission and updates the element - * if |category| is equal to the settings category of this element. - * @param {settings.ContentSettingsTypes} category The content settings type - * that represents this permission category. - * @param {settings.ChooserType} chooserType The content settings type that - * represents the chooser data for this permission. - * @private - */ - objectWithinChooserTypeChanged_: function(category, chooserType) { - if (category === this.category && chooserType === this.chooserType) { - this.chooserTypeChanged_(); - } - }, - - /** - * Called for each chooser-exception-list when incognito is enabled or - * disabled. Only called on change (opening N incognito windows only fires one - * message). Another message is sent when the *last* incognito window closes. - * @private - */ - onIncognitoStatusChanged_: function(hasIncognito) { - this.hasIncognito_ = hasIncognito; - this.populateList_(); - }, - - /** - * Configures the visibility of the widget and shows the list. - * @private - */ - chooserTypeChanged_: function() { - if (this.chooserType == settings.ChooserType.NONE) { - return; - } - - // Set the message to display when the exception list is empty. - switch (this.chooserType) { - case settings.ChooserType.USB_DEVICES: - this.emptyListMessage_ = this.i18n('noUsbDevicesFound'); - break; - case settings.ChooserType.SERIAL_PORTS: - this.emptyListMessage_ = this.i18n('noSerialPortsFound'); - break; - default: - this.emptyListMessage_ = ''; - } - - this.populateList_(); - }, - - /** - * Returns true if there are any chooser exceptions for this chooser type. - * @return {boolean} - * @private - */ - hasExceptions_: function() { - return this.chooserExceptions.length > 0; - }, - - /** - * Need to use a common tooltip since the tooltip in the entry is cut off from - * the iron-list. - * @param{!CustomEvent<!{target: HTMLElement, text: string}>} e - * @private - */ - onShowTooltip_: function(e) { - this.tooltipText_ = e.detail.text; - const target = e.detail.target; - // paper-tooltip normally determines the target from the |for| property, - // which is a selector. Here paper-tooltip is being reused by multiple - // potential targets. - this.$.tooltip.target = target; - const hide = () => { - this.$.tooltip.hide(); - target.removeEventListener('mouseleave', hide); - target.removeEventListener('blur', hide); - target.removeEventListener('tap', hide); - this.$.tooltip.removeEventListener('mouseenter', hide); - }; - target.addEventListener('mouseleave', hide); - target.addEventListener('blur', hide); - target.addEventListener('tap', hide); - this.$.tooltip.addEventListener('mouseenter', hide); - this.$.tooltip.show(); - }, - - /** - * Populate the chooser exception list for display. - * @private - */ - populateList_: function() { - this.browserProxy_.getChooserExceptionList(this.chooserType) - .then(exceptionList => this.processExceptions_(exceptionList)); - }, - - /** - * Process the chooser exception list returned from the native layer. - * @param {!Array<RawChooserException>} exceptionList - * @private - */ - processExceptions_: function(exceptionList) { - const exceptions = exceptionList.map(exception => { - const sites = exception.sites.map(this.expandSiteException); - return Object.assign(exception, {sites}); - }); - - if (!this.updateList( - 'chooserExceptions', x => x.displayName, exceptions, - true /* uidBasedUpdate */)) { - // The chooser objects have not been changed, so check if their site - // permissions have changed. The |exceptions| and |this.chooserExceptions| - // arrays should be the same length. - const siteUidGetter = x => x.origin + x.embeddingOrigin + x.incognito; - exceptions.forEach((exception, index) => { - const propertyPath = 'chooserExceptions.' + index + '.sites'; - this.updateList(propertyPath, siteUidGetter, exception.sites); - }, this); - } - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list_entry.html b/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list_entry.html deleted file mode 100644 index 3bf1c47f580..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list_entry.html +++ /dev/null @@ -1,35 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_list_entry.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="chooser-exception-list-entry"> - <template> - <style include="settings-shared"></style> - - <div class="settings-box first"> - <h2 class="start">[[exception.displayName]]</h2> - </div> - - <div class="list-frame menu-content vertical-list" id="listContainer"> - <iron-list items="[[exception.sites]]" preserve-focus risk-selection> - <template> - <site-list-entry model="[[item]]" - tabindex$="[[tabIndex]]" first$="[[!index]]" - iron-list-tab-index="[[tabIndex]]" - last-focused="{{lastFocused_}}" - chooser-type="[[exception.chooserType]]" - chooser-object="[[exception.object]]" read-only-list> - </site-list-entry> - </template> - </iron-list> - </div> - </template> - <script src="chooser_exception_list_entry.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list_entry.js b/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list_entry.js deleted file mode 100644 index 0e99b6067fd..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/chooser_exception_list_entry.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 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. - -/** - * @fileoverview - * 'chooser-exception-list-entry' shows a single chooser exception for a given - * chooser type. - */ -Polymer({ - is: 'chooser-exception-list-entry', - - behaviors: [SiteSettingsBehavior], - - properties: { - /** - * Chooser exception object to display in the widget. - * @type {!ChooserException} - */ - exception: Object, - - /** @private */ - lastFocused_: Object, - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/constants.html b/chromium/chrome/browser/resources/settings/site_settings/constants.html deleted file mode 100644 index f6c86039d20..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/constants.html +++ /dev/null @@ -1,2 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<script src="constants.js"></script> diff --git a/chromium/chrome/browser/resources/settings/site_settings/constants.js b/chromium/chrome/browser/resources/settings/site_settings/constants.js deleted file mode 100644 index f073aa9b3db..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/constants.js +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2015 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.exportPath('settings'); - -/** - * All possible contentSettingsTypes that we currently support configuring in - * the UI. Both top-level categories and content settings that represent - * individual permissions under Site Details should appear here. - * This should be kept in sync with the |kContentSettingsTypeGroupNames| array - * in chrome/browser/ui/webui/site_settings_helper.cc - * @enum {string} - */ -settings.ContentSettingsTypes = { - COOKIES: 'cookies', - IMAGES: 'images', - JAVASCRIPT: 'javascript', - SOUND: 'sound', - PLUGINS: 'plugins', // AKA Flash. - POPUPS: 'popups', - GEOLOCATION: 'location', - NOTIFICATIONS: 'notifications', - MIC: 'media-stream-mic', // AKA Microphone. - CAMERA: 'media-stream-camera', - PROTOCOL_HANDLERS: 'register-protocol-handler', - UNSANDBOXED_PLUGINS: 'ppapi-broker', - AUTOMATIC_DOWNLOADS: 'multiple-automatic-downloads', - BACKGROUND_SYNC: 'background-sync', - MIDI_DEVICES: 'midi-sysex', - USB_DEVICES: 'usb-devices', - SERIAL_PORTS: 'serial-ports', - ZOOM_LEVELS: 'zoom-levels', - PROTECTED_CONTENT: 'protected-content', - ADS: 'ads', - CLIPBOARD: 'clipboard', - SENSORS: 'sensors', - PAYMENT_HANDLER: 'payment-handler', - MIXEDSCRIPT: 'mixed-script', - BLUETOOTH_SCANNING: 'bluetooth-scanning', - NATIVE_FILE_SYSTEM_WRITE: 'native-file-system-write', -}; - -/** - * Contains the possible string values for a given ContentSettingsTypes. - * This should be kept in sync with the |ContentSetting| enum in - * components/content_settings/core/common/content_settings.h - * @enum {string} - */ -settings.ContentSetting = { - DEFAULT: 'default', - ALLOW: 'allow', - BLOCK: 'block', - ASK: 'ask', - SESSION_ONLY: 'session_only', - IMPORTANT_CONTENT: 'detect_important_content', -}; - -/** - * All possible ChooserTypes that we currently support configuring in the UI. - * This should be kept in sync with the |kChooserTypeGroupNames| array in - * chrome/browser/ui/webui/site_settings_helper.cc - * @enum {string} - */ -settings.ChooserType = { - NONE: '', - USB_DEVICES: 'usb-devices-data', - SERIAL_PORTS: 'serial-ports-data', -}; - -/** - * Contains the possible sources of a ContentSetting. - * This should be kept in sync with the |SiteSettingSource| enum in - * chrome/browser/ui/webui/site_settings_helper.h - * @enum {string} - */ -settings.SiteSettingSource = { - ADS_FILTER_BLACKLIST: 'ads-filter-blacklist', - DEFAULT: 'default', - // This source is for the Protected Media Identifier / Protected Content - // content setting only, which is only available on ChromeOS. - DRM_DISABLED: 'drm-disabled', - EMBARGO: 'embargo', - EXTENSION: 'extension', - INSECURE_ORIGIN: 'insecure-origin', - KILL_SWITCH: 'kill-switch', - POLICY: 'policy', - PREFERENCE: 'preference', -}; - -/** - * A category value to use for the All Sites list. - * @type {string} - */ -settings.ALL_SITES = 'all-sites'; - -/** - * An invalid subtype value. - * @type {string} - */ -settings.INVALID_CATEGORY_SUBTYPE = ''; - -/** - * Contains the possible record action types. - * This should be kept in sync with the |AllSitesAction| enum in - * chrome/browser/ui/webui/settings/site_settings_handler.cc - * @enum {number} - */ -settings.AllSitesAction = { - LOAD_PAGE: 0, - RESET_PERMISSIONS: 1, - CLEAR_DATA: 2, - ENTER_SITE_DETAILS: 3, -}; - -/** - * Contains the possible sort methods. - * @enum {string} - */ -settings.SortMethod = { - NAME: 'name', - MOST_VISITED: 'most-visited', - STORAGE: 'data-stored', -}; - -/** - * String representation of the wildcard used for universal - * match for SiteExceptions. - * @type {string} - */ -settings.SITE_EXCEPTION_WILDCARD = '*'; diff --git a/chromium/chrome/browser/resources/settings/site_settings/cookie_info.html b/chromium/chrome/browser/resources/settings/site_settings/cookie_info.html deleted file mode 100644 index 77485cabf8a..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/cookie_info.html +++ /dev/null @@ -1 +0,0 @@ -<script src="cookie_info.js"></script> diff --git a/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js b/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js deleted file mode 100644 index 91289e40b9e..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2016 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. - -/** - * @typedef {{hasChildren: boolean, - * id: string, - * idPath: string, - * title: string, - * totalUsage: string, - * type: string}} - */ -let CookieDetails; - -/** - * @typedef {{content: string, - * label: string}} - */ -let CookieDataForDisplay; - -// This structure maps the various cookie type names from C++ (hence the -// underscores) to arrays of the different types of data each has, along with -// the i18n name for the description of that data type. -// This structure serves three purposes: -// 1) to list what subset of the cookie data we want to show in the UI. -// 2) What order to show it in. -// 3) What user friendly label to prefix the data with. -const cookieInfo = { - 'cookie': [ - ['name', 'cookieName'], ['content', 'cookieContent'], - ['domain', 'cookieDomain'], ['path', 'cookiePath'], - ['sendfor', 'cookieSendFor'], - ['accessibleToScript', 'cookieAccessibleToScript'], - ['created', 'cookieCreated'], ['expires', 'cookieExpires'] - ], - 'app_cache': [ - ['origin', 'appCacheOrigin'], ['size', 'localStorageSize'], - ['modified', 'localStorageLastModified'] - ], - 'database': [ - ['origin', 'databaseOrigin'], ['size', 'localStorageSize'], - ['modified', 'localStorageLastModified'] - ], - 'local_storage': [ - ['origin', 'localStorageOrigin'], ['size', 'localStorageSize'], - ['modified', 'localStorageLastModified'] - ], - 'indexed_db': [ - ['origin', 'indexedDbOrigin'], ['size', 'indexedDbSize'], - ['modified', 'indexedDbLastModified'] - ], - 'file_system': [ - ['origin', 'fileSystemOrigin'], ['persistent', 'fileSystemPersistentUsage'], - ['temporary', 'fileSystemTemporaryUsage'] - ], - 'service_worker': - [['origin', 'serviceWorkerOrigin'], ['size', 'serviceWorkerSize']], - 'shared_worker': - [['worker', 'sharedWorkerWorker'], ['name', 'sharedWorkerName']], - 'cache_storage': [ - ['origin', 'cacheStorageOrigin'], ['size', 'cacheStorageSize'], - ['modified', 'cacheStorageLastModified'] - ], - 'flash_lso': [['domain', 'cookieDomain']], - 'media_license': [ - ['origin', 'mediaLicenseOrigin'], ['size', 'mediaLicenseSize'], - ['modified', 'mediaLicenseLastModified'] - ], -}; - -/** - * Get cookie data for a given HTML node. - * @param {CookieDetails} data The contents of the cookie. - * @return {!Array<CookieDataForDisplay>} - */ -const getCookieData = function(data) { - /** @type {!Array<CookieDataForDisplay>} */ - const out = []; - const fields = cookieInfo[data.type]; - for (let i = 0; i < fields.length; i++) { - const field = fields[i]; - // Iterate through the keys found in |cookieInfo| for the given |type| - // and see if those keys are present in the data. If so, display them - // (in the order determined by |cookieInfo|). - const key = field[0]; - if (data[key].length > 0) { - const entry = /** @type {CookieDataForDisplay} */ ({ - label: loadTimeData.getString(field[1]), - content: data[key], - }); - out.push(entry); - } - } - return out; -}; diff --git a/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.html b/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.html deleted file mode 100644 index 2bc85d2723c..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.html +++ /dev/null @@ -1,32 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="settings-edit-exception-dialog"> - <template> - <style include="settings-shared"></style> - <cr-dialog id="dialog"> - <div slot="title">$i18n{editSiteTitle}</div> - <div slot="body"> - <cr-input label="$i18n{addSite}" value="{{origin_}}" - placeholder="$i18n{addSiteExceptionPlaceholder}" - on-input="validate_" error-message="{{errorMessage_}}" - invalid="[[invalid_]]" autofocus spellcheck="false"> - </cr-input> - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCancelTap_" - id="cancel">$i18n{cancel}</cr-button> - <cr-button id="actionButton" class="action-button" - on-click="onActionButtonTap_" disabled="[[invalid_]]"> - $i18n{save} - </cr-button> - </div> - </cr-dialog> - </template> - <script src="edit_exception_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js b/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js deleted file mode 100644 index 87bba9081fc..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2017 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. - -/** - * @fileoverview 'settings-edit-exception-dialog' is a component for editing a - * site exception entry. - */ -Polymer({ - is: 'settings-edit-exception-dialog', - - properties: { - /** - * @type {!SiteException} - */ - model: { - type: Object, - observer: 'modelChanged_', - }, - - /** @private */ - origin_: String, - - /** - * The localized error message to display when the pattern is invalid. - * @private - */ - errorMessage_: String, - - /** - * Whether the current input is invalid. - * @private - */ - invalid_: { - type: Boolean, - value: false, - }, - }, - - /** @private {!settings.SiteSettingsPrefsBrowserProxy} */ - browserProxy_: null, - - /** @override */ - attached: function() { - this.browserProxy_ = - settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); - this.origin_ = this.model.origin; - - this.$.dialog.showModal(); - }, - - /** @private */ - onCancelTap_: function() { - this.$.dialog.close(); - }, - - /** @private */ - onActionButtonTap_: function() { - if (this.model.origin != this.origin_) { - // The way to "edit" an exception is to remove it and and a new one. - this.browserProxy_.resetCategoryPermissionForPattern( - this.model.origin, this.model.embeddingOrigin, this.model.category, - this.model.incognito); - - this.browserProxy_.setCategoryPermissionForPattern( - this.origin_, this.origin_, this.model.category, this.model.setting, - this.model.incognito); - } - - this.$.dialog.close(); - }, - - /** @private */ - validate_: function() { - if (this.$$('cr-input').value.trim() == '') { - this.invalid_ = true; - return; - } - - this.browserProxy_.isPatternValidForType(this.origin_, this.model.category) - .then(({isValid, reason}) => { - this.invalid_ = !isValid; - this.errorMessage_ = reason || ''; - }); - }, - - /** @private */ - modelChanged_: function() { - if (!this.model) { - this.$.dialog.cancel(); - } - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.html b/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.html deleted file mode 100644 index 00f30d023ca..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ -<script src="local_data_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js b/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js deleted file mode 100644 index 56112da2884..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2017 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. - -/** - * @fileoverview A helper object used from the Cookies and Local Storage Data - * section. - */ - -/** - * @typedef {{ - * id: string, - * start: number, - * children: !Array<CookieDetails>, - * }} - */ -let CookieList; - -/** - * @typedef {{ - * data: !Object, - * id: string, - * }} - */ -let LocalDataItem; - -/** - * TODO(dschuyler): add |filter| and |order|. - * @typedef {{ - * items: !Array<!LocalDataItem>, - * total: number, - * }} - */ -let LocalDataList; - -/** - * Number of cookies attached to a given domain / eTLD+1. - * @typedef {{ - * etldPlus1: string, - * numCookies: number, - * }} - */ -let EtldPlus1CookieNumber; - -cr.define('settings', function() { - /** @interface */ - class LocalDataBrowserProxy { - /** - * @param {string} filter Search filter (use "" for none). - * @return {!Promise<!LocalDataList>} - */ - getDisplayList(filter) {} - - /** - * Removes all local data (local storage, cookies, etc.). - * Note: on-tree-item-removed will not be sent. - * @return {!Promise} To signal completion. - */ - removeAll() {} - - /** - * Remove items that pass the current filter. Completion signaled by - * on-tree-item-removed. - */ - removeShownItems() {} - - /** - * Remove a specific list item. Completion signaled by on-tree-item-removed. - * @param {string} id Which element to delete. - */ - removeItem(id) {} - - /** - * Gets the cookie details for a particular site. - * @param {string} site The name of the site. - * @return {!Promise<!CookieList>} - */ - getCookieDetails(site) {} - - /** - * Gets the plural string for a given number of cookies. - * @param {number} numCookies The number of cookies. - * @return {!Promise<string>} - */ - getNumCookiesString(numCookies) {} - - /** - * Reloads all local data. - * TODO(dschuyler): rename function to reload(). - * @return {!Promise} To signal completion. - */ - reloadCookies() {} - - /** - * TODO(dschuyler): merge with removeItem(). - * Removes a given cookie. - * @param {string} path The path to the parent cookie. - */ - removeCookie(path) {} - - /** - * Removes all SameSite=None cookies, as well as storage available in - * third-party contexts. - * Note: on-tree-item-removed will not be sent. - * @return {!Promise} To signal completion. - */ - removeAllThirdPartyCookies() {} - } - - /** - * @implements {settings.LocalDataBrowserProxy} - */ - class LocalDataBrowserProxyImpl { - /** @override */ - getDisplayList(filter) { - return cr.sendWithPromise('localData.getDisplayList', filter); - } - - /** @override */ - removeAll() { - return cr.sendWithPromise('localData.removeAll'); - } - - /** @override */ - removeShownItems() { - chrome.send('localData.removeShownItems'); - } - - /** @override */ - removeItem(id) { - chrome.send('localData.removeItem', [id]); - } - - /** @override */ - getCookieDetails(site) { - return cr.sendWithPromise('localData.getCookieDetails', site); - } - - /** @override */ - getNumCookiesString(numCookies) { - return cr.sendWithPromise('localData.getNumCookiesString', numCookies); - } - - /** @override */ - reloadCookies() { - return cr.sendWithPromise('localData.reload'); - } - - /** @override */ - removeCookie(path) { - chrome.send('localData.removeCookie', [path]); - } - - /** @override */ - removeAllThirdPartyCookies() { - return cr.sendWithPromise('localData.removeThirdPartyCookies'); - } - } - - // The singleton instance_ is replaced with a test version of this wrapper - // during testing. - cr.addSingletonGetter(LocalDataBrowserProxyImpl); - - return { - LocalDataBrowserProxy: LocalDataBrowserProxy, - LocalDataBrowserProxyImpl: LocalDataBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/media_picker.html b/chromium/chrome/browser/resources/settings/site_settings/media_picker.html deleted file mode 100644 index 92f8c15fdf3..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/media_picker.html +++ /dev/null @@ -1,24 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../settings_vars_css.html"> - -<dom-module id="media-picker"> - <template> - <style include="settings-shared md-select"> - :host { - display: block; - } - </style> - <div class="settings-box first" id="picker" hidden> - <select id="mediaPicker" class="md-select" on-change="onChange_" - aria-label$="[[label]]"> - <template is="dom-repeat" items="[[devices]]"> - <option value$="[[item.id]]">[[item.name]]</option> - </template> - </select> - </div> - </template> - <script src="media_picker.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/media_picker.js b/chromium/chrome/browser/resources/settings/site_settings/media_picker.js deleted file mode 100644 index 85137a83a2a..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/media_picker.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'media-picker' handles showing the dropdown allowing users to select the - * default camera/microphone. - */ -Polymer({ - is: 'media-picker', - - behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], - - properties: { - /** - * The type of media picker, either 'camera' or 'mic'. - */ - type: String, - - /** Label for a11y purposes. */ - label: String, - - /** - * The devices available to pick from. - * @type {Array<MediaPickerEntry>} - */ - devices: Array, - }, - - /** @override */ - ready: function() { - this.addWebUIListener( - 'updateDevicesMenu', this.updateDevicesMenu_.bind(this)); - this.browserProxy.getDefaultCaptureDevices(this.type); - }, - - /** - * Updates the microphone/camera devices menu with the given entries. - * @param {string} type The device type. - * @param {!Array<MediaPickerEntry>} devices List of available devices. - * @param {string} defaultDevice The unique id of the current default device. - */ - updateDevicesMenu_: function(type, devices, defaultDevice) { - if (type != this.type) { - return; - } - - this.$.picker.hidden = devices.length == 0; - if (devices.length > 0) { - this.devices = devices; - - // Wait for <select> to be populated. - this.async(() => { - this.$.mediaPicker.value = defaultDevice; - }); - } - }, - - /** - * A handler for when an item is selected in the media picker. - * @private - */ - onChange_: function() { - this.browserProxy.setDefaultCaptureDevice( - this.type, this.$.mediaPicker.value); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/pdf_documents.html b/chromium/chrome/browser/resources/settings/site_settings/pdf_documents.html deleted file mode 100644 index a6a0b7cdcfe..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/pdf_documents.html +++ /dev/null @@ -1,19 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="../controls/settings_toggle_button.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-pdf-documents"> - <template> - <style include="settings-shared"> - .secondary { - margin-top: 0; /* Cancel separation between main and secondary text. */ - } - </style> - <settings-toggle-button id="toggle" class="first two-line" - label="$i18n{siteSettingsPdfDownloadPdfs}" - pref="{{prefs.plugins.always_open_pdf_externally}}"> - </settings-toggle-button> - </template> - <script src="pdf_documents.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/pdf_documents.js b/chromium/chrome/browser/resources/settings/site_settings/pdf_documents.js deleted file mode 100644 index 66f61a6db59..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/pdf_documents.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'settings-pdf-documents' is the polymer element for showing the - * settings for viewing PDF documents under Site Settings. - */ - -Polymer({ - is: 'settings-pdf-documents', - - properties: { - prefs: { - type: Object, - notify: true, - }, - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html deleted file mode 100644 index 269709ab022..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html +++ /dev/null @@ -1,103 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../site_favicon.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="protocol-handlers"> - <template> - <style include="settings-shared"> - :host { - display: block; - } - - .column-header { - margin-bottom: 15px; - margin-inline-start: 20px; - margin-top: 15px; - } - </style> - <div class="settings-box first two-line"> - <div id="categoryLabel" class="start" on-click="categoryLabelClicked_" - actionable> - [[computeHandlersDescription_(categoryEnabled)]] - </div> - <cr-toggle id="toggle" checked="{{categoryEnabled}}" - on-change="onToggleChange_" aria-labelledby="categoryLabel"> - </cr-toggle> - </div> - - <template is="dom-repeat" items="[[protocols]]" as="protocol"> - <div class="column-header">[[protocol.protocol_display_name]]</div> - - <div class="list-frame menu-content vertical-list"> - <template is="dom-repeat" items="[[protocol.handlers]]"> - - <div class="list-item"> - <site-favicon url="[[item.host]]"></site-favicon> - <div class="middle" > - <div class="protocol-host"> - <span class="url-directionality">[[item.host]]</span> - </div> - <div class="secondary protocol-default" - hidden$="[[!item.is_default]]"> - $i18n{handlerIsDefault} - </div> - </div> - - <cr-icon-button class="icon-more-vert" on-click="showMenu_" - title="$i18n{moreActions}"></cr-icon-button> - </div> - </template> - </div> - </template> - - <cr-action-menu> - <button class="dropdown-item" on-click="onDefaultClick_" - id="defaultButton" hidden$="[[actionMenuModel_.is_default]]"> - $i18n{handlerSetDefault} - </button> - <button class="dropdown-item" on-click="onRemoveClick_" - id="removeButton"> - $i18n{handlerRemove} - </button> - </cr-action-menu> - - <template is="dom-if" if="[[ignoredProtocols.length]]"> - <div class="column-header">$i18n{siteSettingsBlocked}</div> - <div class="list-frame menu-content vertical-list"> - <template is="dom-repeat" items="[[ignoredProtocols]]"> - <div class="list-item"> - <site-favicon url="[[item.host]]"></site-favicon> - <div class="middle" > - <div class="protocol-host"> - <span class="url-directionality">[[item.host]]</span></div> - <div class="secondary protocol-protocol"> - [[item.protocol_display_name]] - </div> - </div> - <cr-icon-button class="icon-clear" id="removeIgnoredButton" - on-click="onRemoveIgnored_" title="$i18n{handlerRemove}"> - </cr-icon-button> - </div> - </template> - </div> - </template> - -<if expr="chromeos"> - <template is="dom-if" if="[[settingsAppAvailable_]]"> - <cr-link-row on-click="onManageAndroidAppsClick_" - label="$i18n{androidAppsManageAppLinks}" external></cr-link-row> - </template> -</if> - </template> - <script src="protocol_handlers.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js deleted file mode 100644 index 5fe1b814e49..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js +++ /dev/null @@ -1,222 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'protocol-handlers' is the polymer element for showing the - * protocol handlers category under Site Settings. - */ - -/** - * All possible actions in the menu. - * @enum {string} - */ -const MenuActions = { - SET_DEFAULT: 'SetDefault', - REMOVE: 'Remove', -}; - -/** - * @typedef {{host: string, - * is_default: boolean, - * protocol: string, - * protocol_display_name: string, - * spec: string}} - */ -let HandlerEntry; - -/** - * @typedef {{handlers: !Array<!HandlerEntry>, - * protocol: string, - * protocol_display_name: string}} - */ -let ProtocolEntry; - -Polymer({ - is: 'protocol-handlers', - - behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], - - properties: { - /** - * Represents the state of the main toggle shown for the category. - */ - categoryEnabled: Boolean, - - /** - * Array of protocols and their handlers. - * @type {!Array<!ProtocolEntry>} - */ - protocols: Array, - - /** - * The targetted object for menu operations. - * @private {?HandlerEntry} - */ - actionMenuModel_: Object, - - /* Labels for the toggle on/off positions. */ - toggleOffLabel: String, - toggleOnLabel: String, - - /** - * Array of ignored (blocked) protocols. - * @type {!Array<!HandlerEntry>} - */ - ignoredProtocols: Array, - - // <if expr="chromeos"> - /** @private */ - settingsAppAvailable_: { - type: Boolean, - value: false, - }, - // </if> - }, - - /** @override */ - ready: function() { - this.addWebUIListener( - 'setHandlersEnabled', this.setHandlersEnabled_.bind(this)); - this.addWebUIListener( - 'setProtocolHandlers', this.setProtocolHandlers_.bind(this)); - this.addWebUIListener( - 'setIgnoredProtocolHandlers', - this.setIgnoredProtocolHandlers_.bind(this)); - this.browserProxy.observeProtocolHandlers(); - }, - - // <if expr="chromeos"> - /** @override */ - attached: function() { - if (settings.AndroidAppsBrowserProxyImpl) { - cr.addWebUIListener( - 'android-apps-info-update', this.androidAppsInfoUpdate_.bind(this)); - settings.AndroidAppsBrowserProxyImpl.getInstance() - .requestAndroidAppsInfo(); - } - }, - // </if> - - // <if expr="chromeos"> - /** - * Receives updates on whether or not ARC settings app is available. - * @param {AndroidAppsInfo} info - * @private - */ - androidAppsInfoUpdate_: function(info) { - this.settingsAppAvailable_ = info.settingsAppAvailable; - }, - // </if> - - /** @private */ - categoryLabelClicked_: function() { - this.$.toggle.click(); - }, - - /** - * Obtains the description for the main toggle. - * @return {string} The description to use. - * @private - */ - computeHandlersDescription_: function() { - return this.categoryEnabled ? this.toggleOnLabel : this.toggleOffLabel; - }, - - /** - * Updates the main toggle to set it enabled/disabled. - * @param {boolean} enabled The state to set. - * @private - */ - setHandlersEnabled_: function(enabled) { - this.categoryEnabled = enabled; - }, - - /** - * Updates the list of protocol handlers. - * @param {!Array<!ProtocolEntry>} protocols The new protocol handler list. - * @private - */ - setProtocolHandlers_: function(protocols) { - this.protocols = protocols; - }, - - /** - * Updates the list of ignored protocol handlers. - * @param {!Array<!HandlerEntry>} ignoredProtocols The new (ignored) protocol - * handler list. - * @private - */ - setIgnoredProtocolHandlers_: function(ignoredProtocols) { - this.ignoredProtocols = ignoredProtocols; - }, - - /** - * Closes action menu and resets action menu model - * @private - */ - closeActionMenu_: function() { - this.$$('cr-action-menu').close(); - this.actionMenuModel_ = null; - }, - - /** - * A handler when the toggle is flipped. - * @private - */ - onToggleChange_: function(event) { - this.browserProxy.setProtocolHandlerDefault(this.categoryEnabled); - }, - - /** - * The handler for when "Set Default" is selected in the action menu. - * @private - */ - onDefaultClick_: function() { - const item = this.actionMenuModel_; - this.browserProxy.setProtocolDefault(item.protocol, item.spec); - this.closeActionMenu_(); - }, - - /** - * The handler for when "Remove" is selected in the action menu. - * @private - */ - onRemoveClick_: function() { - const item = this.actionMenuModel_; - this.browserProxy.removeProtocolHandler(item.protocol, item.spec); - this.closeActionMenu_(); - }, - - /** - * Handler for removing handlers that were blocked - * @private - */ - onRemoveIgnored_: function(event) { - const item = event.model.item; - this.browserProxy.removeProtocolHandler(item.protocol, item.spec); - }, - - /** - * A handler to show the action menu next to the clicked menu button. - * @param {!{model: !{item: HandlerEntry}}} event - * @private - */ - showMenu_: function(event) { - this.actionMenuModel_ = event.model.item; - /** @type {!CrActionMenuElement} */ (this.$$('cr-action-menu')) - .showAt( - /** @type {!Element} */ (/** @type {!Event} */ (event).target)); - }, - - // <if expr="chromeos"> - /** - * Opens an activity to handle App links (preferred apps). - * @private - */ - onManageAndroidAppsClick_: function() { - this.browserProxy.showAndroidManageAppLinks(); - }, - // </if> -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data.html b/chromium/chrome/browser/resources/settings/site_settings/site_data.html deleted file mode 100644 index f1a028c92b5..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data.html +++ /dev/null @@ -1,101 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/list_property_update_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_search_field.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html"> -<link rel="import" href="../global_scroll_target_behavior.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="cookie_info.html"> -<link rel="import" href="local_data_browser_proxy.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_data_entry.html"> - -<dom-module id="site-data"> - <template> - <style include="settings-shared"> - paper-spinner-lite { - @apply --cr-icon-height-width; - opacity: 0; - transition-delay: 1s; - } - - paper-spinner-lite[active] { - opacity: 1; - } - - #removeShowingSites { - margin-inline-start: auto; - } - </style> - <div class="settings-box continuation"> - <paper-spinner-lite active="[[isLoading_]]"></paper-spinner-lite> - <cr-button disabled$="[[isLoading_]]" id="removeShowingSites" - on-click="onRemoveShowingSitesTap_" hidden$="[[!sites.length]]"> - [[computeRemoveLabel_(filter)]] - </cr-button> - <cr-button disabled$="[[isLoading_]]" id="removeThirdPartyCookies" - on-click="onRemoveThirdPartyCookiesTap_" - hidden$="[[!showRemoveThirdPartyCookies_(sites.length, filter)]]"> - $i18n{siteSettingsCookieRemoveAllThirdParty} - </cr-button> - </div> - <iron-list id="list" items="[[sites]]" preserve-focus - scroll-target="[[subpageScrollTarget]]" class="cr-separators"> - <template> - <site-data-entry id$="siteItem_[[item.site]]" actionable - model="[[item]]" first$="[[!index]]" tabindex$="[[tabIndex]]" - iron-list-tab-index="[[tabIndex]]" last-focused="{{lastFocused_}}" - list-blurred="{{listBlurred_}}" on-click="onSiteClick_" - on-remove-site="onRemoveSite_"> - </site-data-entry> - </template> - </iron-list> - - <!-- Confirm Delete dialog --> - <cr-dialog id="confirmDeleteDialog" close-text="$i18n{close}" - on-close="onConfirmDeleteDialogClosed_"> - <div slot="title"> - $i18n{siteSettingsCookieRemoveDialogTitle} - </div> - <div slot="body">$i18n{siteSettingsCookieRemoveMultipleConfirmation}</div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCloseDialog_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onConfirmDelete_"> - $i18n{siteSettingsCookiesClearAll} - </cr-button> - </div> - </cr-dialog> - - <!-- Confirm Delete Third Party Cookies dialog --> - <cr-dialog id="confirmDeleteThirdPartyDialog" close-text="$i18n{close}" - on-close="onConfirmDeleteThirdPartyDialogClosed_"> - <div slot="title"> - $i18n{siteSettingsCookieRemoveThirdPartyDialogTitle} - </div> - <div slot="body"> - $i18n{siteSettingsCookieRemoveThirdPartyConfirmation} - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCloseThirdPartyDialog_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onConfirmThirdPartyDelete_"> - $i18n{siteSettingsCookiesClearThirdParty} - </cr-button> - </div> - </cr-dialog> - - </template> - <script src="site_data.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data.js b/chromium/chrome/browser/resources/settings/site_settings/site_data.js deleted file mode 100644 index cd6370aa91c..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data.js +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'site-data' handles showing the local storage summary list for all sites. - */ - -/** - * @typedef {{ - * site: string, - * id: string, - * localData: string, - * }} - */ -let CookieDataSummaryItem; - -/** - * @typedef {{ - * id: string, - * start: number, - * count: number, - * }} - */ -let CookieRemovePacket; - -Polymer({ - is: 'site-data', - - behaviors: [ - I18nBehavior, - ListPropertyUpdateBehavior, - settings.GlobalScrollTargetBehavior, - WebUIListenerBehavior, - ], - - properties: { - /** - * The current filter applied to the cookie data list. - */ - filter: { - observer: 'updateSiteList_', - notify: true, - type: String, - }, - - /** @type {!Map<string, (string|Function)>} */ - focusConfig: { - type: Object, - observer: 'focusConfigChanged_', - }, - - isLoading_: Boolean, - - /** @type {!Array<!CookieDataSummaryItem>} */ - sites: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * settings.GlobalScrollTargetBehavior - * @override - */ - subpageRoute: { - type: Object, - value: settings.routes.SITE_SETTINGS_SITE_DATA, - }, - - /** @private */ - lastFocused_: Object, - - /** @private */ - listBlurred_: Boolean, - }, - - /** @private {settings.LocalDataBrowserProxy} */ - browserProxy_: null, - - /** - * When navigating to site data details sub-page, |lastSelected_| holds the - * site name as well as the index of the selected site. This is used when - * navigating back to site data in order to focus on the correct site. - * @private {!{item: CookieDataSummaryItem, index: number}|null} - */ - lastSelected_: null, - - /** @override */ - ready: function() { - this.browserProxy_ = settings.LocalDataBrowserProxyImpl.getInstance(); - this.addWebUIListener( - 'on-tree-item-removed', this.updateSiteList_.bind(this)); - }, - - /** - * Reload cookies when the site data page is visited. - * - * settings.RouteObserverBehavior - * @param {!settings.Route} currentRoute - * @protected - */ - currentRouteChanged: function(currentRoute) { - settings.GlobalScrollTargetBehaviorImpl.currentRouteChanged.call( - this, currentRoute); - if (currentRoute == settings.routes.SITE_SETTINGS_SITE_DATA) { - this.isLoading_ = true; - // Needed to fix iron-list rendering issue. The list will not render - // correctly until a scroll occurs. - // See https://crbug.com/853906. - const ironList = /** @type {!IronListElement} */ (this.$$('iron-list')); - ironList.scrollToIndex(0); - this.browserProxy_.reloadCookies().then(this.updateSiteList_.bind(this)); - } - }, - - /** - * @param {!Map<string, (string|Function)>} newConfig - * @param {?Map<string, (string|Function)>} oldConfig - * @private - */ - focusConfigChanged_: function(newConfig, oldConfig) { - // focusConfig is set only once on the parent, so this observer should only - // fire once. - assert(!oldConfig); - - // Populate the |focusConfig| map of the parent <settings-animated-pages> - // element, with additional entries that correspond to subpage trigger - // elements residing in this element's Shadow DOM. - if (settings.routes.SITE_SETTINGS_DATA_DETAILS) { - const onNavigatedTo = () => this.async(() => { - if (this.lastSelected_ == null || this.sites.length == 0) { - return; - } - - const lastSelectedSite = this.lastSelected_.item.site; - const lastSelectedIndex = this.lastSelected_.index; - this.lastSelected_ = null; - - const indexFromId = - this.sites.findIndex(site => site.site == lastSelectedSite); - - // If the site is no longer in |sites|, use the index as a fallback. - // Since the sites are sorted, an alternative could be to select the - // site that comes next in sort order. - const indexFallback = lastSelectedIndex < this.sites.length ? - lastSelectedIndex : - this.sites.length - 1; - const index = indexFromId > -1 ? indexFromId : indexFallback; - this.focusOnSiteSelectButton_(index); - }); - this.focusConfig.set( - settings.routes.SITE_SETTINGS_DATA_DETAILS.path, onNavigatedTo); - } - }, - - /** - * @param {number} index - * @private - */ - focusOnSiteSelectButton_: function(index) { - const ironList = - /** @type {!IronListElement} */ (this.$$('iron-list')); - ironList.focusItem(index); - const siteToSelect = this.sites[index].site.replace(/[.]/g, '\\.'); - const button = this.$$(`#siteItem_${siteToSelect}`).$$('.subpage-arrow'); - cr.ui.focusWithoutInk(assert(button)); - }, - - /** - * Gather all the site data. - * @private - */ - updateSiteList_: function() { - this.isLoading_ = true; - this.browserProxy_.getDisplayList(this.filter).then(listInfo => { - this.updateList('sites', item => item.site, listInfo.items); - this.isLoading_ = false; - this.fire('site-data-list-complete'); - }); - }, - - /** - * Returns the string to use for the Remove label. - * @param {string} filter The current filter string. - * @return {string} - * @private - */ - computeRemoveLabel_: function(filter) { - if (filter.length == 0) { - return loadTimeData.getString('siteSettingsCookieRemoveAll'); - } - return loadTimeData.getString('siteSettingsCookieRemoveAllShown'); - }, - - /** @private */ - onCloseDialog_: function() { - this.$.confirmDeleteDialog.close(); - }, - - /** @private */ - onCloseThirdPartyDialog_: function() { - this.$.confirmDeleteThirdPartyDialog.close(); - }, - - /** @private */ - onConfirmDeleteDialogClosed_: function() { - cr.ui.focusWithoutInk(assert(this.$.removeShowingSites)); - }, - - /** @private */ - onConfirmDeleteThirdPartyDialogClosed_: function() { - cr.ui.focusWithoutInk(assert(this.$.removeAllThirdPartyCookies)); - }, - - /** - * Shows a dialog to confirm the deletion of multiple sites. - * @param {!Event} e - * @private - */ - onRemoveShowingSitesTap_: function(e) { - e.preventDefault(); - this.$.confirmDeleteDialog.showModal(); - }, - - /** - * Shows a dialog to confirm the deletion of cookies available - * in third-party contexts and associated site data. - * @private - */ - onRemoveThirdPartyCookiesTap_: function(e) { - e.preventDefault(); - this.$.confirmDeleteThirdPartyDialog.showModal(); - }, - - /** - * Called when deletion for all showing sites has been confirmed. - * @private - */ - onConfirmDelete_: function() { - this.$.confirmDeleteDialog.close(); - if (this.filter.length == 0) { - this.browserProxy_.removeAll().then(() => { - this.sites = []; - }); - } else { - this.browserProxy_.removeShownItems(); - // We just deleted all items found by the filter, let's reset the filter. - this.fire('clear-subpage-search'); - } - }, - - /** - * Called when deletion of all third-party cookies and site data has been - * confirmed. - * @private - */ - onConfirmThirdPartyDelete_: function() { - this.$.confirmDeleteThirdPartyDialog.close(); - this.browserProxy_.removeAllThirdPartyCookies().then(() => { - this.updateSiteList_(); - }); - }, - - /** - * @param {!{model: !{item: CookieDataSummaryItem, index: number}}} event - * @private - */ - onSiteClick_: function(event) { - // If any delete button is selected, the focus will be in a bad state when - // returning to this page. To avoid this, the site select button is given - // focus. See https://crbug.com/872197. - this.focusOnSiteSelectButton_(event.model.index); - settings.navigateTo( - settings.routes.SITE_SETTINGS_DATA_DETAILS, - new URLSearchParams('site=' + event.model.item.site)); - this.lastSelected_ = event.model; - }, - - /** - * @private - * @return {boolean} - */ - showRemoveThirdPartyCookies_: function() { - return loadTimeData.getBoolean('enableRemovingAllThirdPartyCookies') && - this.sites.length > 0 && this.filter.length == 0; - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html b/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html deleted file mode 100644 index c4529c642a5..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.html +++ /dev/null @@ -1,48 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="cookie_info.html"> -<link rel="import" href="local_data_browser_proxy.html"> - -<dom-module id="site-data-details-subpage"> - <template> - <style include="settings-shared md-select"> - [first] { - border-top: none; - } - - .secondary, - .start { - max-width: 100%; - word-break: break-word; - } - </style> - <template is="dom-repeat" items="[[entries_]]"> - <div class="settings-box" first$="[[!index]]"> - <cr-expand-button class="start" expanded="{{item.expanded_}}"> - [[getEntryDescription_(item)]] - </cr-expand-button> - <div class="separator"></div> - <cr-icon-button class="icon-clear" data-id-path$="[[item.idPath]]" - on-click="onRemove_"></cr-icon-button> - </div> - <iron-collapse class="list-frame vertical-list" - opened="[[item.expanded_]]"> - <template is="dom-repeat" items="[[getCookieNodes_(item)]]"> - <div class="list-item two-line"> - <div class="start"> - [[item.label]] - <div class="secondary">[[item.content]]</div> - </div> - </div> - </template> - </iron-collapse> - </template> - </template> - <script src="site_data_details_subpage.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js b/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js deleted file mode 100644 index 37ca12214f4..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright 2015 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. - -(function() { -'use strict'; - -const categoryLabels = { - app_cache: loadTimeData.getString('cookieAppCache'), - cache_storage: loadTimeData.getString('cookieCacheStorage'), - database: loadTimeData.getString('cookieDatabaseStorage'), - file_system: loadTimeData.getString('cookieFileSystem'), - flash_lso: loadTimeData.getString('cookieFlashLso'), - indexed_db: loadTimeData.getString('cookieDatabaseStorage'), - local_storage: loadTimeData.getString('cookieLocalStorage'), - service_worker: loadTimeData.getString('cookieServiceWorker'), - shared_worker: loadTimeData.getString('cookieSharedWorker'), - media_license: loadTimeData.getString('cookieMediaLicense'), -}; - -/** - * 'site-data-details-subpage' Display cookie contents. - */ -Polymer({ - is: 'site-data-details-subpage', - - behaviors: [settings.RouteObserverBehavior, WebUIListenerBehavior], - - properties: { - /** - * The cookie entries for the given site. - * @type {!Array<!CookieDetails>} - * @private - */ - entries_: Array, - - /** Set the page title on the settings-subpage parent. */ - pageTitle: { - type: String, - notify: true, - }, - - /** @private */ - site_: String, - - /** @private */ - siteId_: String, - }, - - /** - * The browser proxy used to retrieve and change cookies. - * @private {?settings.LocalDataBrowserProxy} - */ - browserProxy_: null, - - /** @override */ - ready: function() { - this.browserProxy_ = settings.LocalDataBrowserProxyImpl.getInstance(); - - this.addWebUIListener( - 'on-tree-item-removed', this.getCookieDetails_.bind(this)); - }, - - /** - * settings.RouteObserverBehavior - * @param {!settings.Route} route - * @protected - */ - currentRouteChanged: function(route) { - if (settings.getCurrentRoute() != - settings.routes.SITE_SETTINGS_DATA_DETAILS) { - return; - } - const site = settings.getQueryParameters().get('site'); - if (!site) { - return; - } - this.site_ = site; - this.pageTitle = loadTimeData.getStringF('siteSettingsCookieSubpage', site); - this.getCookieDetails_(); - }, - - /** @private */ - getCookieDetails_: function() { - if (!this.site_) { - return; - } - this.browserProxy_.getCookieDetails(this.site_) - .then( - this.onCookiesLoaded_.bind(this), - this.onCookiesLoadFailed_.bind(this)); - }, - - /** - * @return {!Array<!CookieDataForDisplay>} - * @private - */ - getCookieNodes_: function(node) { - return getCookieData(node); - }, - - /** - * @param {!CookieList} cookies - * @private - */ - onCookiesLoaded_: function(cookies) { - this.siteId_ = cookies.id; - this.entries_ = cookies.children; - // Set up flag for expanding cookie details. - this.entries_.forEach(function(e) { - e.expanded_ = false; - }); - }, - - /** - * The site was not found. E.g. The site data may have been deleted or the - * site URL parameter may be mistyped. - * @private - */ - onCookiesLoadFailed_: function() { - this.siteId_ = ''; - this.entries_ = []; - }, - - /** - * A handler for when the user opts to remove a single cookie. - * @param {!CookieDetails} item - * @return {string} - * @private - */ - getEntryDescription_: function(item) { - // Frequently there are multiple cookies per site. To avoid showing a list - // of '1 cookie', '1 cookie', ... etc, it is better to show the title of the - // cookie to differentiate them. - if (item.type == 'cookie') { - return item.title; - } - if (item.type == 'quota') { - return item.totalUsage; - } - return categoryLabels[item.type]; - }, - - /** - * A handler for when the user opts to remove a single cookie. - * @param {!Event} event - * @private - */ - onRemove_: function(event) { - this.browserProxy_.removeCookie( - /** @type {!CookieDetails} */ (event.currentTarget.dataset).idPath); - }, - - /** - * A handler for when the user opts to remove all cookies. - */ - removeAll: function() { - this.browserProxy_.removeCookie(this.siteId_); - }, -}); - -})(); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data_entry.html b/chromium/chrome/browser/resources/settings/site_settings/site_data_entry.html deleted file mode 100644 index 5585d9a34c3..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data_entry.html +++ /dev/null @@ -1,35 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_row_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../site_favicon.html"> -<link rel="import" href="cookie_info.html"> - -<dom-module id="site-data-entry"> - <template> - <style include="settings-shared"> - .settings-box { - border: none; - } - </style> - <div class="settings-box two-line site-item" focus-row-container actionable> - <site-favicon url="[[model.site]]"></site-favicon> - <div class="middle"> - <span class="url-directionality">[[model.site]]</span> - <div class="secondary">[[model.localData]]</div> - </div> - <cr-icon-button class="subpage-arrow" aria-label$="[[model.site]]" - focus-row-control focus-type="showDetails"></cr-icon-button> - <div class="separator"></div> - <cr-icon-button class="icon-delete-gray" - title$="[[i18n('siteSettingsCookieRemoveSite', model.site)]]" - on-click="onRemove_" focus-row-control focus-type="remove"> - </cr-icon-button> - </div> - </template> - <script src="site_data_entry.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data_entry.js b/chromium/chrome/browser/resources/settings/site_settings/site_data_entry.js deleted file mode 100644 index 0c5e30c27e7..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data_entry.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 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. - -/** - * @fileoverview - * 'site-data-entry' handles showing the local storage summary for a site. - */ - -Polymer({ - is: 'site-data-entry', - - behaviors: [ - cr.ui.FocusRowBehavior, - I18nBehavior, - ], - - properties: { - /** @type {!CookieDataSummaryItem} */ - model: Object, - }, - - /** @private {settings.LocalDataBrowserProxy} */ - browserProxy_: null, - - /** @override */ - ready: function() { - this.browserProxy_ = settings.LocalDataBrowserProxyImpl.getInstance(); - }, - - /** - * Deletes all site data for this site. - * @param {!Event} e - * @private - */ - onRemove_: function(e) { - e.stopPropagation(); - this.browserProxy_.removeItem(this.model.site); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details.html b/chromium/chrome/browser/resources/settings/site_settings/site_details.html deleted file mode 100644 index fb24557a8e0..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details.html +++ /dev/null @@ -1,232 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/action_link.html"> -<link rel="import" href="chrome://resources/cr_elements/action_link_css.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_details_permission.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="website_usage_private_api.html"> - -<dom-module id="site-details"> - <template> - <style include="settings-shared action-link"> - .favicon-image { - margin: 2px; - } - - #storage { - padding-inline-end: 0; - } - - #storageText { - display: flex; - } - - #resetSettingsButton { - margin-top: 24px; - } - </style> - <!-- Confirm reset settings dialog. --> - <cr-dialog id="confirmResetSettings" close-text="$i18n{close}" - on-close="onResetSettingsDialogClosed_"> - <div slot="body"> - [[i18n('siteSettingsSiteResetConfirmation', pageTitle)]] - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCloseDialog_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onResetSettings_"> - $i18n{siteSettingsSiteResetAll} - </cr-button> - </div> - </cr-dialog> - - <!-- Confirm clear storage dialog. --> - <cr-dialog id="confirmClearStorage" close-text="$i18n{close}" - on-close="onClearStorageDialogClosed_"> - <div slot="title"> - $i18n{siteSettingsSiteClearStorageDialogTitle} - </div> - <div slot="body"> - [[i18n('siteSettingsSiteClearStorageConfirmation', pageTitle)]] - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCloseDialog_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onClearStorage_"> - $i18n{siteSettingsSiteClearStorage} - </cr-button> - </div> - </cr-dialog> - - <div id="usage"> - <div class="settings-box first line-only"> - <h2 class="first">$i18n{siteSettingsUsage}</h2> - </div> - <div class="list-frame"> - <div class="list-item" id="noStorage" - hidden$="[[hasUsage_(storedData_, numCookies_)]]"> - <div class="start">$i18n{siteSettingsUsageNone}</div> - </div> - <div class="list-item" id="storage" - hidden$="[[!hasUsage_(storedData_, numCookies_)]]"> - <div class="start" id="storageText"> - <div hidden$="[[!storedData_]]">[[storedData_]]</div> - <div hidden$="[[!hasDataAndCookies_(storedData_, numCookies_)]]"> - · - </div> - <div hidden$="[[!numCookies_]]">[[numCookies_]]</div> - </div> - <cr-button id="clearStorage" role="button" aria-disabled="false" - on-click="onConfirmClearStorage_" - aria-label="$i18n{siteSettingsDelete}"> - $i18n{siteSettingsDelete} - </cr-button> - </div> - </div> - </div> - - <div class="settings-box first"> - <h2 class="start">$i18n{siteSettingsPermissions}</h2> - <cr-button id="resetSettingsButton" class="header-aligned-button" - role="button" aria-disabled="false" - on-click="onConfirmClearSettings_"> - $i18n{siteSettingsReset} - </cr-button> - </div> - <div class="list-frame"> - <site-details-permission category="{{ContentSettingsTypes.GEOLOCATION}}" - icon="cr:location-on" id="geolocation" - label="$i18n{siteSettingsLocation}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.CAMERA}}" - icon="cr:videocam" id="camera" - label="$i18n{siteSettingsCamera}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.MIC}}" - icon="cr:mic" id="mic" - label="$i18n{siteSettingsMic}"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.SENSORS}}" - icon="settings:sensors" id="sensors" - label="$i18n{siteSettingsSensors}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.NOTIFICATIONS}}" - icon="settings:notifications" id="notifications" - label="$i18n{siteSettingsNotifications}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.JAVASCRIPT}}" - icon="settings:code" id="javascript" - label="$i18n{siteSettingsJavascript}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.PLUGINS}}" - icon="cr:extension" id="plugins" label="$i18n{siteSettingsFlash}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.IMAGES}}" - icon="settings:photo" id="images" label="$i18n{siteSettingsImages}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.POPUPS}}" - icon="cr:open-in-new" id="popups" label="$i18n{siteSettingsPopups}"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.ADS}}" - icon="settings:ads" id="ads" - label="$i18n{siteSettingsAds}"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.BACKGROUND_SYNC}}" - icon="cr:sync" id="backgroundSync" - label="$i18n{siteSettingsBackgroundSync}"> - </site-details-permission> - <site-details-permission category="{{ContentSettingsTypes.SOUND}}" - icon="settings:volume-up" id="sound" - label="$i18n{siteSettingsSound}" - use-automatic-label="[[blockAutoplayEnabled]]"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.AUTOMATIC_DOWNLOADS}}" - icon="cr:file-download" id="automaticDownloads" - label="$i18n{siteSettingsAutomaticDownloads}"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.MIDI_DEVICES}}" icon="settings:midi" - id="midiDevices" label="$i18n{siteSettingsMidiDevices}"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.USB_DEVICES}}" icon="settings:usb" - id="usbDevices" label="$i18n{siteSettingsUsbDevices}"> - </site-details-permission> - <template is="dom-if" if="[[enableExperimentalWebPlatformFeatures_]]"> - <site-details-permission - category="{{ContentSettingsTypes.SERIAL_PORTS}}" - icon="settings:serial-port" id="serialPorts" - label="$i18n{siteSettingsSerialPorts}"> - </site-details-permission> - </template> - <template is="dom-if" if="[[enableNativeFileSystemWriteContentSetting_]]"> - <site-details-permission - category="{{ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE}}" - icon="settings:save-original" id="nativeFileSystemWrite" - label="$i18n{siteSettingsNativeFileSystemWrite}"> - </site-details-permission> - </template> - <site-details-permission - category="{{ContentSettingsTypes.UNSANDBOXED_PLUGINS}}" - icon="cr:extension" id="unsandboxedPlugins" - label="$i18n{siteSettingsUnsandboxedPlugins}"> - </site-details-permission> -<if expr="chromeos"> - <site-details-permission - category="{{ContentSettingsTypes.PROTECTED_CONTENT}}" - icon="settings:protected-content" id="protectedContent" - label="$i18n{siteSettingsProtectedContentIdentifiers}"> - </site-details-permission> -</if> - <site-details-permission - category="{{ContentSettingsTypes.CLIPBOARD}}" - icon="settings:clipboard" id="clipboard" - label="$i18n{siteSettingsClipboard}"> - </site-details-permission> - <site-details-permission - category="{{ContentSettingsTypes.PAYMENT_HANDLER}}" - icon="settings:payment-handler" id="paymentHandler" - label="$i18n{siteSettingsPaymentHandler}"> - </site-details-permission> - <template is="dom-if" if="[[enableExperimentalWebPlatformFeatures_]]"> - <site-details-permission - category="{{ContentSettingsTypes.BLUETOOTH_SCANNING}}" - icon="settings:bluetooth-scanning" id="bluetoothScanning" - label="$i18n{siteSettingsBluetoothScanning}"> - </site-details-permission> - </template> - <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> - </div> - - <website-usage-private-api id="usageApi" - website-data-usage="{{storedData_}}" - website-cookie-usage="{{numCookies_}}"> - </website-usage-private-api> - </template> - <script src="site_details.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details.js b/chromium/chrome/browser/resources/settings/site_settings/site_details.js deleted file mode 100644 index df765e0e3af..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details.js +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright 2015 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. - -/** - * @fileoverview - * 'site-details' show the details (permissions and usage) for a given origin - * under Site Settings. - */ -Polymer({ - is: 'site-details', - - behaviors: [ - I18nBehavior, SiteSettingsBehavior, settings.RouteObserverBehavior, - WebUIListenerBehavior - ], - - properties: { - /** - * Whether unified autoplay blocking is enabled. - */ - blockAutoplayEnabled: Boolean, - - /** - * Use the string representing the origin or extension name as the page - * title of the settings-subpage parent. - */ - pageTitle: { - type: String, - notify: true, - }, - - /** - * The origin that this widget is showing details for. - * @private - */ - origin_: String, - - /** - * The amount of data stored for the origin. - * @private - */ - storedData_: { - type: String, - value: '', - }, - - /** - * The number of cookies stored for the origin. - * @private - */ - numCookies_: { - type: String, - value: '', - }, - - /** @private */ - enableExperimentalWebPlatformFeatures_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('enableExperimentalWebPlatformFeatures'); - }, - }, - - /** @private */ - enableNativeFileSystemWriteContentSetting_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean( - 'enableNativeFileSystemWriteContentSetting'); - } - }, - - /** @private */ - enableInsecureContentContentSetting_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('enableInsecureContentContentSetting'); - } - }, - }, - - listeners: { - 'usage-deleted': 'onUsageDeleted_', - }, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'contentSettingSitePermissionChanged', - this.onPermissionChanged_.bind(this)); - - // <if expr="chromeos"> - this.addWebUIListener( - 'prefEnableDrmChanged', this.prefEnableDrmChanged_.bind(this)); - // </if> - - // Refresh block autoplay status from the backend. - this.browserProxy.fetchBlockAutoplayStatus(); - }, - - /** @override */ - ready: function() { - this.ContentSettingsTypes = settings.ContentSettingsTypes; - }, - - /** - * settings.RouteObserverBehavior - * @param {!settings.Route} route - * @protected - */ - currentRouteChanged: function(route) { - if (route != settings.routes.SITE_SETTINGS_SITE_DETAILS) { - return; - } - const site = settings.getQueryParameters().get('site'); - if (!site) { - return; - } - this.origin_ = site; - this.browserProxy.isOriginValid(this.origin_).then((valid) => { - if (!valid) { - settings.navigateToPreviousRoute(); - } else { - this.$.usageApi.fetchUsageTotal(this.toUrl(this.origin_).hostname); - this.updatePermissions_(this.getCategoryList()); - } - }); - }, - - /** - * Called when a site within a category has been changed. - * @param {!settings.ContentSettingsTypes} category The category that - * changed. - * @param {string} origin The origin of the site that changed. - * @param {string} embeddingOrigin The embedding origin of the site that - * changed. - * @private - */ - onPermissionChanged_: function(category, origin, embeddingOrigin) { - if (this.origin_ === undefined || this.origin_ == '' || - origin === undefined || origin == '') { - return; - } - if (!this.getCategoryList().includes(category)) { - return; - } - - // Site details currently doesn't support embedded origins, so ignore it - // and just check whether the origins are the same. - this.updatePermissions_([category]); - }, - - // <if expr="chromeos"> - prefEnableDrmChanged_: function() { - this.updatePermissions_([settings.ContentSettingsTypes.PROTECTED_CONTENT]); - }, - // </if> - - /** - * Retrieves the permissions listed in |categoryList| from the backend for - * |this.origin_|. - * @param {!Array<!settings.ContentSettingsTypes>} categoryList The list - * of categories to update permissions for. - * @private - */ - updatePermissions_: function(categoryList) { - const permissionsMap = - /** - * @type {!Object<!settings.ContentSettingsTypes, - * !SiteDetailsPermissionElement>} - */ - (Array.prototype.reduce.call( - this.root.querySelectorAll('site-details-permission'), - (map, element) => { - if (categoryList.includes(element.category)) { - map[element.category] = element; - } - return map; - }, - {})); - - this.browserProxy.getOriginPermissions(this.origin_, categoryList) - .then((exceptionList) => { - exceptionList.forEach((exception, i) => { - // |exceptionList| should be in the same order as - // |categoryList|. - if (permissionsMap[categoryList[i]]) { - permissionsMap[categoryList[i]].site = exception; - } - }); - - // The displayName won't change, so just use the first - // exception. - assert(exceptionList.length > 0); - this.pageTitle = exceptionList[0].displayName; - }); - }, - - /** @private */ - onCloseDialog_: function(e) { - e.target.closest('cr-dialog').close(); - }, - - /** - * Confirms the resetting of all content settings for an origin. - * @param {!Event} e - * @private - */ - onConfirmClearSettings_: function(e) { - e.preventDefault(); - this.$.confirmResetSettings.showModal(); - }, - - /** - * Confirms the clearing of storage for an origin. - * @param {!Event} e - * @private - */ - onConfirmClearStorage_: function(e) { - e.preventDefault(); - this.$.confirmClearStorage.showModal(); - }, - - /** - * Resets all permissions for the current origin. - * @private - */ - onResetSettings_: function(e) { - this.browserProxy.setOriginPermissions( - this.origin_, this.getCategoryList(), settings.ContentSetting.DEFAULT); - if (this.getCategoryList().includes( - settings.ContentSettingsTypes.PLUGINS)) { - this.browserProxy.clearFlashPref(this.origin_); - } - - this.onCloseDialog_(e); - }, - - /** - * Clears all data stored, except cookies, for the current origin. - * @private - */ - onClearStorage_: function(e) { - if (this.hasUsage_(this.storedData_, this.numCookies_)) { - this.$.usageApi.clearUsage(this.toUrl(this.origin_).href); - } - - this.onCloseDialog_(e); - }, - - /** - * Called when usage has been deleted for an origin via a non-Site Details - * source, e.g. clear browsing data. - * @param {!CustomEvent<!{origin: string}>} event - * @private - */ - onUsageDeleted_: function(event) { - if (event.detail.origin == this.toUrl(this.origin_).href) { - this.storedData_ = ''; - this.numCookies_ = ''; - } - }, - - /** - * Checks whether this site has any usage information to show. - * @return {boolean} Whether there is any usage information to show (e.g. - * disk or battery). - * @private - */ - hasUsage_: function(storage, cookies) { - return storage != '' || cookies != ''; - }, - - /** - * Checks whether this site has both storage and cookies information to show. - * @return {boolean} Whether there are both storage and cookies information to - * show. - * @private - */ - hasDataAndCookies_: function(storage, cookies) { - return storage != '' && cookies != ''; - }, - - /** @private */ - onResetSettingsDialogClosed_: function() { - cr.ui.focusWithoutInk(assert(this.$$('#resetSettingsButton'))); - }, - - /** @private */ - onClearStorageDialogClosed_: function() { - cr.ui.focusWithoutInk(assert(this.$$('#clearStorage'))); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html b/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html deleted file mode 100644 index c5a1e0091d3..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html +++ /dev/null @@ -1,80 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../settings_vars_css.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<!-- `site-details-permission` does not include any icon-set, so containing - elements should import the icon-set needed for the specified |icon|. --> -<dom-module id="site-details-permission"> - <template> - <style include="settings-shared md-select"></style> - <div id="details" hidden$="[[shouldHideCategory_(category)]]"> - <div id="permissionItem" - class$="list-item [[permissionInfoStringClass_(site.source, category, - site.setting)]]"> - <div> - <iron-icon icon="[[icon]]"> - </iron-icon> - </div> - <div class="middle" id="permissionHeader"> - [[label]] - <div class="secondary" - hidden$="[[!hasPermissionInfoString_(site.source, category, - site.setting)]]" - inner-h-t-m-l="[[permissionInfoString_( - site.source, - category, - site.setting, - '$i18nPolymer{siteSettingsAdsBlockBlacklistedSingular}', - '$i18nPolymer{siteSettingsAdsBlockNotBlacklistedSingular}', - '$i18nPolymer{siteSettingsSourceEmbargo}', - '$i18nPolymer{siteSettingsSourceInsecureOrigin}', - '$i18nPolymer{siteSettingsSourceKillSwitch}', - '$i18nPolymer{siteSettingsSourceExtensionAllow}', - '$i18nPolymer{siteSettingsSourceExtensionBlock}', - '$i18nPolymer{siteSettingsSourceExtensionAsk}', - '$i18nPolymer{siteSettingsSourcePolicyAllow}', - '$i18nPolymer{siteSettingsSourcePolicyBlock}', - '$i18nPolymer{siteSettingsSourcePolicyAsk}', - '$i18nPolymer{siteSettingsSourceDrmDisabled}')]]"> - </div> - </div> - <select id="permission" class="md-select" - aria-labelledby="permissionHeader" - on-change="onPermissionSelectionChange_" - disabled$="[[!isPermissionUserControlled_(site.source, category, - site.setting)]]"> - <option id="default" value$="[[ContentSetting.DEFAULT]]"> - [[defaultSettingString_( - defaultSetting_, - category, - useAutomaticLabel)]] - </option> - <option id="allow" value$="[[ContentSetting.ALLOW]]" - hidden$="[[!showAllowedSetting_(category)]]"> - $i18n{siteSettingsActionAllow} - </option> - <option id="block" value$="[[ContentSetting.BLOCK]]"> - [[blockSettingString_( - category, - '$i18n{siteSettingsActionBlock}', - '$i18n{siteSettingsActionMute}')]] - </option> - <option id="ask" value$="[[ContentSetting.ASK]]" - hidden$="[[!showAskSetting_(category, site.setting, - site.source)]]"> - $i18n{siteSettingsActionAsk} - </option> - </select> - </div> - </div> - </template> - <script src="site_details_permission.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js b/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js deleted file mode 100644 index 76f870645d2..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js +++ /dev/null @@ -1,377 +0,0 @@ -// Copyright 2015 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. - -/** - * @fileoverview - * 'site-details-permission' handles showing the state of one permission, such - * as Geolocation, for a given origin. - */ -Polymer({ - is: 'site-details-permission', - - behaviors: [I18nBehavior, SiteSettingsBehavior, WebUIListenerBehavior], - - properties: { - /** - * If this is a sound content setting, then this controls whether it - * should use "Automatic" instead of "Allow" as the default setting - * allow label. - */ - useAutomaticLabel: {type: Boolean, value: false}, - - /** - * The site that this widget is showing details for. - * @type {RawSiteException} - */ - site: Object, - - /** - * The default setting for this permission category. - * @type {settings.ContentSetting} - * @private - */ - defaultSetting_: String, - - label: String, - - icon: String, - }, - - observers: ['siteChanged_(site)'], - - /** @override */ - attached: function() { - this.addWebUIListener( - 'contentSettingCategoryChanged', - this.onDefaultSettingChanged_.bind(this)); - }, - - shouldHideCategory_: function(category) { - return !this.getCategoryList().includes(category); - }, - - /** - * Updates the drop-down value after |site| has changed. - * @param {!RawSiteException} site The site to display. - * @private - */ - siteChanged_: function(site) { - if (site.source == settings.SiteSettingSource.DEFAULT) { - this.defaultSetting_ = site.setting; - this.$.permission.value = settings.ContentSetting.DEFAULT; - } else { - // The default setting is unknown, so consult the C++ backend for it. - this.updateDefaultPermission_(site); - this.$.permission.value = site.setting; - } - - if (this.isNonDefaultAsk_(site.setting, site.source)) { - assert( - this.$.permission.value == settings.ContentSetting.ASK, - '\'Ask\' should only show up when it\'s currently selected.'); - } - }, - - /** - * Updates the default permission setting for this permission category. - * @param {!RawSiteException} site The site to display. - * @private - */ - updateDefaultPermission_: function(site) { - this.browserProxy.getDefaultValueForContentType(this.category) - .then((defaultValue) => { - this.defaultSetting_ = defaultValue.setting; - }); - }, - - /** - * Handles the category permission changing for this origin. - * @param {!settings.ContentSettingsTypes} category The permission category - * that has changed default permission. - * @private - */ - onDefaultSettingChanged_: function(category) { - if (category == this.category) { - this.updateDefaultPermission_(this.site); - } - }, - - /** - * Handles the category permission changing for this origin. - * @private - */ - onPermissionSelectionChange_: function() { - this.browserProxy.setOriginPermissions( - this.site.origin, [this.category], this.$.permission.value); - }, - - /** - * Returns if we should use the custom labels for the sound type. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @return {boolean} - * @private - */ - useCustomSoundLabels_: function(category) { - return category == settings.ContentSettingsTypes.SOUND && - loadTimeData.getBoolean('enableAutoplayWhitelistContentSetting'); - }, - - /** - * Updates the string used for this permission category's default setting. - * @param {!settings.ContentSetting} defaultSetting Value of the default - * setting for this permission category. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @param {boolean} useAutomaticLabel Whether to use the automatic label - * if the default setting value is allow. - * @return {string} - * @private - */ - defaultSettingString_: function(defaultSetting, category, useAutomaticLabel) { - if (defaultSetting == undefined || category == undefined || - useAutomaticLabel == undefined) { - return ''; - } - - if (defaultSetting == settings.ContentSetting.ASK || - defaultSetting == settings.ContentSetting.IMPORTANT_CONTENT) { - return this.i18n('siteSettingsActionAskDefault'); - } else if (defaultSetting == settings.ContentSetting.ALLOW) { - if (this.useCustomSoundLabels_(category) && useAutomaticLabel) { - return this.i18n('siteSettingsActionAutomaticDefault'); - } - return this.i18n('siteSettingsActionAllowDefault'); - } else if (defaultSetting == settings.ContentSetting.BLOCK) { - if (this.useCustomSoundLabels_(category)) { - return this.i18n('siteSettingsActionMuteDefault'); - } - return this.i18n('siteSettingsActionBlockDefault'); - } - assertNotReached( - `No string for ${this.category}'s default of ${defaultSetting}`); - }, - - /** - * Updates the string used for this permission category's block setting. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @param {string} blockString 'Block' label. - * @param {string} muteString 'Mute' label. - * @return {string} - * @private - */ - blockSettingString_: function(category, blockString, muteString) { - if (this.useCustomSoundLabels_(category)) { - return muteString; - } - return blockString; - }, - - /** - * Returns true if there's a string to display that provides more information - * about this permission's setting. Currently, this only gets called when - * |this.site| is updated. - * @param {!settings.SiteSettingSource} source The source of the permission. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @param {!settings.ContentSetting} setting The permission setting. - * @return {boolean} Whether the permission will have a source string to - * display. - * @private - */ - hasPermissionInfoString_: function(source, category, setting) { - // This method assumes that an empty string will be returned for categories - // that have no permission info string. - return this.permissionInfoString_( - source, category, setting, - // Set all permission info string arguments as null. This is OK - // because there is no need to know what the information string - // will be, just whether there is one or not. - null, null, null, null, null, null, null, null, null, null, null, - null) != ''; - }, - - /** - * Checks if there's a additional information to display, and returns the - * class name to apply to permissions if so. - * @param {!settings.SiteSettingSource} source The source of the permission. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @param {!settings.ContentSetting} setting The permission setting. - * @return {string} CSS class applied when there is an additional description - * string. - * @private - */ - permissionInfoStringClass_: function(source, category, setting) { - return this.hasPermissionInfoString_(source, category, setting) ? - 'two-line' : - ''; - }, - - /** - * Returns true if this permission can be controlled by the user. - * @param {!settings.SiteSettingSource} source The source of the permission. - * @return {boolean} - * @private - */ - isPermissionUserControlled_: function(source) { - return !( - source == settings.SiteSettingSource.DRM_DISABLED || - source == settings.SiteSettingSource.POLICY || - source == settings.SiteSettingSource.EXTENSION || - source == settings.SiteSettingSource.KILL_SWITCH || - source == settings.SiteSettingSource.INSECURE_ORIGIN); - }, - - /** - * Returns true if the 'allow' option should be shown. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @return {boolean} - * @private - */ - showAllowedSetting_: function(category) { - return !( - category == settings.ContentSettingsTypes.SERIAL_PORTS || - category == settings.ContentSettingsTypes.USB_DEVICES || - category == settings.ContentSettingsTypes.BLUETOOTH_SCANNING || - category == settings.ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE); - }, - - /** - * Returns true if the 'ask' option should be shown. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @param {!settings.ContentSetting} setting The setting of the permission. - * @param {!settings.SiteSettingSource} source The source of the permission. - * @return {boolean} - * @private - */ - showAskSetting_: function(category, setting, source) { - // For chooser-based permissions 'ask' takes the place of 'allow'. - if (category == settings.ContentSettingsTypes.SERIAL_PORTS || - category == settings.ContentSettingsTypes.USB_DEVICES) { - return true; - } - - // For Bluetooth scanning permission and Native File System write permission - // 'ask' takes the place of 'allow'. - if (category == settings.ContentSettingsTypes.BLUETOOTH_SCANNING || - category == settings.ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE) { - return true; - } - - return this.isNonDefaultAsk_(setting, source); - }, - - /** - * Returns true if the permission is set to a non-default 'ask'. Currently, - * this only gets called when |this.site| is updated. - * @param {!settings.ContentSetting} setting The setting of the permission. - * @param {!settings.SiteSettingSource} source The source of the permission. - * @private - */ - isNonDefaultAsk_: function(setting, source) { - if (setting != settings.ContentSetting.ASK || - source == settings.SiteSettingSource.DEFAULT) { - return false; - } - - assert( - source == settings.SiteSettingSource.EXTENSION || - source == settings.SiteSettingSource.POLICY || - source == settings.SiteSettingSource.PREFERENCE, - 'Only extensions, enterprise policy or preferences can change ' + - 'the setting to ASK.'); - return true; - }, - - /** - * Updates the information string for the current permission. - * Currently, this only gets called when |this.site| is updated. - * @param {!settings.SiteSettingSource} source The source of the permission. - * @param {!settings.ContentSettingsTypes} category The permission type. - * @param {!settings.ContentSetting} setting The permission setting. - * @param {?string} adsBlacklistString The string to show if the site is - * blacklisted for showing bad ads. - * @param {?string} adsBlockString The string to show if ads are blocked, but - * the site is not blacklisted. - * @param {?string} embargoString - * @param {?string} insecureOriginString - * @param {?string} killSwitchString - * @param {?string} extensionAllowString - * @param {?string} extensionBlockString - * @param {?string} extensionAskString - * @param {?string} policyAllowString - * @param {?string} policyBlockString - * @param {?string} policyAskString - * @param {?string} drmDisabledString - * @return {?string} The permission information string to display in the HTML. - * @private - */ - permissionInfoString_: function( - source, category, setting, adsBlacklistString, adsBlockString, - embargoString, insecureOriginString, killSwitchString, - extensionAllowString, extensionBlockString, extensionAskString, - policyAllowString, policyBlockString, policyAskString, - drmDisabledString) { - if (source == undefined || category == undefined || setting == undefined) { - return null; - } - - /** @type {Object<!settings.ContentSetting, ?string>} */ - const extensionStrings = {}; - extensionStrings[settings.ContentSetting.ALLOW] = extensionAllowString; - extensionStrings[settings.ContentSetting.BLOCK] = extensionBlockString; - extensionStrings[settings.ContentSetting.ASK] = extensionAskString; - - /** @type {Object<!settings.ContentSetting, ?string>} */ - const policyStrings = {}; - policyStrings[settings.ContentSetting.ALLOW] = policyAllowString; - policyStrings[settings.ContentSetting.BLOCK] = policyBlockString; - policyStrings[settings.ContentSetting.ASK] = policyAskString; - - if (source == settings.SiteSettingSource.ADS_FILTER_BLACKLIST) { - assert( - settings.ContentSettingsTypes.ADS == category, - 'The ads filter blacklist only applies to Ads.'); - return adsBlacklistString; - } else if ( - category == settings.ContentSettingsTypes.ADS && - setting == settings.ContentSetting.BLOCK) { - return adsBlockString; - } else if (source == settings.SiteSettingSource.DRM_DISABLED) { - assert( - settings.ContentSetting.BLOCK == setting, - 'If DRM is disabled, Protected Content must be blocked.'); - assert( - settings.ContentSettingsTypes.PROTECTED_CONTENT == category, - 'The DRM disabled source only applies to Protected Content.'); - if (!drmDisabledString) { - return null; - } - return loadTimeData.sanitizeInnerHtml(loadTimeData.substituteString( - drmDisabledString, - settings.routes.SITE_SETTINGS_PROTECTED_CONTENT.getAbsolutePath())); - } else if (source == settings.SiteSettingSource.EMBARGO) { - assert( - settings.ContentSetting.BLOCK == setting, - 'Embargo is only used to block permissions.'); - return embargoString; - } else if (source == settings.SiteSettingSource.EXTENSION) { - return extensionStrings[setting]; - } else if (source == settings.SiteSettingSource.INSECURE_ORIGIN) { - assert( - settings.ContentSetting.BLOCK == setting, - 'Permissions can only be blocked due to insecure origins.'); - return insecureOriginString; - } else if (source == settings.SiteSettingSource.KILL_SWITCH) { - assert( - settings.ContentSetting.BLOCK == setting, - 'The permissions kill switch can only be used to block permissions.'); - return killSwitchString; - } else if (source == settings.SiteSettingSource.POLICY) { - return policyStrings[setting]; - } else if ( - source == settings.SiteSettingSource.DEFAULT || - source == settings.SiteSettingSource.PREFERENCE) { - return ''; - } - assertNotReached(`No string for ${category} setting source '${source}'`); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_entry.html b/chromium/chrome/browser/resources/settings/site_settings/site_entry.html deleted file mode 100644 index 49b87662716..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_entry.html +++ /dev/null @@ -1,139 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_row_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../site_favicon.html"> -<link rel="import" href="local_data_browser_proxy.html"> -<link rel="import" href="site_settings_behavior.html"> - -<dom-module id="site-entry"> - <template> - <style include="settings-shared"> - .row-aligned { - display: flex; - flex-direction: row; - } - - #toggleButton { - /** Use the minimum row height as the minimum click-target height. */ - min-height: var(--settings-row-min-height); - } - - .site-representation { - display: flex; - } - - .second-line { - margin-top: 0.1em; - } - - /* Data units such as "0 KB" should always read left-to-right. */ - .data-unit { - direction: ltr; - unicode-bidi: isolate; - } - - .list-frame { - padding-inline-end: 0; - } - - .spacing { - padding-inline-start: 1ch; - } - </style> - <div id="collapseParent" focus-row-container> - <div class$="settings-box list-item [[getClassForIndex_(listIndex)]]"> - <div id="toggleButton" class="start row-aligned two-line" - on-click="onSiteEntryTap_" actionable aria-expanded="false"> - <site-favicon url="[[getSiteGroupIcon_(siteGroup)]]"></site-favicon> - <div class="middle text-elide" id="displayName"> - <div class="site-representation"> - <span class="url-directionality">[[displayName_]]</span> - <span class="secondary" - hidden$="[[!siteGroupScheme_(siteGroup)]]"> - $i18nPolymer{siteSettingsSiteRepresentationSeparator} - </span> - <span class="secondary" - hidden$="[[!siteGroupScheme_(siteGroup)]]"> - [[siteGroupScheme_(siteGroup)]] - </span> - </div> - <div class="second-line secondary"> - <span class="data-unit">[[overallUsageString_]]</span> - <span id="cookies" hidden$="[[!siteGroup.numCookies]]"> - · [[cookieString_]] - </span> - </div> - </div> - <cr-icon-button id="expandIcon" class="icon-expand-more" - hidden$="[[!grouped_(siteGroup)]]" aria-label$="[[displayName_]]" - aria-describedby="displayName" focus-row-control - focus-type="expand"></cr-icon-button> - <cr-icon-button class="subpage-arrow" - hidden$="[[grouped_(siteGroup)]]" aria-label$="[[displayName_]]" - aria-describedby="displayName" - focus-row-control focus-type="show-detail"></cr-icon-button> - </div> - <div class="row-aligned" hidden$="[[!grouped_(siteGroup)]]"> - <div class="separator"></div> - <cr-icon-button class="icon-more-vert" id="overflowMenuButton" - title="$i18n{moreActions}" on-click="showOverflowMenu_" - focus-row-control focus-type="more-actions"></cr-icon-button> - </div> - </div> - - <cr-lazy-render id="originList"> - <template> - <iron-collapse id="collapseChild" no-animation> - <div class="list-frame"> - <template is="dom-repeat" items="[[siteGroup.origins]]"> - <div class="settings-box list-item" on-click="onOriginTap_" - actionable> - <site-favicon url="[[item.origin]]"></site-favicon> - <div class="site-representation middle text-elide"> - <span id="originSiteRepresentation" - class="url-directionality"> - [[originRepresentation_(item)]] - </span> - <span class="secondary" - hidden$="[[!originScheme_(item)]]"> - - $i18nPolymer{siteSettingsSiteRepresentationSeparator} - - </span> - <span class="secondary" - hidden$="[[!originScheme_(item)]]"> - [[originScheme_(item)]] - </span> - <!--Define a spacing span so that when the direction is rtl, - the spacing is still showing correctly. This is because the - data-unit class is set to be ltr so the padding will be in - wrong place if we put padding in that span.--> - <span class="spacing" hidden$="[[!item.usage]]"></span> - <span class="secondary data-unit" hidden$="[[!item.usage]]"> - [[originUsagesItem_(originUsages_.*, index)]] - </span> - <span class="secondary" hidden$="[[!item.numCookies]]"> - · - [[originCookiesItem_(cookiesNum_.*, index)]] - </span> - </div> - <cr-icon-button class="subpage-arrow" - aria-labelledby$="originSiteRepresentation" - focus-row-control focus-type="detailed-sites"> - </cr-icon-button> - </div> - </template> - </div> - </iron-collapse> - </template> - </cr-lazy-render> - </div> - </template> - <script src="site_entry.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_entry.js b/chromium/chrome/browser/resources/settings/site_settings/site_entry.js deleted file mode 100644 index ad60ba23464..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_entry.js +++ /dev/null @@ -1,454 +0,0 @@ -// Copyright 2018 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. - -/** - * @fileoverview - * 'site-entry' is an element representing a single eTLD+1 site entity. - */ -Polymer({ - is: 'site-entry', - - behaviors: [SiteSettingsBehavior, cr.ui.FocusRowBehavior], - - properties: { - /** - * An object representing a group of sites with the same eTLD+1. - * @type {!SiteGroup} - */ - siteGroup: { - type: Object, - observer: 'onSiteGroupChanged_', - }, - - /** - * The name to display beside the icon. If grouped_() is true, it will be - * the eTLD+1 for all the origins, otherwise, it will return the host. - * @private - */ - displayName_: String, - - /** - * The string to display when there is a non-zero number of cookies. - * @private - */ - cookieString_: String, - - /** - * The position of this site-entry in its parent list. - */ - listIndex: { - type: Number, - value: -1, - }, - - /** - * The string to display showing the overall usage of this site-entry. - * @private - */ - overallUsageString_: String, - - /** - * An array containing the strings to display showing the individual disk - * usage for each origin in |siteGroup|. - * @type {!Array<string>} - * @private - */ - originUsages_: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * An array containing the strings to display showing the individual cookies - * number for each origin in |siteGroup|. - * @type {!Array<string>} - * @private - */ - cookiesNum_: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * The selected sort method. - * @type {!settings.SortMethod|undefined} - */ - sortMethod: {type: String, observer: 'updateOrigins_'} - }, - - /** @private {?settings.LocalDataBrowserProxy} */ - localDataBrowserProxy_: null, - - /** @private {?Element} */ - button_: null, - - /** @override */ - created: function() { - this.localDataBrowserProxy_ = - settings.LocalDataBrowserProxyImpl.getInstance(); - }, - - /** @override */ - detached: function() { - if (this.button_) { - this.unlisten(this.button_, 'keydown', 'onButtonKeydown_'); - } - }, - - /** @param {!KeyboardEvent} e */ - onButtonKeydown_: function(e) { - if (e.shiftKey && e.key === 'Tab') { - this.focus(); - } - }, - - /** - * Whether the list of origins displayed in this site-entry is a group of - * eTLD+1 origins or not. - * @param {SiteGroup} siteGroup The eTLD+1 group of origins. - * @return {boolean} - * @private - */ - grouped_: function(siteGroup) { - if (!siteGroup) { - return false; - } - if (siteGroup.origins.length > 1 || - siteGroup.numCookies > siteGroup.origins[0].numCookies) { - return true; - } - return false; - }, - - /** - * Returns a user-friendly name for the siteGroup. - * If grouped_() is true and eTLD+1 is available, returns the eTLD+1, - * otherwise return the origin representation for the first origin. - * @param {SiteGroup} siteGroup The eTLD+1 group of origins. - * @return {string} The user-friendly name. - * @private - */ - siteGroupRepresentation_: function(siteGroup) { - if (!siteGroup) { - return ''; - } - if (this.grouped_(siteGroup)) { - if (siteGroup.etldPlus1 != '') { - return siteGroup.etldPlus1; - } - // Fall back onto using the host of the first origin, if no eTLD+1 name - // was computed. - } - return this.originRepresentation_(siteGroup.origins[0]); - }, - - /** - * Returns a user-friendly name for the origin. - * @param {OriginInfo} origin - * @return {string} The user-friendly name. - * @private - */ - originRepresentation_(origin) { - const url = this.toUrl(origin.origin); - return url.host; - }, - - /** - * @param {SiteGroup} siteGroup The eTLD+1 group of origins. - * @private - */ - onSiteGroupChanged_: function(siteGroup) { - // Update the button listener. - if (this.button_) { - this.unlisten(this.button_, 'keydown', 'onButtonKeydown_'); - } - this.button_ = /** @type Element */ - (this.root.querySelector('#toggleButton *:not([hidden])')); - this.listen(assert(this.button_), 'keydown', 'onButtonKeydown_'); - - if (!this.grouped_(siteGroup)) { - // Ensure ungrouped |siteGroup|s do not get stuck in an opened state. - const collapseChild = this.$.originList.getIfExists(); - if (collapseChild && collapseChild.opened) { - this.toggleCollapsible_(); - } - } - if (!siteGroup) { - return; - } - this.calculateUsageInfo_(siteGroup); - this.getCookieNumString_(siteGroup.numCookies).then(string => { - this.cookieString_ = string; - }); - this.updateOrigins_(this.sortMethod); - this.displayName_ = this.siteGroupRepresentation_(siteGroup); - }, - - /** - * Returns any non-HTTPS scheme/protocol for the siteGroup that only contains - * one origin. Otherwise, returns a empty string. - * @param {SiteGroup} siteGroup The eTLD+1 group of origins. - * @return {string} The scheme if non-HTTPS, or empty string if HTTPS. - * @private - */ - siteGroupScheme_: function(siteGroup) { - if (!siteGroup || (this.grouped_(siteGroup))) { - return ''; - } - return this.originScheme_(siteGroup.origins[0]); - }, - - /** - * Returns any non-HTTPS scheme/protocol for the origin. Otherwise, returns - * an empty string. - * @param {OriginInfo} origin - * @return {string} The scheme if non-HTTPS, or empty string if HTTPS. - * @private - */ - originScheme_: function(origin) { - const url = this.toUrl(origin.origin); - const scheme = url.protocol.replace(new RegExp(':*$'), ''); - /** @type{string} */ const HTTPS_SCHEME = 'https'; - if (scheme == HTTPS_SCHEME) { - return ''; - } - return scheme; - }, - - /** - * Get an appropriate favicon that represents this group of eTLD+1 sites as a - * whole. - * @param {!SiteGroup} siteGroup The eTLD+1 group of origins. - * @return {string} URL that is used for fetching the favicon - * @private - */ - getSiteGroupIcon_: function(siteGroup) { - const origins = siteGroup.origins; - assert(origins); - assert(origins.length >= 1); - if (origins.length == 1) { - return origins[0].origin; - } - // If we can find a origin with format "www.etld+1", use the favicon of this - // origin. Otherwise find the origin with largest storage, and use the - // number of cookies as a tie breaker. - for (const originInfo of origins) { - if (this.toUrl(originInfo.origin).host == 'www.' + siteGroup.etldPlus1) { - return originInfo.origin; - } - } - const getMaxStorage = (max, originInfo) => { - return ( - max.usage > originInfo.usage || - (max.usage == originInfo.usage && - max.numCookies > originInfo.numCookies) ? - max : - originInfo); - }; - return origins.reduce(getMaxStorage, origins[0]).origin; - }, - - /** - * Calculates the amount of disk storage used by the given eTLD+1. - * Also updates the corresponding display strings. - * @param {SiteGroup} siteGroup The eTLD+1 group of origins. - * @private - */ - calculateUsageInfo_: function(siteGroup) { - let overallUsage = 0; - this.siteGroup.origins.forEach((originInfo, i) => { - overallUsage += originInfo.usage; - }); - this.browserProxy.getFormattedBytes(overallUsage).then(string => { - this.overallUsageString_ = string; - }); - }, - - /** - * Get display string for number of cookies. - * @param {number} numCookies - * @private - */ - getCookieNumString_: function(numCookies) { - if (numCookies == 0) { - return Promise.resolve(''); - } - return this.localDataBrowserProxy_.getNumCookiesString(numCookies); - }, - - /** - * Array binding for the |originUsages_| array for use in the HTML. - * @param {!{base: !Array<string>}} change The change record for the array. - * @param {number} index The index of the array item. - * @return {string} - * @private - */ - originUsagesItem_: function(change, index) { - return change.base[index]; - }, - - /** - * Array binding for the |cookiesNum_| array for use in the HTML. - * @param {!{base: !Array<string>}} change The change record for the array. - * @param {number} index The index of the array item. - * @return {string} - * @private - */ - originCookiesItem_: function(change, index) { - return change.base[index]; - }, - - /** - * Navigates to the corresponding Site Details page for the given origin. - * @param {string} origin The origin to navigate to the Site Details page for - * it. - * @private - */ - navigateToSiteDetails_: function(origin) { - this.fire( - 'site-entry-selected', {item: this.siteGroup, index: this.listIndex}); - settings.navigateTo( - settings.routes.SITE_SETTINGS_SITE_DETAILS, - new URLSearchParams('site=' + origin)); - }, - - /** - * A handler for selecting a site (by clicking on the origin). - * @param {!{model: !{index: !number}}} e - * @private - */ - onOriginTap_: function(e) { - this.navigateToSiteDetails_(this.siteGroup.origins[e.model.index].origin); - this.browserProxy.recordAction(settings.AllSitesAction.ENTER_SITE_DETAILS); - }, - - /** - * A handler for clicking on a site-entry heading. This will either show a - * list of origins or directly navigates to Site Details if there is only one. - * @private - */ - onSiteEntryTap_: function() { - // Individual origins don't expand - just go straight to Site Details. - if (!this.grouped_(this.siteGroup)) { - this.navigateToSiteDetails_(this.siteGroup.origins[0].origin); - this.browserProxy.recordAction( - settings.AllSitesAction.ENTER_SITE_DETAILS); - return; - } - this.toggleCollapsible_(); - - // Make sure the expanded origins can be viewed without further scrolling - // (in case |this| is already at the bottom of the viewport). - this.scrollIntoViewIfNeeded(); - }, - - /** - * Toggles open and closed the list of origins if there is more than one. - * @private - */ - toggleCollapsible_: function() { - const collapseChild = - /** @type {IronCollapseElement} */ (this.$.originList.get()); - collapseChild.toggle(); - this.$.toggleButton.setAttribute('aria-expanded', collapseChild.opened); - this.$.expandIcon.toggleClass('icon-expand-more'); - this.$.expandIcon.toggleClass('icon-expand-less'); - this.fire('iron-resize'); - }, - - /** - * Fires a custom event when the menu button is clicked. Sends the details - * of the site entry item and where the menu should appear. - * @param {!Event} e - * @private - */ - showOverflowMenu_: function(e) { - this.fire('open-menu', { - target: e.target, - index: this.listIndex, - item: this.siteGroup, - }); - }, - - /** - * Returns a valid index for an origin contained in |siteGroup.origins| by - * clamping the given |index|. This also replaces undefined |index|es with 0. - * Use this to prevent being given out-of-bounds indexes by dom-repeat when - * scrolling an iron-list storing these site-entries too quickly. - * @param {!number=} index - * @return {number} - * @private - */ - getIndexBoundToOriginList_: function(siteGroup, index) { - return Math.max(0, Math.min(index, siteGroup.origins.length - 1)); - }, - - /** - * Returns the correct class to apply depending on this site-entry's position - * in a list. - * @param {number} index - * @private - */ - getClassForIndex_: function(index) { - if (index == 0) { - return 'first'; - } - return ''; - }, - - /** - * Update the order and data display text for origins. - * @param {!settings.SortMethod|undefined} sortMethod - * @private - */ - updateOrigins_: function(sortMethod) { - if (!sortMethod || !this.siteGroup || !this.grouped_(this.siteGroup)) { - return null; - } - - const origins = this.siteGroup.origins.slice(); - origins.sort(this.sortFunction_(sortMethod)); - this.set('siteGroup.origins', origins); - - this.originUsages_ = new Array(origins.length); - origins.forEach((originInfo, i) => { - this.browserProxy.getFormattedBytes(originInfo.usage).then((string) => { - this.set(`originUsages_.${i}`, string); - }); - }); - - this.cookiesNum_ = new Array(this.siteGroup.origins.length); - origins.forEach((originInfo, i) => { - this.getCookieNumString_(originInfo.numCookies).then((string) => { - this.set(`cookiesNum_.${i}`, string); - }); - }); - }, - - /** - * Sort functions for sorting origins based on selected method. - * @param {!settings.SortMethod|undefined} sortMethod - * @private - */ - sortFunction_: function(sortMethod) { - if (sortMethod == settings.SortMethod.MOST_VISITED) { - return (origin1, origin2) => { - return origin2.engagement - origin1.engagement; - }; - } else if (sortMethod == settings.SortMethod.STORAGE) { - return (origin1, origin2) => { - return origin2.usage - origin1.usage || - origin2.numCookies - origin1.numCookies; - }; - } else if (sortMethod == settings.SortMethod.NAME) { - return (origin1, origin2) => { - return origin1.origin.localeCompare(origin2.origin); - }; - } - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_list.html b/chromium/chrome/browser/resources/settings/site_settings/site_list.html deleted file mode 100644 index de095c0574e..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_list.html +++ /dev/null @@ -1,103 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/html/list_property_update_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-tooltip/paper-tooltip.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="add_site_dialog.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="edit_exception_dialog.html"> -<link rel="import" href="site_list_entry.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> -<if expr="chromeos"> - <link rel="import" href="../multidevice_page/multidevice_browser_proxy.html"> -</if> - -<dom-module id="site-list"> - <template> - <style include="settings-shared"> - paper-tooltip { - --paper-tooltip: var(--cr-tooltip); - } - </style> - <div id="category"> - <div class="settings-box first"> - <h2 class="start">[[categoryHeader]]</h2> - <cr-button id="addSite" class="header-aligned-button" - hidden$="[[!showAddSiteButton_]]" on-click="onAddSiteTap_"> - $i18n{add} - </cr-button> - </div> - - <cr-action-menu> - <button class="dropdown-item" id="allow" - on-click="onAllowTap_" hidden$="[[!showAllowAction_]]"> - $i18n{siteSettingsActionAllow} - </button> - <button class="dropdown-item" id="block" - on-click="onBlockTap_" hidden$="[[!showBlockAction_]]"> - $i18n{siteSettingsActionBlock} - </button> - <button class="dropdown-item" id="sessionOnly" - on-click="onSessionOnlyTap_" - hidden$="[[!showSessionOnlyActionForSite_(actionMenuSite_)]]"> - $i18n{siteSettingsActionSessionOnly} - </button> - <button class="dropdown-item" id="edit" - on-click="onEditTap_"> - $i18n{edit} - </button> - <button class="dropdown-item" id="reset" - on-click="onResetTap_"> - $i18n{siteSettingsActionReset} - </button> - </cr-action-menu> - - <div class="list-frame" hidden$="[[hasSites_(sites.*)]]"> - <div class="list-item secondary">$i18n{noSitesAdded}</div> - </div> - <div class="list-frame" - hidden$="[[!showNoSearchResults_(searchFilter, sites.*)]]"> - <div class="list-item secondary">$i18n{searchNoResults}</div> - </div> - <div class="list-frame menu-content vertical-list" id="listContainer"> - <iron-list items="[[getFilteredSites_(searchFilter, sites.*)]]" - preserve-focus risk-selection> - <template> - <site-list-entry model="[[item]]" read-only-list="[[readOnlyList]]" - on-show-action-menu="onShowActionMenu_" tabindex$="[[tabIndex]]" - first$="[[!index]]" iron-list-tab-index="[[tabIndex]]" - last-focused="{{lastFocused_}}" list-blurred="{{listBlurred_}}" - on-show-tooltip="onShowTooltip_"> - </site-list-entry> - </template> - </iron-list> - </div> - </div> - <paper-tooltip id="tooltip" fit-to-visible-bounds manual-mode - position="top"> - [[tooltipText_]] - </paper-tooltip> - <template is="dom-if" if="[[showEditExceptionDialog_]]" restamp> - <settings-edit-exception-dialog model="[[actionMenuSite_]]" - on-close="onEditExceptionDialogClosed_"> - </settings-edit-exception-dialog> - </template> - <template is="dom-if" if="[[showAddSiteDialog_]]" restamp> - <add-site-dialog has-incognito="[[hasIncognito_]]" category="[[category]]" - content-setting="[[categorySubtype]]" - on-close="onAddSiteDialogClosed_"> - </add-site-dialog> - </template> - </template> - <script src="site_list.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_list.js b/chromium/chrome/browser/resources/settings/site_settings/site_list.js deleted file mode 100644 index bdc541bd8a9..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_list.js +++ /dev/null @@ -1,499 +0,0 @@ -// Copyright 2015 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. - -/** - * @fileoverview - * 'site-list' shows a list of Allowed and Blocked sites for a given - * category. - */ -Polymer({ - is: 'site-list', - - behaviors: [ - SiteSettingsBehavior, - WebUIListenerBehavior, - ListPropertyUpdateBehavior, - ], - - properties: { - /** - * Some content types (like Location) do not allow the user to manually - * edit the exception list from within Settings. - * @private - */ - readOnlyList: { - type: Boolean, - value: false, - }, - - categoryHeader: String, - - /** - * The site serving as the model for the currently open action menu. - * @private {?SiteException} - */ - actionMenuSite_: Object, - - /** - * Whether the "edit exception" dialog should be shown. - * @private - */ - showEditExceptionDialog_: Boolean, - - /** - * Array of sites to display in the widget. - * @type {!Array<SiteException>} - */ - sites: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * The type of category this widget is displaying data for. Normally - * either 'allow' or 'block', representing which sites are allowed or - * blocked respectively. - */ - categorySubtype: { - type: String, - value: settings.INVALID_CATEGORY_SUBTYPE, - }, - - /** @private */ - hasIncognito_: Boolean, - - /** - * Whether to show the Add button next to the header. - * @private - */ - showAddSiteButton_: { - type: Boolean, - computed: 'computeShowAddSiteButton_(readOnlyList, category, ' + - 'categorySubtype)', - }, - - /** @private */ - showAddSiteDialog_: Boolean, - - /** - * Whether to show the Allow action in the action menu. - * @private - */ - showAllowAction_: Boolean, - - /** - * Whether to show the Block action in the action menu. - * @private - */ - showBlockAction_: Boolean, - - /** - * Whether to show the 'Clear on exit' action in the action - * menu. - * @private - */ - showSessionOnlyAction_: Boolean, - - /** - * All possible actions in the action menu. - * @private - */ - actions_: { - readOnly: true, - type: Object, - values: { - ALLOW: 'Allow', - BLOCK: 'Block', - RESET: 'Reset', - SESSION_ONLY: 'SessionOnly', - } - }, - - /** @private */ - lastFocused_: Object, - - /** @private */ - listBlurred_: Boolean, - - /** @private */ - tooltipText_: String, - - searchFilter: String, - }, - - // <if expr="chromeos"> - /** - * Android messages info object containing messages feature state and - * exception origin. - * @private {?settings.AndroidSmsInfo} - */ - androidSmsInfo_: null, - // </if> - - /** - * The element to return focus to, when the currently active dialog is closed. - * @private {?HTMLElement} - */ - activeDialogAnchor_: null, - - observers: ['configureWidget_(category, categorySubtype)'], - - /** @override */ - ready: function() { - this.addWebUIListener( - 'contentSettingSitePermissionChanged', - this.siteWithinCategoryChanged_.bind(this)); - this.addWebUIListener( - 'onIncognitoStatusChanged', this.onIncognitoStatusChanged_.bind(this)); - // <if expr="chromeos"> - this.addWebUIListener('settings.onAndroidSmsInfoChange', (info) => { - this.androidSmsInfo_ = info; - this.populateList_(); - }); - // </if> - this.browserProxy.updateIncognitoStatus(); - }, - - /** - * Called when a site changes permission. - * @param {string} category The category of the site that changed. - * @param {string} site The site that changed. - * @private - */ - siteWithinCategoryChanged_: function(category, site) { - if (category == this.category) { - this.configureWidget_(); - } - }, - - /** - * Called for each site list when incognito is enabled or disabled. Only - * called on change (opening N incognito windows only fires one message). - * Another message is sent when the *last* incognito window closes. - * @private - */ - onIncognitoStatusChanged_: function(hasIncognito) { - this.hasIncognito_ = hasIncognito; - - // The SESSION_ONLY list won't have any incognito exceptions. (Minor - // optimization, not required). - if (this.categorySubtype == settings.ContentSetting.SESSION_ONLY) { - return; - } - - // A change notification is not sent for each site. So we repopulate the - // whole list when the incognito profile is created or destroyed. - this.populateList_(); - }, - - /** - * Configures the action menu, visibility of the widget and shows the list. - * @private - */ - configureWidget_: function() { - if (this.category == undefined) { - return; - } - - // The observer for All Sites fires before the attached/ready event, so - // initialize this here. - if (this.browserProxy_ === undefined) { - this.browserProxy_ = - settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); - } - - this.setUpActionMenu_(); - - // <if expr="not chromeos"> - this.populateList_(); - // </if> - - // <if expr="chromeos"> - this.updateAndroidSmsInfo_().then(this.populateList_.bind(this)); - // </if> - - // The Session permissions are only for cookies. - if (this.categorySubtype == settings.ContentSetting.SESSION_ONLY) { - this.$.category.hidden = - this.category != settings.ContentSettingsTypes.COOKIES; - } - }, - - /** - * Whether there are any site exceptions added for this content setting. - * @return {boolean} - * @private - */ - hasSites_: function() { - return this.sites.length > 0; - }, - - /** - * Whether the Add Site button is shown in the header for the current category - * and category subtype. - * @return {boolean} - * @private - */ - computeShowAddSiteButton_: function() { - return !( - this.readOnlyList || - (this.category == - settings.ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE && - this.categorySubtype == settings.ContentSetting.ALLOW)); - }, - - /** - * @return {boolean} - * @private - */ - showNoSearchResults_: function() { - return this.sites.length > 0 && this.getFilteredSites_().length == 0; - }, - - /** - * A handler for the Add Site button. - * @private - */ - onAddSiteTap_: function() { - assert(!this.readOnlyList); - this.showAddSiteDialog_ = true; - }, - - /** @private */ - onAddSiteDialogClosed_: function() { - this.showAddSiteDialog_ = false; - cr.ui.focusWithoutInk(assert(this.$.addSite)); - }, - - /** - * Need to use common tooltip since the tooltip in the entry is cut off from - * the iron-list. - * @param {!CustomEvent<!{target: HTMLElement, text: string}>} e - * @private - */ - onShowTooltip_: function(e) { - this.tooltipText_ = e.detail.text; - const target = e.detail.target; - // paper-tooltip normally determines the target from the |for| property, - // which is a selector. Here paper-tooltip is being reused by multiple - // potential targets. - const tooltip = this.$.tooltip; - tooltip.target = target; - /** @type {{updatePosition: Function}} */ (tooltip).updatePosition(); - const hide = () => { - this.$.tooltip.hide(); - target.removeEventListener('mouseleave', hide); - target.removeEventListener('blur', hide); - target.removeEventListener('tap', hide); - this.$.tooltip.removeEventListener('mouseenter', hide); - }; - target.addEventListener('mouseleave', hide); - target.addEventListener('blur', hide); - target.addEventListener('tap', hide); - this.$.tooltip.addEventListener('mouseenter', hide); - this.$.tooltip.show(); - }, - - // <if expr="chromeos"> - /** - * Load android sms info if required and sets it to the |androidSmsInfo_| - * property. Returns a promise that resolves when load is complete. - * @private - */ - updateAndroidSmsInfo_: function() { - // |androidSmsInfo_| is only relevant for NOTIFICATIONS category. Don't - // bother fetching it for other categories. - if (this.category === settings.ContentSettingsTypes.NOTIFICATIONS && - loadTimeData.valueExists('multideviceAllowedByPolicy') && - loadTimeData.getBoolean('multideviceAllowedByPolicy') && - !this.androidSmsInfo_) { - const multideviceSetupProxy = - settings.MultiDeviceBrowserProxyImpl.getInstance(); - return multideviceSetupProxy.getAndroidSmsInfo().then((info) => { - this.androidSmsInfo_ = info; - }); - } - - return Promise.resolve(); - }, - - /** - * Processes exceptions and adds showAndroidSmsNote field to - * the required exception item. - * @private - */ - processExceptionsForAndroidSmsInfo_: function(sites) { - if (!this.androidSmsInfo_ || !this.androidSmsInfo_.enabled) { - return sites; - } - return sites.map((site) => { - if (site.origin === this.androidSmsInfo_.origin) { - return Object.assign({showAndroidSmsNote: true}, site); - } else { - return site; - } - }); - }, - // </if> - - /** - * Populate the sites list for display. - * @private - */ - populateList_: function() { - this.browserProxy_.getExceptionList(this.category).then(exceptionList => { - this.processExceptions_(exceptionList); - this.closeActionMenu_(); - }); - }, - - /** - * Process the exception list returned from the native layer. - * @param {!Array<RawSiteException>} exceptionList - * @private - */ - processExceptions_: function(exceptionList) { - let sites = - exceptionList - .filter( - site => site.setting != settings.ContentSetting.DEFAULT && - site.setting == this.categorySubtype) - .map(site => this.expandSiteException(site)); - - // <if expr="chromeos"> - sites = this.processExceptionsForAndroidSmsInfo_(sites); - // </if> - this.updateList('sites', x => x.origin, sites); - }, - - /** - * Set up the values to use for the action menu. - * @private - */ - setUpActionMenu_: function() { - this.showAllowAction_ = - this.categorySubtype != settings.ContentSetting.ALLOW; - this.showBlockAction_ = - this.categorySubtype != settings.ContentSetting.BLOCK; - this.showSessionOnlyAction_ = - this.categorySubtype != settings.ContentSetting.SESSION_ONLY && - this.category == settings.ContentSettingsTypes.COOKIES; - }, - - /** - * @return {boolean} Whether to show the "Session Only" menu item for the - * currently active site. - * @private - */ - showSessionOnlyActionForSite_: function() { - // It makes no sense to show "clear on exit" for exceptions that only apply - // to incognito. It gives the impression that they might under some - // circumstances not be cleared on exit, which isn't true. - if (!this.actionMenuSite_ || this.actionMenuSite_.incognito) { - return false; - } - - return this.showSessionOnlyAction_; - }, - - /** - * @param {!settings.ContentSetting} contentSetting - * @private - */ - setContentSettingForActionMenuSite_: function(contentSetting) { - assert(this.actionMenuSite_); - this.browserProxy.setCategoryPermissionForPattern( - this.actionMenuSite_.origin, this.actionMenuSite_.embeddingOrigin, - this.category, contentSetting, this.actionMenuSite_.incognito); - }, - - /** @private */ - onAllowTap_: function() { - this.setContentSettingForActionMenuSite_(settings.ContentSetting.ALLOW); - this.closeActionMenu_(); - }, - - /** @private */ - onBlockTap_: function() { - this.setContentSettingForActionMenuSite_(settings.ContentSetting.BLOCK); - this.closeActionMenu_(); - }, - - /** @private */ - onSessionOnlyTap_: function() { - this.setContentSettingForActionMenuSite_( - settings.ContentSetting.SESSION_ONLY); - this.closeActionMenu_(); - }, - - /** @private */ - onEditTap_: function() { - // Close action menu without resetting |this.actionMenuSite_| since it is - // bound to the dialog. - /** @type {!CrActionMenuElement} */ (this.$$('cr-action-menu')).close(); - this.showEditExceptionDialog_ = true; - }, - - /** @private */ - onEditExceptionDialogClosed_: function() { - this.showEditExceptionDialog_ = false; - this.actionMenuSite_ = null; - if (this.activeDialogAnchor_) { - this.activeDialogAnchor_.focus(); - this.activeDialogAnchor_ = null; - } - }, - - /** @private */ - onResetTap_: function() { - const site = this.actionMenuSite_; - assert(site); - this.browserProxy.resetCategoryPermissionForPattern( - site.origin, site.embeddingOrigin, this.category, site.incognito); - this.closeActionMenu_(); - }, - - /** - * @param {!Event} e - * @private - */ - onShowActionMenu_: function(e) { - this.activeDialogAnchor_ = /** @type {!HTMLElement} */ (e.detail.anchor); - this.actionMenuSite_ = e.detail.model; - /** @type {!CrActionMenuElement} */ (this.$$('cr-action-menu')) - .showAt(this.activeDialogAnchor_); - }, - - /** @private */ - closeActionMenu_: function() { - this.actionMenuSite_ = null; - this.activeDialogAnchor_ = null; - const actionMenu = - /** @type {!CrActionMenuElement} */ (this.$$('cr-action-menu')); - if (actionMenu.open) { - actionMenu.close(); - } - }, - - /** - * @return {!Array<!SiteException>} - * @private - */ - getFilteredSites_: function() { - if (!this.searchFilter) { - return this.sites.slice(); - } - - const propNames = [ - 'displayName', - 'origin', - ]; - const searchFilter = this.searchFilter.toLowerCase(); - return this.sites.filter( - site => propNames.some( - propName => site[propName].toLowerCase().includes(searchFilter))); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_list_entry.html b/chromium/chrome/browser/resources/settings/site_settings/site_list_entry.html deleted file mode 100644 index da644580de1..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_list_entry.html +++ /dev/null @@ -1,73 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_row_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../site_favicon.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="site-list-entry"> - <template> - <style include="settings-shared"> - :host { - padding-inline-end: 4px; - } - - .settings-row { - flex: 1 - } - - /* Tooltip is hidden since site-list will display a common tooltip. */ - cr-policy-pref-indicator::part(tooltip) { - display: none; - } - </style> - <div class="list-item" focus-row-container> - <div class="settings-row" - actionable$="[[allowNavigateToSiteDetail_]]" on-click="onOriginTap_"> - <site-favicon url="[[model.origin]]"></site-favicon> - <div class="middle no-min-width"> - <div class="text-elide"> - <span class="url-directionality">[[computeDisplayName_(model)]] - </span> - </div> - - <!-- This div must not contain extra whitespace. --> - <div class="secondary text-elide" - id="siteDescription">[[computeSiteDescription_(model)]]</div> - </div> - <template is="dom-if" if="[[allowNavigateToSiteDetail_]]"> - <cr-icon-button class="subpage-arrow" - aria-label$="[[computeDisplayName_(model)]]" - aria-describedby="siteDescription" focus-row-control - focus-type="site-details"></cr-icon-button> - <div class="separator"></div> - </template> - </div> - <template is="dom-if" if="[[showPolicyPrefIndicator_]]"> - <cr-policy-pref-indicator pref="[[model]]" - icon-aria-label="[[label]]" on-mouseenter="onShowTooltip_" - on-focus="onShowTooltip_" focus-row-control focus-type="policy"> - </cr-policy-pref-indicator> - </template> - <cr-icon-button id="resetSite" class="icon-delete-gray" - hidden="[[shouldHideResetButton_(model, readOnlyList)]]" - on-click="onResetButtonTap_" - aria-label="$i18n{siteSettingsActionReset}" focus-row-control - focus-type="reset"></cr-icon-button> - <cr-icon-button id="actionMenuButton" class="icon-more-vert" - hidden="[[shouldHideActionMenu_(model, readOnlyList)]]" - on-click="onShowActionMenuTap_" title="$i18n{moreActions}" - focus-row-control focus-type="menu"></cr-icon-button> - </div> - </template> - <script src="site_list_entry.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_list_entry.js b/chromium/chrome/browser/resources/settings/site_settings/site_list_entry.js deleted file mode 100644 index b296f31a34a..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_list_entry.js +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2018 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. - -/** - * @fileoverview - * 'site-list-entry' shows an Allowed and Blocked site for a given category. - */ -Polymer({ - is: 'site-list-entry', - - behaviors: [ - SiteSettingsBehavior, - cr.ui.FocusRowBehavior, - ], - - properties: { - /** - * Some content types (like Location) do not allow the user to manually - * edit the exception list from within Settings. - * @private - */ - readOnlyList: { - type: Boolean, - value: false, - }, - - /** - * Site to display in the widget. - * @type {!SiteException} - */ - model: { - type: Object, - observer: 'onModelChanged_', - }, - - /** - * If the site represented is part of a chooser exception, the chooser type - * will be stored here to allow the permission to be manipulated. - * @private {!settings.ChooserType} - */ - chooserType: { - type: String, - value: settings.ChooserType.NONE, - }, - - /** - * If the site represented is part of a chooser exception, the chooser - * object will be stored here to allow the permission to be manipulated. - * @private - */ - chooserObject: { - type: Object, - value: null, - }, - - /** @private */ - showPolicyPrefIndicator_: { - type: Boolean, - computed: 'computeShowPolicyPrefIndicator_(model)', - }, - - /** @private */ - allowNavigateToSiteDetail_: { - type: Boolean, - value: false, - }, - }, - - /** @private */ - onShowTooltip_: function() { - const indicator = assert(this.$$('cr-policy-pref-indicator')); - // The tooltip text is used by an paper-tooltip contained inside the - // cr-policy-pref-indicator. The text is currently held in a private - // property. This text is needed here to send up to the common tooltip - // component. - const text = indicator.indicatorTooltip_; - this.fire('show-tooltip', {target: indicator, text}); - }, - - /** - * @return {boolean} - * @private - */ - shouldHideResetButton_: function() { - if (this.model === undefined) { - return false; - } - - return this.model.enforcement == - chrome.settingsPrivate.Enforcement.ENFORCED || - !(this.readOnlyList || !!this.model.embeddingOrigin); - }, - - /** - * @return {boolean} - * @private - */ - shouldHideActionMenu_: function() { - if (this.model === undefined) { - return false; - } - - return this.model.enforcement == - chrome.settingsPrivate.Enforcement.ENFORCED || - this.readOnlyList || !!this.model.embeddingOrigin; - }, - - /** - * A handler for selecting a site (by clicking on the origin). - * @private - */ - onOriginTap_: function() { - if (!this.allowNavigateToSiteDetail_) { - return; - } - settings.navigateTo( - settings.routes.SITE_SETTINGS_SITE_DETAILS, - new URLSearchParams('site=' + this.model.origin)); - }, - - /** - * Returns the appropriate display name to show for the exception. - * This can, for example, be the website that is affected itself, - * or the website whose third parties are also affected. - * @return {string} - */ - computeDisplayName_: function() { - if (this.model.embeddingOrigin && - this.model.category === settings.ContentSettingsTypes.COOKIES && - this.model.origin.trim() == settings.SITE_EXCEPTION_WILDCARD) { - return this.model.embeddingOrigin; - } - return this.model.displayName; - }, - - /** - * Returns the appropriate site description to display. This can, for example, - * be blank, an 'embedded on <site>' or 'Current incognito session' (or a - * mix of the last two). - * @return {string} - */ - computeSiteDescription_: function() { - let description = ''; - - if (this.model.embeddingOrigin) { - if (this.model.category === settings.ContentSettingsTypes.COOKIES && - this.model.origin.trim() == settings.SITE_EXCEPTION_WILDCARD) { - description = - loadTimeData.getString( - 'siteSettingsCookiesThirdPartyExceptionLabel'); - } else { - description = loadTimeData.getStringF( - 'embeddedOnHost', this.sanitizePort(this.model.embeddingOrigin)); - } - } else if (this.category == settings.ContentSettingsTypes.GEOLOCATION) { - description = loadTimeData.getString('embeddedOnAnyHost'); - } - - // <if expr="chromeos"> - if (this.model.category === settings.ContentSettingsTypes.NOTIFICATIONS && - this.model.showAndroidSmsNote) { - description = loadTimeData.getString('androidSmsNote'); - } - // </if> - - if (this.model.incognito) { - if (description.length > 0) { - description = - loadTimeData.getStringF('embeddedIncognitoSite', description); - } else { - description = loadTimeData.getString('incognitoSite'); - } - } - return description; - }, - - /** - * @return {boolean} - * @private - */ - computeShowPolicyPrefIndicator_: function() { - return this.model.enforcement == - chrome.settingsPrivate.Enforcement.ENFORCED && - !!this.model.controlledBy; - }, - - /** @private */ - onResetButtonTap_: function() { - // Use the appropriate method to reset a chooser exception. - if (this.chooserType !== settings.ChooserType.NONE && - this.chooserObject != null) { - this.browserProxy.resetChooserExceptionForSite( - this.chooserType, this.model.origin, this.model.embeddingOrigin, - this.chooserObject); - return; - } - - this.browserProxy.resetCategoryPermissionForPattern( - this.model.origin, this.model.embeddingOrigin, this.model.category, - this.model.incognito); - }, - - /** @private */ - onShowActionMenuTap_: function() { - // Chooser exceptions do not support the action menu, so do nothing. - if (this.chooserType !== settings.ChooserType.NONE) { - return; - } - - this.fire( - 'show-action-menu', - {anchor: this.$.actionMenuButton, model: this.model}); - }, - - /** @private */ - onModelChanged_: function() { - if (!this.model) { - this.allowNavigateToSiteDetail_ = false; - return; - } - this.browserProxy.isOriginValid(this.model.origin).then((valid) => { - this.allowNavigateToSiteDetail_ = valid; - }); - } -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.html b/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.html deleted file mode 100644 index 5f011e4f7b7..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.html +++ /dev/null @@ -1,8 +0,0 @@ -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="constants.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<script src="site_settings_behavior.js"></script> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js b/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js deleted file mode 100644 index 545c49afcba..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_settings_behavior.js +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2015 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. - -/** - * @fileoverview Behavior common to Site Settings classes. - */ - - -/** - * The source information on site exceptions doesn't exactly match the - * controlledBy values. - * TODO(dschuyler): Can they be unified (and this dictionary removed)? - * @type {!Object} - */ -const kControlledByLookup = { - 'extension': chrome.settingsPrivate.ControlledBy.EXTENSION, - 'HostedApp': chrome.settingsPrivate.ControlledBy.EXTENSION, - 'platform_app': chrome.settingsPrivate.ControlledBy.EXTENSION, - 'policy': chrome.settingsPrivate.ControlledBy.USER_POLICY, -}; - - -/** @polymerBehavior */ -const SiteSettingsBehaviorImpl = { - properties: { - /** - * The string ID of the category this element is displaying data for. - * See site_settings/constants.js for possible values. - * @type {!settings.ContentSettingsTypes} - */ - category: String, - - /** - * A cached list of ContentSettingsTypes with a standard allow-block-ask - * pattern that are currently enabled for use. This property is the same - * across all elements with SiteSettingsBehavior ('static'). - * @type {Array<settings.ContentSettingsTypes>} - * @private - */ - contentTypes_: { - type: Array, - value: [], - }, - - /** - * The browser proxy used to retrieve and change information about site - * settings categories and the sites within. - * @type {settings.SiteSettingsPrefsBrowserProxy} - */ - browserProxy: Object, - }, - - /** @override */ - created: function() { - this.browserProxy = - settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); - }, - - /** @override */ - ready: function() { - this.ContentSetting = settings.ContentSetting; - }, - - /** - * Ensures the URL has a scheme (assumes http if omitted). - * @param {string} url The URL with or without a scheme. - * @return {string} The URL with a scheme, or an empty string. - */ - ensureUrlHasScheme: function(url) { - if (url.length == 0) { - return url; - } - return url.includes('://') ? url : 'http://' + url; - }, - - /** - * Removes redundant ports, such as port 80 for http and 443 for https. - * @param {string} url The URL to sanitize. - * @return {string} The URL without redundant ports, if any. - */ - sanitizePort: function(url) { - const urlWithScheme = this.ensureUrlHasScheme(url); - if (urlWithScheme.startsWith('https://') && - urlWithScheme.endsWith(':443')) { - return url.slice(0, -4); - } - if (urlWithScheme.startsWith('http://') && urlWithScheme.endsWith(':80')) { - return url.slice(0, -3); - } - return url; - }, - - /** - * Returns true if the passed content setting is considered 'enabled'. - * @param {string} setting - * @return {boolean} - * @protected - */ - computeIsSettingEnabled: function(setting) { - return setting != settings.ContentSetting.BLOCK; - }, - - /** - * Converts a string origin/pattern to a URL. - * @param {string} originOrPattern The origin/pattern to convert to URL. - * @return {URL} The URL to return (or null if origin is not a valid URL). - * @protected - */ - toUrl: function(originOrPattern) { - if (originOrPattern.length == 0) { - return null; - } - // TODO(finnur): Hmm, it would probably be better to ensure scheme on the - // JS/C++ boundary. - // TODO(dschuyler): I agree. This filtering should be done in one go, rather - // that during the sort. The URL generation should be wrapped in a try/catch - // as well. - originOrPattern = originOrPattern.replace('*://', ''); - originOrPattern = originOrPattern.replace('[*.]', ''); - return new URL(this.ensureUrlHasScheme(originOrPattern)); - }, - - /** - * Convert an exception (received from the C++ handler) to a full - * SiteException. - * @param {!RawSiteException} exception The raw site exception from C++. - * @return {!SiteException} The expanded (full) SiteException. - * @protected - */ - expandSiteException: function(exception) { - const origin = exception.origin; - const embeddingOrigin = exception.embeddingOrigin; - - // TODO(patricialor): |exception.source| should be one of the values defined - // in |settings.SiteSettingSource|. - let enforcement = /** @type {?chrome.settingsPrivate.Enforcement} */ (null); - if (exception.source == 'extension' || exception.source == 'HostedApp' || - exception.source == 'platform_app' || exception.source == 'policy') { - enforcement = chrome.settingsPrivate.Enforcement.ENFORCED; - } - - const controlledBy = /** @type {!chrome.settingsPrivate.ControlledBy} */ ( - kControlledByLookup[exception.source] || - chrome.settingsPrivate.ControlledBy.PRIMARY_USER); - - return { - category: this.category, - origin: origin, - displayName: exception.displayName, - embeddingOrigin: embeddingOrigin, - incognito: exception.incognito, - setting: exception.setting, - enforcement: enforcement, - controlledBy: controlledBy, - }; - }, - - /** - * Returns list of categories for each setting.ContentSettingsTypes that are - * currently enabled. - * @return {!Array<!settings.ContentSettingsTypes>} - */ - getCategoryList: function() { - if (this.contentTypes_.length == 0) { - for (const typeName in settings.ContentSettingsTypes) { - const contentType = settings.ContentSettingsTypes[typeName]; - // <if expr="not chromeos"> - if (contentType == settings.ContentSettingsTypes.PROTECTED_CONTENT) { - continue; - } - // </if> - // Some categories store their data in a custom way. - if (contentType == settings.ContentSettingsTypes.COOKIES || - contentType == settings.ContentSettingsTypes.PROTOCOL_HANDLERS || - contentType == settings.ContentSettingsTypes.ZOOM_LEVELS) { - continue; - } - this.contentTypes_.push(contentType); - } - } - - const addOrRemoveSettingWithFlag = (type, flag) => { - if (loadTimeData.getBoolean(flag)) { - if (!this.contentTypes_.includes(type)) { - this.contentTypes_.push(type); - } - } else { - if (this.contentTypes_.includes(type)) { - this.contentTypes_.splice(this.contentTypes_.indexOf(type), 1); - } - } - }; - // These categories are gated behind flags. - addOrRemoveSettingWithFlag( - settings.ContentSettingsTypes.SERIAL_PORTS, - 'enableExperimentalWebPlatformFeatures'); - addOrRemoveSettingWithFlag( - settings.ContentSettingsTypes.BLUETOOTH_SCANNING, - 'enableExperimentalWebPlatformFeatures'); - addOrRemoveSettingWithFlag( - settings.ContentSettingsTypes.ADS, - 'enableSafeBrowsingSubresourceFilter'); - addOrRemoveSettingWithFlag( - settings.ContentSettingsTypes.PAYMENT_HANDLER, - 'enablePaymentHandlerContentSetting'); - addOrRemoveSettingWithFlag( - settings.ContentSettingsTypes.NATIVE_FILE_SYSTEM_WRITE, - 'enableNativeFileSystemWriteContentSetting'); - addOrRemoveSettingWithFlag( - settings.ContentSettingsTypes.MIXEDSCRIPT, - 'enableInsecureContentContentSetting'); - return this.contentTypes_.slice(0); - }, - -}; - -/** @polymerBehavior */ -const SiteSettingsBehavior = [SiteSettingsBehaviorImpl]; diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.html b/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.html deleted file mode 100644 index 945c6ebe6c8..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ -<script src="site_settings_prefs_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js b/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js deleted file mode 100644 index 2b826c3b5a2..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js +++ /dev/null @@ -1,533 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview A helper object used from the "Site Settings" section to - * interact with the content settings prefs. - */ - -/** - * The handler will send a policy source that is similar, but not exactly the - * same as a ControlledBy value. If the ContentSettingProvider is omitted it - * should be treated as 'default'. - * @enum {string} - */ -const ContentSettingProvider = { - POLICY: 'policy', - SUPERVISED_USER: 'supervised_user', - EXTENSION: 'extension', - INSTALLED_WEBAPP_PROVIDER: 'installed_webapp_provider', - NOTIFICATION_ANDROID: 'notification_android', - EPHEMERAL: 'ephemeral', - PREFERENCE: 'preference', - DEFAULT: 'default', - TESTS: 'tests', - TESTS_OTHER: 'tests_other' -}; - -/** - * Stores information about if a content setting is valid, and why. - * @typedef {{isValid: boolean, - * reason: ?string}} - */ -let IsValid; - -/** - * Stores origin information. The |hasPermissionSettings| will be set to true - * when this origin has permissions or when there is a pattern permission - * affecting this origin. - * @typedef {{origin: string, - * engagement: number, - * usage: number, - numCookies: number, - hasPermissionSettings: boolean}} - */ -let OriginInfo; - -/** - * Represents a list of sites, grouped under the same eTLD+1. For example, an - * origin "https://www.example.com" would be grouped together with - * "https://login.example.com" and "http://example.com" under a common eTLD+1 of - * "example.com". - * @typedef {{etldPlus1: string, - * numCookies: number, - * origins: Array<OriginInfo>}} - */ -let SiteGroup; - -/** - * The site exception information passed from the C++ handler. - * See also: SiteException. - * @typedef {{embeddingOrigin: string, - * incognito: boolean, - * origin: string, - * displayName: string, - * setting: !settings.ContentSetting, - * source: !settings.SiteSettingSource}} - */ -let RawSiteException; - -/** - * The site exception after it has been converted/filtered for UI use. - * See also: RawSiteException. - * @typedef {{category: !settings.ContentSettingsTypes, - * embeddingOrigin: string, - * incognito: boolean, - * origin: string, - * displayName: string, - * setting: !settings.ContentSetting, - * enforcement: ?chrome.settingsPrivate.Enforcement, - * controlledBy: !chrome.settingsPrivate.ControlledBy, - * showAndroidSmsNote: (boolean|undefined)}} - */ -let SiteException; - -/** - * The chooser exception information passed from the C++ handler. - * See also: ChooserException. - * @typedef {{chooserType: !settings.ChooserType, - * displayName: string, - * object: Object, - * sites: Array<!RawSiteException>}} - */ -let RawChooserException; - -/** - * The chooser exception after it has been converted/filtered for UI use. - * See also: RawChooserException. - * @typedef {{chooserType: !settings.ChooserType, - * displayName: string, - * object: Object, - * sites: Array<!SiteException>}} - */ -let ChooserException; - -/** - * @typedef {{setting: !settings.ContentSetting, - * source: !ContentSettingProvider}} - */ -let DefaultContentSetting; - -/** - * @typedef {{name: string, - * id: string}} - */ -let MediaPickerEntry; - -/** - * @typedef {{protocol: string, - * spec: string}} - */ -let ProtocolHandlerEntry; - -/** - * @typedef {{origin: string, - * setting: string, - * source: string, - * zoom: string}} - */ -let ZoomLevelEntry; - -cr.define('settings', function() { - /** @interface */ - class SiteSettingsPrefsBrowserProxy { - /** - * Sets the default value for a site settings category. - * @param {string} contentType The name of the category to change. - * @param {string} defaultValue The name of the value to set as default. - */ - setDefaultValueForContentType(contentType, defaultValue) {} - - /** - * Gets the default value for a site settings category. - * @param {string} contentType The name of the category to query. - * @return {!Promise<!DefaultContentSetting>} - */ - getDefaultValueForContentType(contentType) {} - - /** - * Gets a list of sites, grouped by eTLD+1, affected by any of the content - * settings specified by |contentTypes|. - * @param {!Array<!settings.ContentSettingsTypes>} contentTypes A list of - * the content types to retrieve sites for. - * @return {!Promise<!Array<!SiteGroup>>} - */ - getAllSites(contentTypes) {} - - /** - * Gets the chooser exceptions for a particular chooser type. - * @param {settings.ChooserType} chooserType The chooser type to grab - * exceptions from. - * @return {!Promise<!Array<!RawChooserException>>} - */ - getChooserExceptionList(chooserType) {} - - /** - * Converts a given number of bytes into a human-readable format, with data - * units. - * @param {number} numBytes The number of bytes to convert. - * @return {!Promise<string>} - */ - getFormattedBytes(numBytes) {} - - /** - * Gets the exceptions (site list) for a particular category. - * @param {string} contentType The name of the category to query. - * @return {!Promise<!Array<!RawSiteException>>} - */ - getExceptionList(contentType) {} - - /** - * Gets a list of category permissions for a given origin. Note that this - * may be different to the results retrieved by getExceptionList(), since it - * combines different sources of data to get a permission's value. - * @param {string} origin The origin to look up permissions for. - * @param {!Array<!settings.ContentSettingsTypes>} contentTypes A list of - * categories to retrieve the ContentSetting for. - * @return {!Promise<!NodeList<!RawSiteException>>} - */ - getOriginPermissions(origin, contentTypes) {} - - /** - * Resets the permissions for a list of categories for a given origin. This - * does not support incognito settings or patterns. - * @param {string} origin The origin to reset permissions for. - * @param {!Array<!settings.ContentSettingsTypes>} contentTypes A list of - * categories to set the permission for. Typically this would be a - * single category, but sometimes it is useful to clear any permissions - * set for all categories. - * @param {!settings.ContentSetting} blanketSetting The setting to set all - * permissions listed in |contentTypes| to. - */ - setOriginPermissions(origin, contentTypes, blanketSetting) {} - - /** - * Clears the flag that's set when the user has changed the Flash permission - * for this particular origin. - * @param {string} origin The origin to clear the Flash preference for. - */ - clearFlashPref(origin) {} - - /** - * Resets the category permission for a given origin (expressed as primary - * and secondary patterns). Only use this if intending to remove an - * exception - use setOriginPermissions() for origin-scoped settings. - * @param {string} primaryPattern The origin to change (primary pattern). - * @param {string} secondaryPattern The embedding origin to change - * (secondary pattern). - * @param {string} contentType The name of the category to reset. - * @param {boolean} incognito Whether this applies only to a current - * incognito session exception. - */ - resetCategoryPermissionForPattern( - primaryPattern, secondaryPattern, contentType, incognito) {} - - /** - * Removes a particular chooser object permission by origin and embedding - * origin. - * @param {settings.ChooserType} chooserType The chooser exception type - * @param {string} origin The origin to look up the permission for. - * @param {string} embeddingOrigin the embedding origin to look up. - * @param {!Object} exception The exception to revoke permission for. - */ - resetChooserExceptionForSite( - chooserType, origin, embeddingOrigin, exception) {} - - /** - * Sets the category permission for a given origin (expressed as primary and - * secondary patterns). Only use this if intending to set an exception - use - * setOriginPermissions() for origin-scoped settings. - * @param {string} primaryPattern The origin to change (primary pattern). - * @param {string} secondaryPattern The embedding origin to change - * (secondary pattern). - * @param {string} contentType The name of the category to change. - * @param {string} value The value to change the permission to. - * @param {boolean} incognito Whether this rule applies only to the current - * incognito session. - */ - setCategoryPermissionForPattern( - primaryPattern, secondaryPattern, contentType, value, incognito) {} - - /** - * Checks whether an origin is valid. - * @param {string} origin The origin to check. - * @return {!Promise<boolean>} True if the origin is valid. - */ - isOriginValid(origin) {} - - /** - * Checks whether a setting is valid. - * @param {string} pattern The pattern to check. - * @param {settings.ContentSettingsTypes} category What kind of setting, - * e.g. Location, Camera, Cookies, etc. - * @return {!Promise<IsValid>} Contains whether or not the pattern is - * valid for the type, and if it is invalid, the reason why. - */ - isPatternValidForType(pattern, category) {} - - /** - * Gets the list of default capture devices for a given type of media. List - * is returned through a JS call to updateDevicesMenu. - * @param {string} type The type to look up. - */ - getDefaultCaptureDevices(type) {} - - /** - * Sets a default devices for a given type of media. - * @param {string} type The type of media to configure. - * @param {string} defaultValue The id of the media device to set. - */ - setDefaultCaptureDevice(type, defaultValue) {} - - /** - * observes _all_ of the the protocol handler state, which includes a list - * that is returned through JS calls to 'setProtocolHandlers' along with - * other state sent with the messages 'setIgnoredProtocolHandler' and - * 'setHandlersEnabled'. - */ - observeProtocolHandlers() {} - - /** - * Observes one aspect of the protocol handler so that updates to the - * enabled/disabled state are sent. A 'setHandlersEnabled' will be sent - * from C++ immediately after receiving this observe request and updates - * may follow via additional 'setHandlersEnabled' messages. - * - * If |observeProtocolHandlers| is called, there's no need to call this - * observe as well. - */ - observeProtocolHandlersEnabledState() {} - - /** - * Enables or disables the ability for sites to ask to become the default - * protocol handlers. - * @param {boolean} enabled Whether sites can ask to become default. - */ - setProtocolHandlerDefault(enabled) {} - - /** - * Sets a certain url as default for a given protocol handler. - * @param {string} protocol The protocol to set a default for. - * @param {string} url The url to use as the default. - */ - setProtocolDefault(protocol, url) {} - - /** - * Deletes a certain protocol handler by url. - * @param {string} protocol The protocol to delete the url from. - * @param {string} url The url to delete. - */ - removeProtocolHandler(protocol, url) {} - - /** - * Fetches the incognito status of the current profile (whether an incognito - * profile exists). Returns the results via onIncognitoStatusChanged. - */ - updateIncognitoStatus() {} - - /** - * Fetches the currently defined zoom levels for sites. Returns the results - * via onZoomLevelsChanged. - */ - fetchZoomLevels() {} - - /** - * Removes a zoom levels for a given host. - * @param {string} host The host to remove zoom levels for. - */ - removeZoomLevel(host) {} - - // <if expr="chromeos"> - /** - * Links to com.android.settings.Settings$ManageDomainUrlsActivity on ARC - * side, this is to manage app preferences. - */ - showAndroidManageAppLinks() {} - // </if> - - /** - * Fetches the current block autoplay state. Returns the results via - * onBlockAutoplayStatusChanged. - */ - fetchBlockAutoplayStatus() {} - - /** - * Clears all the web storage data and cookies for a given etld+1. - * @param {string} etldPlus1 The etld+1 to clear data from. - */ - clearEtldPlus1DataAndCookies(etldPlus1) {} - - /** - * Record All Sites Page action for metrics. - * @param {number} action number. - */ - recordAction(action) {} - } - - /** - * @implements {settings.SiteSettingsPrefsBrowserProxy} - */ - class SiteSettingsPrefsBrowserProxyImpl { - /** @override */ - setDefaultValueForContentType(contentType, defaultValue) { - chrome.send('setDefaultValueForContentType', [contentType, defaultValue]); - } - - /** @override */ - getDefaultValueForContentType(contentType) { - return cr.sendWithPromise('getDefaultValueForContentType', contentType); - } - - /** @override */ - getAllSites(contentTypes) { - return cr.sendWithPromise('getAllSites', contentTypes); - } - - /** @override */ - getChooserExceptionList(chooserType) { - return cr.sendWithPromise('getChooserExceptionList', chooserType); - } - - /** @override */ - getFormattedBytes(numBytes) { - return cr.sendWithPromise('getFormattedBytes', numBytes); - } - - /** @override */ - getExceptionList(contentType) { - return cr.sendWithPromise('getExceptionList', contentType); - } - - /** @override */ - getOriginPermissions(origin, contentTypes) { - return cr.sendWithPromise('getOriginPermissions', origin, contentTypes); - } - - /** @override */ - setOriginPermissions(origin, contentTypes, blanketSetting) { - chrome.send( - 'setOriginPermissions', [origin, contentTypes, blanketSetting]); - } - - /** @override */ - clearFlashPref(origin) { - chrome.send('clearFlashPref', [origin]); - } - - /** @override */ - resetCategoryPermissionForPattern( - primaryPattern, secondaryPattern, contentType, incognito) { - chrome.send( - 'resetCategoryPermissionForPattern', - [primaryPattern, secondaryPattern, contentType, incognito]); - } - - /** @override */ - resetChooserExceptionForSite( - chooserType, origin, embeddingOrigin, exception) { - chrome.send( - 'resetChooserExceptionForSite', - [chooserType, origin, embeddingOrigin, exception]); - } - - /** @override */ - setCategoryPermissionForPattern( - primaryPattern, secondaryPattern, contentType, value, incognito) { - chrome.send( - 'setCategoryPermissionForPattern', - [primaryPattern, secondaryPattern, contentType, value, incognito]); - } - - /** @override */ - isOriginValid(origin) { - return cr.sendWithPromise('isOriginValid', origin); - } - - /** @override */ - isPatternValidForType(pattern, category) { - return cr.sendWithPromise('isPatternValidForType', pattern, category); - } - - /** @override */ - getDefaultCaptureDevices(type) { - chrome.send('getDefaultCaptureDevices', [type]); - } - - /** @override */ - setDefaultCaptureDevice(type, defaultValue) { - chrome.send('setDefaultCaptureDevice', [type, defaultValue]); - } - - /** @override */ - observeProtocolHandlers() { - chrome.send('observeProtocolHandlers'); - } - - /** @override */ - observeProtocolHandlersEnabledState() { - chrome.send('observeProtocolHandlersEnabledState'); - } - - /** @override */ - setProtocolHandlerDefault(enabled) { - chrome.send('setHandlersEnabled', [enabled]); - } - - /** @override */ - setProtocolDefault(protocol, url) { - chrome.send('setDefault', [protocol, url]); - } - - /** @override */ - removeProtocolHandler(protocol, url) { - chrome.send('removeHandler', [protocol, url]); - } - - /** @override */ - updateIncognitoStatus() { - chrome.send('updateIncognitoStatus'); - } - - /** @override */ - fetchZoomLevels() { - chrome.send('fetchZoomLevels'); - } - - /** @override */ - removeZoomLevel(host) { - chrome.send('removeZoomLevel', [host]); - } - - // <if expr="chromeos"> - /** @override */ - showAndroidManageAppLinks() { - chrome.send('showAndroidManageAppLinks'); - } - // </if> - - /** @override */ - fetchBlockAutoplayStatus() { - chrome.send('fetchBlockAutoplayStatus'); - } - - /** @override */ - clearEtldPlus1DataAndCookies(etldPlus1) { - chrome.send('clearEtldPlus1DataAndCookies', [etldPlus1]); - } - - /** @override */ - recordAction(action) { - chrome.send('recordAction', [action]); - } - } - - // The singleton instance_ is replaced with a test version of this wrapper - // during testing. - cr.addSingletonGetter(SiteSettingsPrefsBrowserProxyImpl); - - return { - SiteSettingsPrefsBrowserProxy: SiteSettingsPrefsBrowserProxy, - SiteSettingsPrefsBrowserProxyImpl: SiteSettingsPrefsBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/website_usage_private_api.html b/chromium/chrome/browser/resources/settings/site_settings/website_usage_private_api.html deleted file mode 100644 index d2867362724..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/website_usage_private_api.html +++ /dev/null @@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/cr.html"> -<script src="website_usage_private_api.js"></script> diff --git a/chromium/chrome/browser/resources/settings/site_settings/website_usage_private_api.js b/chromium/chrome/browser/resources/settings/site_settings/website_usage_private_api.js deleted file mode 100644 index 214b3ff9259..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/website_usage_private_api.js +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2016 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. - -(function() { -'use strict'; - -Polymer({ - is: 'website-usage-private-api', - - properties: { - /** - * The amount of data used by the given website. - */ - websiteDataUsage: { - type: String, - notify: true, - }, - - /** - * The number of cookies used by the given website. - */ - websiteCookieUsage: { - type: String, - notify: true, - }, - }, - - /** @override */ - attached: function() { - settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this; - }, - - /** @param {string} host */ - fetchUsageTotal: function(host) { - settings.WebsiteUsagePrivateApi.fetchUsageTotal(host); - }, - - /** - * @param {string} origin - */ - clearUsage: function(origin) { - settings.WebsiteUsagePrivateApi.clearUsage(origin); - }, - - /** @param {string} origin */ - notifyUsageDeleted: function(origin) { - this.fire('usage-deleted', {origin: origin}); - }, -}); -})(); - -cr.define('settings.WebsiteUsagePrivateApi', function() { - /** - * @type {Object} An instance of the polymer object defined above. - * All data will be set here. - */ - const websiteUsagePolymerInstance = null; - - /** - * @type {string} The host for which the usage total is being fetched. - */ - let hostName; - - /** - * Encapsulates the calls between JS and C++ to fetch how much storage the - * host is using. - * Will update the data in |websiteUsagePolymerInstance|. - */ - const fetchUsageTotal = function(host) { - const instance = - settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance; - if (instance != null) { - instance.websiteDataUsage = ''; - } - - hostName = host; - chrome.send('fetchUsageTotal', [host]); - }; - - /** - * Callback for when the usage total is known. - * @param {string} host The host that the usage was fetched for. - * @param {string} usage The string showing how much data the given host - * is using. - */ - const returnUsageTotal = function(host, usage, cookies) { - const instance = - settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance; - if (instance == null) { - return; - } - - if (hostName == host) { - instance.websiteDataUsage = usage; - instance.websiteCookieUsage = cookies; - } - }; - - /** - * Deletes the storage being used for a given origin. - * @param {string} origin The origin to delete storage for. - */ - const clearUsage = function(origin) { - chrome.send('clearUsage', [origin]); - const instance = - settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance; - if (instance == null) { - return; - } - - instance.notifyUsageDeleted(origin); - }; - - return { - websiteUsagePolymerInstance: websiteUsagePolymerInstance, - fetchUsageTotal: fetchUsageTotal, - returnUsageTotal: returnUsageTotal, - clearUsage: clearUsage, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/site_settings/zoom_levels.html b/chromium/chrome/browser/resources/settings/site_settings/zoom_levels.html deleted file mode 100644 index f83154708ff..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/zoom_levels.html +++ /dev/null @@ -1,61 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/list_property_update_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../site_favicon.html"> -<link rel="import" href="site_settings_behavior.html"> -<link rel="import" href="site_settings_prefs_browser_proxy.html"> - -<dom-module id="zoom-levels"> - <template> - <style include="settings-shared"> - :host { - display: block; - } - - .zoom-label { - color: var(--cr-secondary-text-color); - margin-inline-end: 16px; - } - - #empty { - margin-top: 15px; - } - - .list-item site-favicon { - flex-shrink: 0; - } - - .list-item .middle { - overflow-x: hidden; - text-overflow: ellipsis; - } - </style> - <div class="list-frame vertical-list" id="listContainer"> - <iron-list id="list" preserve-focus items="[[sites_]]" - class="cr-separators" risk-selection> - <template> - <div class="list-item" first$="[[!index]]"> - <site-favicon url="[[item.originForFavicon]]"></site-favicon> - <div class="middle"> - <span class="url-directionality">[[item.displayName]]</span> - </div> - <div class="zoom-label">[[item.zoom]]</div> - <cr-icon-button class="icon-clear" on-click="removeZoomLevel_" - title="$i18n{siteSettingsRemoveZoomLevel}" - tabindex$="[[tabIndex]]"></cr-icon-button> - </div> - </template> - </iron-list> - <div id="empty" hidden$="[[!showNoSites_]]"> - $i18n{siteSettingsNoZoomedSites} - </div> - </div> - </template> - <script src="zoom_levels.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/zoom_levels.js b/chromium/chrome/browser/resources/settings/site_settings/zoom_levels.js deleted file mode 100644 index e600e08fdee..00000000000 --- a/chromium/chrome/browser/resources/settings/site_settings/zoom_levels.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 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. - -/** - * @fileoverview - * 'zoom-levels' is the polymer element for showing the sites that are zoomed in - * or out. - */ - -Polymer({ - is: 'zoom-levels', - - behaviors: [ - ListPropertyUpdateBehavior, - SiteSettingsBehavior, - WebUIListenerBehavior, - ], - - properties: { - /** - * Array of sites that are zoomed in or out. - * @type {!Array<ZoomLevelEntry>} - */ - sites_: { - type: Array, - value: () => [], - }, - - /** @private */ - showNoSites_: { - type: Boolean, - value: false, - }, - }, - - /** @override */ - ready: function() { - this.addWebUIListener( - 'onZoomLevelsChanged', this.onZoomLevelsChanged_.bind(this)); - this.browserProxy.fetchZoomLevels(); - }, - - /** - * A handler for when zoom levels change. - * @param {!Array<ZoomLevelEntry>} sites The up to date list of sites and - * their zoom levels. - */ - onZoomLevelsChanged_: function(sites) { - this.updateList('sites_', item => item.origin, sites); - this.showNoSites_ = this.sites_.length == 0; - }, - - /** - * A handler for when a zoom level for a site is deleted. - * @param {!{model: !{index: number}}} event - * @private - */ - removeZoomLevel_: function(event) { - const site = this.sites_[event.model.index]; - this.browserProxy.removeZoomLevel(site.origin); - }, -}); |