Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: ui/webui/resources/cr_elements/v1_0/network/cr_network_list_item.js

Issue 1406023003: Elim cr_elements/v1_0 subdirectory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/cr_elements/v1_0/network/cr_network_list_item.js
diff --git a/ui/webui/resources/cr_elements/v1_0/network/cr_network_list_item.js b/ui/webui/resources/cr_elements/v1_0/network/cr_network_list_item.js
deleted file mode 100644
index 84d2c1375e66d2ec103467a88e287a96d5c3f101..0000000000000000000000000000000000000000
--- a/ui/webui/resources/cr_elements/v1_0/network/cr_network_list_item.js
+++ /dev/null
@@ -1,221 +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 Polymer element for displaying information about a network
- * in a list or summary based on ONC state properties.
- */
-(function() {
-'use strict';
-
-/**
- * TODO(stevenjb): Replace getText with a proper localization function that
- * handles string substitution.
- * Performs argument substitution, replacing $1, $2, etc in 'text' with
- * corresponding entries in |args|.
- * @param {string} text The string to perform the substitution on.
- * @param {?Array<string>=} opt_args The arguments to replace $1, $2, etc with.
- */
-function getText(text, opt_args) {
- var res;
- if (loadTimeData && loadTimeData.data_)
- res = loadTimeData.getString(text) || text;
- else
- res = text;
- if (!opt_args)
- return res;
- for (let i = 0; i < opt_args.length; ++i) {
- let key = '$' + (i + 1);
- res = res.replace(key, opt_args[i]);
- }
- return res;
-}
-
-/**
- * Returns the appropriate connection state text.
- * @param {string} state The connection state.
- * @param {string} name The name of the network.
- */
-function getConnectionStateText(state, name) {
- if (state == CrOnc.ConnectionState.CONNECTED)
- return getText('networkConnected', [name]);
- if (state == CrOnc.ConnectionState.CONNECTING)
- return getText('networkConnecting', [name]);
- if (state == CrOnc.ConnectionState.NOT_CONNECTED)
- return getText('networkNotConnected');
- return getText(state);
-};
-
-/**
- * Returns the name to display for |network|.
- * @param {?CrOnc.NetworkStateProperties} network
- */
-function getNetworkName(network) {
- var name = network.Name;
- if (!name)
- return getText('OncType' + network.Type);
- if (network.Type == 'VPN' && network.VPN &&
- network.VPN.Type == 'ThirdPartyVPN' && network.VPN.ThirdPartyVPN) {
- var providerName = network.VPN.ThirdPartyVPN.ProviderName;
- if (providerName)
- return getText('vpnNameTemplate', [providerName, name]);
- }
- return name;
-}
-
-/**
- * Polymer class definition for 'cr-network-list-item'.
- * @element cr-network-list-item
- */
-Polymer({
- is: 'cr-network-list-item',
-
- properties: {
- /**
- * The ONC data properties used to display the list item.
- *
- * @type {?CrOnc.NetworkStateProperties}
- */
- networkState: {
- type: Object,
- value: null,
- observer: 'networkStateChanged_'
- },
-
- /**
- * Determines how the list item will be displayed:
- * 'visible' - displays the network icon (with strength) and name
- * 'known' - displays the visible info along with a toggle icon for the
- * preferred status and a remove button.
- * 'none' - The element is a stand-alone item (e.g. part of a summary)
- * and displays the name of the network type plus the network name
- * and connection state.
- */
- listItemType: {
- type: String,
- value: 'none',
- observer: 'networkStateChanged_'
- },
- },
-
- /**
- * Polymer networkState changed method. Updates the element based on the
- * network state.
- */
- networkStateChanged_: function() {
- if (!this.networkState)
- return;
-
- var network = this.networkState;
- var isDisconnected =
- network.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED;
- var name = getNetworkName(network);
- if (this.isListItem_(this.listItemType)) {
- this.$.networkName.textContent = name;
- this.$.networkName.classList.toggle('connected', !isDisconnected);
- return;
- }
- if (network.Name && network.ConnectionState) {
- this.$.networkName.textContent = getText('OncType' + network.Type);
- this.$.networkName.classList.toggle('connected', false);
- this.$.networkStateText.textContent =
- getConnectionStateText(network.ConnectionState, name);
- this.$.networkStateText.classList.toggle('connected', !isDisconnected);
- return;
- }
- this.$.networkName.textContent = getText('OncType' + network.Type);
- this.$.networkName.classList.toggle('connected', false);
- this.$.networkStateText.textContent = getText('networkDisabled');
- this.$.networkStateText.classList.toggle('connected', false);
-
- if (network.Type == CrOnc.Type.CELLULAR) {
- if (!network.GUID)
- this.$.networkStateText.textContent = getText('networkDisabled');
- }
- },
-
- /**
- * @param {?CrOnc.NetworkStateProperties} networkState
- * @return {string} The icon to use for the shared button indicator.
- * @private
- */
- sharedIcon_: function(networkState) {
- var source = (networkState && networkState.Source) || '';
- var isShared = (source == CrOnc.Source.DEVICE ||
- source == CrOnc.Source.DEVICE_POLICY);
- return isShared ? 'check' : '';
- },
-
- /**
- * @param {?CrOnc.NetworkStateProperties} networkState
- * @return {string} The icon to use for the preferred button.
- * @private
- */
- preferredIcon_: function(networkState) {
- var isPreferred = networkState && networkState.Priority > 0;
- return isPreferred ? 'star' : 'star-border';
- },
-
- /**
- * Fires a 'show-details' event with |this.networkState| as the details.
- * @param {Event} event
- * @private
- */
- fireShowDetails_: function(event) {
- this.fire('show-detail', this.networkState);
- event.stopPropagation();
- },
-
- /**
- * Fires the 'toggle-preferred' event with |this.networkState| as the details.
- * @param {Event} event
- * @private
- */
- fireTogglePreferred_: function(event) {
- this.fire('toggle-preferred', this.networkState);
- event.stopPropagation();
- },
-
- /**
- * Fires the 'remove' event with |this.networkState| as the details.
- * @param {Event} event
- * @private
- */
- fireRemove_: function(event) {
- this.fire('remove', this.networkState);
- event.stopPropagation();
- },
-
- /**
- * @param {?CrOnc.NetworkStateProperties} networkState
- * @return {boolean} True if the network is managed by a policy.
- * @private
- */
- isPolicyManaged_: function(networkState) {
- var source = (networkState && networkState.Source) || '';
- var isPolicyManaged = source == CrOnc.Source.USER_POLICY ||
- source == CrOnc.Source.DEVICE_POLICY;
- return isPolicyManaged;
- },
-
- /**
- * @param {string} listItemType The list item type.
- * @return {boolean} True if the the list item type is not 'none'.
- * @private
- */
- isListItem_: function(listItemType) {
- return listItemType != 'none';
- },
-
- /**
- * @param {string} listItemType The list item type.
- * @param {string} type The type to match against.
- * @return {boolean} True if the the list item type matches |type|.
- * @private
- */
- isListItemType_: function(listItemType, type) {
- return listItemType == type;
- },
-});
-})();

Powered by Google App Engine
This is Rietveld 408576698