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

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

Issue 2755173002: [CrOS Tether] Add a connection dialog to md-settings. (Closed)
Patch Set: Add comments. Created 3 years, 9 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @typedef {{
7 * tetherNostDeviceName: string,
8 * batteryPercentage: number,
9 * connectionStrength: number,
10 * isTetherHostCurrentlyOnWifi: boolean
11 * }}
12 */
13 var TetherConnectionData;
14
15 Polymer({
16 is: 'tether-connection-dialog',
17
18 behaviors: [
19 I18nBehavior,
20 CrScrollableBehavior,
stevenjb 2017/03/17 20:43:54 You shouldn't need this behavior?
Kyle Horimoto 2017/03/17 20:48:38 Done.
21 ],
22
23 properties: {
24 /**
25 * The data used to display the tether connection dialog.
26 * @private {!TetherConnectionData|undefined}
27 */
28 tetherData_: {
29 type: Object,
30 // TODO(khorimoto): Remove this and use real data when available.
31 value: {
32 tetherNostDeviceName: 'Pixel XL',
33 batteryPercentage: 100,
34 connectionStrength: 4,
35 isTetherHostCurrentlyOnWifi: false
36 },
37 },
38 },
39
40 open: function() {
41 this.getDialog_().showModal();
Dan Beam 2017/03/17 21:50:05 note: showModal throws if the dialog is already op
Kyle Horimoto 2017/03/17 22:06:38 Done.
42 },
43
44 close: function() {
45 var dialog = this.getDialog_();
46 if (dialog.open)
47 dialog.close();
48 },
49
50 /** @override */
51 ready: function() {
52 this.open();
53 },
54
55 /**
56 * @return {!CrDialogElement}
57 * @private
58 */
59 getDialog_: function() {
60 return /** @type {!CrDialogElement} */ (this.$.dialog);
61 },
62
63 /** @private */
64 onNotNowTap_: function() {
65 this.getDialog_().cancel();
66 },
67
68 /**
69 * @param {!TetherConnectionData|undefined} tetherData
70 * @return {string}
71 * @private
72 */
73 getReceptionIcon_: function(tetherData) {
74 var connectionStrength;
75
76 if (!tetherData || !tetherData.connectionStrength) {
77 connectionStrength = 0;
78 } else {
79 // Ensure that 0 <= connectionStrength <= 4, since these values are the
80 // limits of the cellular strength icons.
81 connectionStrength =
82 Math.min(Math.max(tetherData.connectionStrength, 0), 4);
83 }
84
85 return 'device:signal-cellular-' + connectionStrength + '-bar';
86 }
87 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698