// 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. import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js'; import 'chrome://resources/cr_elements/cr_icons_css.m.js'; import 'chrome://resources/cr_elements/cr_toggle/cr_toggle.m.js'; import 'chrome://resources/cr_elements/hidden_style_css.m.js'; import 'chrome://resources/cr_elements/icons.m.js'; import 'chrome://resources/cr_elements/shared_style_css.m.js'; import 'chrome://resources/cr_elements/shared_vars_css.m.js'; import 'chrome://resources/js/action_link.js'; import 'chrome://resources/cr_elements/action_link_css.m.js'; import './icons.js'; import './shared_style.js'; import './shared_vars.js'; import './strings.m.js'; import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js'; import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; import 'chrome://resources/polymer/v3_0/paper-tooltip/paper-tooltip.js'; import {getToastManager} from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.m.js'; import {assert, assertNotReached} from 'chrome://resources/js/assert.m.js'; import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {flush, html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {ItemBehavior} from './item_behavior.js'; import {computeInspectableViewLabel, EnableControl, getEnableControl, getItemSource, getItemSourceString, isEnabled, SourceType, userCanChangeEnablement} from './item_util.js'; import {navigation, Page} from './navigation_helper.js'; /** @interface */ export class ItemDelegate { /** @param {string} id */ deleteItem(id) {} /** * @param {string} id * @param {boolean} isEnabled */ setItemEnabled(id, isEnabled) {} /** * @param {string} id * @param {boolean} isAllowedIncognito */ setItemAllowedIncognito(id, isAllowedIncognito) {} /** * @param {string} id * @param {boolean} isAllowedOnFileUrls */ setItemAllowedOnFileUrls(id, isAllowedOnFileUrls) {} /** * @param {string} id * @param {!chrome.developerPrivate.HostAccess} hostAccess */ setItemHostAccess(id, hostAccess) {} /** * @param {string} id * @param {boolean} collectsErrors */ setItemCollectsErrors(id, collectsErrors) {} /** * @param {string} id * @param {chrome.developerPrivate.ExtensionView} view */ inspectItemView(id, view) {} /** * @param {string} url */ openUrl(url) {} /** * @param {string} id * @return {!Promise} */ reloadItem(id) {} /** @param {string} id */ repairItem(id) {} /** @param {!chrome.developerPrivate.ExtensionInfo} extension */ showItemOptionsPage(extension) {} /** @param {string} id */ showInFolder(id) {} /** * @param {string} id * @return {!Promise} */ getExtensionSize(id) {} /** * @param {string} id * @param {string} host * @return {!Promise} */ addRuntimeHostPermission(id, host) {} /** * @param {string} id * @param {string} host * @return {!Promise} */ removeRuntimeHostPermission(id, host) {} // TODO(tjudkins): This function is not specific to items, so should be pulled // out to a more generic place when we need to access it from elsewhere. /** @param {string} metricName */ recordUserAction(metricName) {} } Polymer({ is: 'extensions-item', _template: html`{__html_template__}`, behaviors: [I18nBehavior, ItemBehavior], properties: { // The item's delegate, or null. delegate: { type: Object, }, // Whether or not dev mode is enabled. inDevMode: { type: Boolean, value: false, }, // The underlying ExtensionInfo itself. Public for use in declarative // bindings. /** @type {chrome.developerPrivate.ExtensionInfo} */ data: { type: Object, }, // Whether or not the expanded view of the item is shown. /** @private */ showingDetails_: { type: Boolean, value: false, }, }, /** Prevents reloading the same item while it's already being reloaded. */ isReloading_: false, observers: [ 'observeIdVisibility_(inDevMode, showingDetails_, data.id)', ], /** @return {!HTMLElement} The "Details" button. */ getDetailsButton() { return /** @type {!HTMLElement} */ (this.$.detailsButton); }, /** @return {?HTMLElement} The "Errors" button, if it exists. */ getErrorsButton() { return /** @type {?HTMLElement} */ (this.$$('#errors-button')); }, /** @private string */ a11yAssociation_() { // Don't use I18nBehavior.i18n because of additional checks it performs. // Polymer ensures that this string is not stamped into arbitrary HTML. // |this.data.name| can contain any data including html tags. // ex: "My