OLD | NEW |
| (Empty) |
1 // Copyright 2014 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 function sendCommand(cmd) { | |
6 window.domAutomationController.setAutomationId(1); | |
7 window.domAutomationController.send(cmd); | |
8 } | |
9 | |
10 function makeImageSet(url1x, url2x) { | |
11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; | |
12 } | |
13 | |
14 function initialize() { | |
15 if (loadTimeData.getBoolean('allowAccessRequests')) { | |
16 $('request-access-button').onclick = function(event) { | |
17 $('request-access-button').hidden = true; | |
18 sendCommand('request'); | |
19 }; | |
20 } else { | |
21 $('request-access-button').hidden = true; | |
22 } | |
23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); | |
24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); | |
25 var custodianName = loadTimeData.getString('custodianName'); | |
26 if (custodianName) { | |
27 $('custodians-information').hidden = false; | |
28 if (avatarURL1x) { | |
29 $('custodian-avatar-img').style.content = | |
30 makeImageSet(avatarURL1x, avatarURL2x); | |
31 } | |
32 $('custodian-name').innerHTML = custodianName; | |
33 $('custodian-email').innerHTML = loadTimeData.getString('custodianEmail'); | |
34 var secondAvatarURL1x = loadTimeData.getString('secondAvatarURL1x'); | |
35 var secondAvatarURL2x = loadTimeData.getString('secondAvatarURL2x'); | |
36 var secondCustodianName = loadTimeData.getString('secondCustodianName'); | |
37 if (secondCustodianName) { | |
38 $('second-custodian-information').hidden = false; | |
39 $('second-custodian-avatar-img').hidden = false; | |
40 if (secondAvatarURL1x) { | |
41 $('second-custodian-avatar-img').style.content = | |
42 makeImageSet(secondAvatarURL1x, secondAvatarURL2x); | |
43 } | |
44 $('second-custodian-name').innerHTML = secondCustodianName; | |
45 $('second-custodian-email').innerHTML = loadTimeData.getString( | |
46 'secondCustodianEmail'); | |
47 } | |
48 } | |
49 var showDetailsLink = loadTimeData.getString('showDetailsLink'); | |
50 $('show-details-link').hidden = !showDetailsLink; | |
51 $('back-button').hidden = showDetailsLink; | |
52 $('back-button').onclick = function(event) { | |
53 sendCommand('back'); | |
54 }; | |
55 $('show-details-link').onclick = function(event) { | |
56 $('details').hidden = false; | |
57 $('show-details-link').hidden = true; | |
58 $('hide-details-link').hidden = false; | |
59 $('information-container').classList.add('hidden-on-mobile'); | |
60 $('request-access-button').classList.add('hidden-on-mobile'); | |
61 }; | |
62 $('hide-details-link').onclick = function(event) { | |
63 $('details').hidden = true; | |
64 $('show-details-link').hidden = false; | |
65 $('hide-details-link').hidden = true; | |
66 $('information-container').classList.remove('hidden-on-mobile'); | |
67 $('request-access-button').classList.remove('hidden-on-mobile'); | |
68 }; | |
69 if (loadTimeData.getBoolean('showFeedbackLink')) { | |
70 $('feedback-link').onclick = function(event) { | |
71 sendCommand('feedback'); | |
72 }; | |
73 } else { | |
74 $('feedback').hidden = true; | |
75 } | |
76 } | |
77 | |
78 /** | |
79 * Updates the interstitial to show that the request failed or was sent. | |
80 * @param {boolean} isSuccessful Whether the request was successful or not. | |
81 */ | |
82 function setRequestStatus(isSuccessful) { | |
83 $('block-page-message').hidden = true; | |
84 if (isSuccessful) { | |
85 $('request-failed-message').hidden = true; | |
86 $('request-sent-message').hidden = false; | |
87 $('show-details-link').hidden = true; | |
88 $('hide-details-link').hidden = true; | |
89 $('details').hidden = true; | |
90 $('back-button').hidden = false; | |
91 $('request-access-button').hidden = true; | |
92 } else { | |
93 $('request-failed-message').hidden = false; | |
94 $('request-access-button').hidden = false; | |
95 } | |
96 } | |
97 | |
98 document.addEventListener('DOMContentLoaded', initialize); | |
OLD | NEW |