1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
// Copyright (c) 2011 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.define('options.internet', function() {
var OptionsPage = options.OptionsPage;
/*
* Helper function to set hidden attribute on given element list.
* @param {Array} elements List of elements to be updated.
* @param {bool} hidden New hidden value.
*/
function updateHidden(elements, hidden) {
for (var i = 0, el; el = elements[i]; i++) {
el.hidden = hidden;
}
}
/////////////////////////////////////////////////////////////////////////////
// DetailsInternetPage class:
/**
* Encapsulated handling of ChromeOS internet details overlay page.
* @constructor
*/
function DetailsInternetPage() {
OptionsPage.call(this, 'detailsInternetPage', null, 'detailsInternetPage');
}
cr.addSingletonGetter(DetailsInternetPage);
DetailsInternetPage.prototype = {
__proto__: OptionsPage.prototype,
/**
* Initializes DetailsInternetPage page.
* Calls base class implementation to starts preference initialization.
*/
initializePage: function() {
OptionsPage.prototype.initializePage.call(this);
},
/**
* Update details page controls.
* @private
*/
updateControls_: function() {
// Only show ipconfig section if network is connected OR if nothing on
// this device is connected. This is so that you can fix the ip configs
// if you can't connect to any network.
// TODO(chocobo): Once ipconfig is moved to flimflam service objects,
// we need to redo this logic to allow configuration of all networks.
$('ipconfigSection').hidden = !this.connected && this.deviceConnected;
// Network type related.
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .cellular-details'),
!this.cellular);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .wifi-details'),
!this.wireless);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .vpn-details'),
!this.vpn);
// Cell plan related.
$('planList').hidden = this.cellplanloading;
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .no-plan-info'),
!this.cellular || this.cellplanloading || this.hascellplan);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .plan-loading-info'),
!this.cellular || this.nocellplan || this.hascellplan);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .plan-details-info'),
!this.cellular || this.nocellplan || this.cellplanloading);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .gsm-only'),
!this.cellular || !this.gsm);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .cdma-only'),
!this.cellular || this.gsm);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .apn-list-view'),
!this.cellular || !this.gsm);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .apn-details-view'),
true);
// Password and shared.
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .password-details'),
!this.wireless || !this.password);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .shared-network'),
!this.shared);
updateHidden(
cr.doc.querySelectorAll('#detailsInternetPage .prefer-network'),
!this.showPreferred);
}
};
/**
* Whether the underlying network is connected. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'connected',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the underlying network is wifi. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'wireless',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the underlying network shared wifi. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'shared',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the underlying network is a vpn. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'vpn',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the underlying network is ethernet. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'ethernet',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the underlying network is cellular. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'cellular',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the network is loading cell plan. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'cellplanloading',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the network has cell plan(s). Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'hascellplan',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the network has no cell plan. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'nocellplan',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether the network is gsm. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'gsm',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
/**
* Whether show password details for network. Only used for display purpose.
* @type {boolean}
*/
cr.defineProperty(DetailsInternetPage, 'password',
cr.PropertyKind.JS,
DetailsInternetPage.prototype.updateControls_);
// TODO(xiyuan): Check to see if it is safe to remove these attributes.
cr.defineProperty(DetailsInternetPage, 'hasactiveplan',
cr.PropertyKind.JS);
cr.defineProperty(DetailsInternetPage, 'activated',
cr.PropertyKind.JS);
cr.defineProperty(DetailsInternetPage, 'connecting',
cr.PropertyKind.JS);
cr.defineProperty(DetailsInternetPage, 'connected',
cr.PropertyKind.JS);
return {
DetailsInternetPage: DetailsInternetPage
};
});
|