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

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_summary_item.js

Issue 2684193005: MD Settings: Internet: Request network scan (Closed)
Patch Set: . Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Polymer element for displaying the network state for a specific 6 * @fileoverview Polymer element for displaying the network state for a specific
7 * type and a list of networks for that type. 7 * type and a list of networks for that type.
8 */ 8 */
9 9
10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */ 10 /** @typedef {chrome.networkingPrivate.DeviceStateProperties} */
(...skipping 25 matching lines...) Expand all
36 * @type {!Array<!CrOnc.NetworkStateProperties>} 36 * @type {!Array<!CrOnc.NetworkStateProperties>}
37 */ 37 */
38 networkStateList: { 38 networkStateList: {
39 type: Array, 39 type: Array,
40 value: function() { 40 value: function() {
41 return []; 41 return [];
42 }, 42 },
43 }, 43 },
44 44
45 /** 45 /**
46 * Type of networks in networkStateList. Used to initialte scanning.
47 * @type {CrOnc.Type}
48 */
49 networkType: String,
50
51 /**
46 * Interface for networkingPrivate calls, passed from internet_page. 52 * Interface for networkingPrivate calls, passed from internet_page.
47 * @type {!NetworkingPrivate} 53 * @type {!NetworkingPrivate}
48 */ 54 */
49 networkingPrivate: Object, 55 networkingPrivate: Object,
50 56
51 /** 57 /**
52 * The expanded state of the list of networks. 58 * The expanded state of the list of networks.
53 * @private 59 * @private
54 */ 60 */
55 expanded_: { 61 expanded_: {
56 type: Boolean, 62 type: Boolean,
57 value: false, 63 value: false,
58 observer: 'expandedChanged_', 64 observer: 'expandedChanged_',
59 }, 65 },
60 66
61 /** 67 /**
62 * Whether the list has been expanded. This is used to ensure the 68 * Whether the list has been expanded. This is used to ensure the
63 * iron-collapse section animates correctly. 69 * iron-collapse section animates correctly.
64 * @private 70 * @private
65 */ 71 */
66 wasExpanded_: { 72 wasExpanded_: {
67 type: Boolean, 73 type: Boolean,
68 value: false, 74 value: false,
69 }, 75 },
70 }, 76 },
71 77
78 observers: ['updateScanning_(networkingPrivate, networkType, expanded_)'],
79
80 /** @private {number|null} */
81 scanIntervalId_: null,
82
83 /** override */
84 detached: function() {
85 if (this.scanIntervalId_ !== null) {
86 window.clearInterval(this.scanIntervalId_);
87 this.scanIntervalId_ = null;
88 }
89 },
90
72 /** @private */ 91 /** @private */
73 expandedChanged_: function() { 92 expandedChanged_: function() {
74 var type = this.deviceState ? this.deviceState.Type : ''; 93 var type = this.deviceState ? this.deviceState.Type : '';
75 this.fire('expanded', {expanded: this.expanded_, type: type}); 94 this.fire('expanded', {expanded: this.expanded_, type: type});
76 }, 95 },
77 96
78 /** @private */ 97 /** @private */
79 deviceStateChanged_: function() { 98 deviceStateChanged_: function() {
80 if (this.expanded_ && !this.deviceIsEnabled_(this.deviceState)) 99 if (this.expanded_ && !this.deviceIsEnabled_(this.deviceState))
81 this.expanded_ = false; 100 this.expanded_ = false;
82 }, 101 },
83 102
103 /** @private */
104 updateScanning_: function() {
105 if (this.scanIntervalId_ != null) {
106 if (!this.expanded_) {
107 window.clearInterval(this.scanIntervalId_);
108 this.scanIntervalId_ = null;
109 }
110 return;
111 }
112 if (!this.expanded_ ||
113 (this.networkType != CrOnc.Type.ALL &&
114 this.networkType != CrOnc.Type.WI_FI)) {
115 return;
116 }
117 /** @const */ var INTERVAL_MS = 10 * 1000;
118 this.networkingPrivate.requestNetworkScan();
119 this.scanIntervalId_ = window.setInterval(function() {
120 this.networkingPrivate.requestNetworkScan();
121 }.bind(this), INTERVAL_MS);
122 },
123
84 /** 124 /**
85 * @return {boolean} Whether or not the scanning spinner should be visible. 125 * @return {boolean} Whether or not the scanning spinner should be visible.
86 * @private 126 * @private
87 */ 127 */
88 scanningIsVisible_: function() { 128 scanningIsVisible_: function() {
89 return this.deviceState.Type == CrOnc.Type.WI_FI; 129 return this.deviceState.Type == CrOnc.Type.WI_FI;
90 }, 130 },
91 131
92 /** 132 /**
93 * @return {boolean} Whether or not the scanning spinner should be active. 133 * @return {boolean} Whether or not the scanning spinner should be active.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 */ 312 */
273 onDeviceEnabledTap_: function(event) { 313 onDeviceEnabledTap_: function(event) {
274 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState); 314 var deviceIsEnabled = this.deviceIsEnabled_(this.deviceState);
275 var type = this.deviceState ? this.deviceState.Type : ''; 315 var type = this.deviceState ? this.deviceState.Type : '';
276 this.fire( 316 this.fire(
277 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type}); 317 'device-enabled-toggled', {enabled: !deviceIsEnabled, type: type});
278 // Make sure this does not propagate to onDetailsTap_. 318 // Make sure this does not propagate to onDetailsTap_.
279 event.stopPropagation(); 319 event.stopPropagation();
280 }, 320 },
281 }); 321 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698