OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 'supervised-user-create-confirm' is a page that is displayed | 6 * @fileoverview 'supervised-user-create-confirm' is a page that is displayed |
7 * upon successful creation of a supervised user. It contains information for | 7 * upon successful creation of a supervised user. It contains information for |
8 * the custodian on where to configure browsing restrictions as well as how to | 8 * the custodian on where to configure browsing restrictions as well as how to |
9 * exit and childlock their profile. | 9 * exit and childlock their profile. |
10 */ | 10 */ |
11 (function() { | 11 (function() { |
12 /** | 12 /** |
13 * Maximum length of the supervised user profile name or custodian's username. | 13 * Maximum length of the supervised user profile name or custodian's username. |
14 * @const {number} | 14 * @const {number} |
15 */ | 15 */ |
16 var MAX_NAME_LENGTH = 50; | 16 var MAX_NAME_LENGTH = 50; |
17 | 17 |
18 Polymer({ | 18 Polymer({ |
19 is: 'supervised-user-create-confirm', | 19 is: 'supervised-user-create-confirm', |
20 | 20 |
21 behaviors: [ | 21 behaviors: [I18nBehavior], |
22 I18nBehavior | |
23 ], | |
24 | 22 |
25 properties: { | 23 properties: { |
26 /** | 24 /** |
27 * Profile Info of the supervised user that is passed to the page. | 25 * Profile Info of the supervised user that is passed to the page. |
28 * @type {?ProfileInfo} | 26 * @type {?ProfileInfo} |
29 */ | 27 */ |
30 profileInfo: { | 28 profileInfo: { |
31 type: Object, | 29 type: Object, |
32 value: function() { return null; } | 30 value: function() { |
| 31 return null; |
| 32 } |
| 33 }, |
| 34 |
| 35 /** @private {!signin.ProfileBrowserProxy} */ |
| 36 browserProxy_: Object |
33 }, | 37 }, |
34 | 38 |
35 /** @private {!signin.ProfileBrowserProxy} */ | 39 listeners: {'tap': 'onTap_'}, |
36 browserProxy_: Object | |
37 }, | |
38 | 40 |
39 listeners: { | 41 /** @override */ |
40 'tap': 'onTap_' | 42 created: function() { |
41 }, | 43 this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance(); |
| 44 }, |
42 | 45 |
43 /** @override */ | 46 /** |
44 created: function() { | 47 * Handles tap events from dynamically created links in the |
45 this.browserProxy_ = signin.ProfileBrowserProxyImpl.getInstance(); | 48 * supervisedUserCreatedText i18n string. |
46 }, | 49 * @param {!Event} event |
| 50 * @private |
| 51 */ |
| 52 onTap_: function(event) { |
| 53 var element = Polymer.dom(event).rootTarget; |
47 | 54 |
48 /** | 55 // Handle the tap event only if the target is a '<a>' element. |
49 * Handles tap events from dynamically created links in the | 56 if (element.nodeName == 'A') { |
50 * supervisedUserCreatedText i18n string. | 57 this.browserProxy_.openUrlInLastActiveProfileBrowser(element.href); |
51 * @param {!Event} event | 58 event.preventDefault(); |
52 * @private | 59 } |
53 */ | 60 }, |
54 onTap_: function(event) { | |
55 var element = Polymer.dom(event).rootTarget; | |
56 | 61 |
57 // Handle the tap event only if the target is a '<a>' element. | 62 /** |
58 if (element.nodeName == 'A') { | |
59 this.browserProxy_.openUrlInLastActiveProfileBrowser(element.href); | |
60 event.preventDefault(); | |
61 } | |
62 }, | |
63 | |
64 /** | |
65 * Returns the shortened profile name or empty string if |profileInfo| is | 63 * Returns the shortened profile name or empty string if |profileInfo| is |
66 * null. | 64 * null. |
67 * @param {?ProfileInfo} profileInfo | 65 * @param {?ProfileInfo} profileInfo |
68 * @return {string} | 66 * @return {string} |
69 * @private | 67 * @private |
70 */ | 68 */ |
71 elideProfileName_: function(profileInfo) { | 69 elideProfileName_: function(profileInfo) { |
72 var name = profileInfo ? profileInfo.name : ''; | 70 var name = profileInfo ? profileInfo.name : ''; |
73 return elide(name, MAX_NAME_LENGTH); | 71 return elide(name, MAX_NAME_LENGTH); |
74 }, | 72 }, |
75 | 73 |
76 /** | 74 /** |
77 * Returns the shortened custodian username or empty string if |profileInfo| | 75 * Returns the shortened custodian username or empty string if |profileInfo| |
78 * is null. | 76 * is null. |
79 * @param {?ProfileInfo} profileInfo | 77 * @param {?ProfileInfo} profileInfo |
80 * @return {string} | 78 * @return {string} |
81 * @private | 79 * @private |
82 */ | 80 */ |
83 elideCustodianUsername_: function(profileInfo) { | 81 elideCustodianUsername_: function(profileInfo) { |
84 var name = profileInfo ? profileInfo.custodianUsername : ''; | 82 var name = profileInfo ? profileInfo.custodianUsername : ''; |
85 return elide(name, MAX_NAME_LENGTH); | 83 return elide(name, MAX_NAME_LENGTH); |
86 }, | 84 }, |
87 | 85 |
88 /** | 86 /** |
89 * Computed binding returning the text of the title section. | 87 * Computed binding returning the text of the title section. |
90 * @param {?ProfileInfo} profileInfo | 88 * @param {?ProfileInfo} profileInfo |
91 * @return {string} | 89 * @return {string} |
92 * @private | 90 * @private |
93 */ | 91 */ |
94 titleText_: function(profileInfo) { | 92 titleText_: function(profileInfo) { |
95 return this.i18n('supervisedUserCreatedTitle', | 93 return this.i18n( |
96 this.elideProfileName_(profileInfo)); | 94 'supervisedUserCreatedTitle', this.elideProfileName_(profileInfo)); |
97 }, | 95 }, |
98 | 96 |
99 /** | 97 /** |
100 * Computed binding returning the sanitized confirmation HTML message that is | 98 * Computed binding returning the sanitized confirmation HTML message that is |
101 * safe to set as innerHTML. | 99 * safe to set as innerHTML. |
102 * @param {?ProfileInfo} profileInfo | 100 * @param {?ProfileInfo} profileInfo |
103 * @return {string} | 101 * @return {string} |
104 * @private | 102 * @private |
105 */ | 103 */ |
106 confirmationMessage_: function(profileInfo) { | 104 confirmationMessage_: function(profileInfo) { |
107 return this.i18n('supervisedUserCreatedText', | 105 return this.i18n( |
108 this.elideProfileName_(profileInfo), | 106 'supervisedUserCreatedText', this.elideProfileName_(profileInfo), |
109 this.elideCustodianUsername_(profileInfo)); | 107 this.elideCustodianUsername_(profileInfo)); |
110 }, | 108 }, |
111 | 109 |
112 /** | 110 /** |
113 * Computed binding returning the text of the 'Switch To User' button. | 111 * Computed binding returning the text of the 'Switch To User' button. |
114 * @param {?ProfileInfo} profileInfo | 112 * @param {?ProfileInfo} profileInfo |
115 * @return {string} | 113 * @return {string} |
116 * @private | 114 * @private |
117 */ | 115 */ |
118 switchUserText_: function(profileInfo) { | 116 switchUserText_: function(profileInfo) { |
119 return this.i18n('supervisedUserCreatedSwitch', | 117 return this.i18n( |
120 this.elideProfileName_(profileInfo)); | 118 'supervisedUserCreatedSwitch', this.elideProfileName_(profileInfo)); |
121 }, | 119 }, |
122 | 120 |
123 /** | 121 /** |
124 * Handler for the 'Ok' button tap event. | 122 * Handler for the 'Ok' button tap event. |
125 * @param {!Event} event | 123 * @param {!Event} event |
126 * @private | 124 * @private |
127 */ | 125 */ |
128 onOkTap_: function(event) { | 126 onOkTap_: function(event) { |
129 // Event is caught by user-manager-pages. | 127 // Event is caught by user-manager-pages. |
130 this.fire('change-page', {page: 'user-pods-page'}); | 128 this.fire('change-page', {page: 'user-pods-page'}); |
131 }, | 129 }, |
132 | 130 |
133 /** | 131 /** |
134 * Handler for the 'Switch To User' button tap event. | 132 * Handler for the 'Switch To User' button tap event. |
135 * @param {!Event} event | 133 * @param {!Event} event |
136 * @private | 134 * @private |
137 */ | 135 */ |
138 onSwitchUserTap_: function(event) { | 136 onSwitchUserTap_: function(event) { |
139 this.browserProxy_.switchToProfile(this.profileInfo.filePath); | 137 this.browserProxy_.switchToProfile(this.profileInfo.filePath); |
140 // Event is caught by user-manager-pages. | 138 // Event is caught by user-manager-pages. |
141 this.fire('change-page', {page: 'user-pods-page'}); | 139 this.fire('change-page', {page: 'user-pods-page'}); |
142 } | 140 } |
143 }); | 141 }); |
144 })(); | 142 })(); |
OLD | NEW |