OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 function sendCommand(cmd) { | 5 function sendCommand(cmd) { |
6 window.domAutomationController.setAutomationId(1); | 6 window.domAutomationController.setAutomationId(1); |
7 window.domAutomationController.send(cmd); | 7 window.domAutomationController.send(cmd); |
8 } | 8 } |
9 | 9 |
10 function makeImageSet(url1x, url2x) { | 10 function makeImageSet(url1x, url2x) { |
11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; | 11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; |
12 } | 12 } |
13 | 13 |
14 function initialize() { | 14 function initialize() { |
15 if (loadTimeData.getBoolean('allowAccessRequests')) { | 15 if (loadTimeData.getBoolean('allowAccessRequests')) { |
16 $('request-access-button').onclick = function(event) { | 16 $('request-access-button').onclick = function(event) { |
17 $('request-access-button').hidden = true; | 17 $('request-access-button').hidden = true; |
18 sendCommand('request'); | 18 if (window.domAutomationController) { |
19 sendCommand('request'); | |
20 } else { | |
21 window.webRestrictions.requestPermission(); | |
22 } | |
19 }; | 23 }; |
20 } else { | 24 } else { |
21 $('request-access-button').hidden = true; | 25 $('request-access-button').hidden = true; |
22 } | 26 } |
23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); | 27 var avatarURL1x = loadTimeData.getString('avatarURL1x'); |
24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); | 28 var avatarURL2x = loadTimeData.getString('avatarURL2x'); |
25 var custodianName = loadTimeData.getString('custodianName'); | 29 var custodianName = loadTimeData.getString('custodianName'); |
26 if (custodianName) { | 30 if (custodianName) { |
27 $('custodians-information').hidden = false; | 31 $('custodians-information').hidden = false; |
28 if (avatarURL1x) { | 32 if (avatarURL1x) { |
(...skipping 12 matching lines...) Expand all Loading... | |
41 $('second-custodian-avatar-img').style.content = | 45 $('second-custodian-avatar-img').style.content = |
42 makeImageSet(secondAvatarURL1x, secondAvatarURL2x); | 46 makeImageSet(secondAvatarURL1x, secondAvatarURL2x); |
43 } | 47 } |
44 $('second-custodian-name').innerHTML = secondCustodianName; | 48 $('second-custodian-name').innerHTML = secondCustodianName; |
45 $('second-custodian-email').innerHTML = loadTimeData.getString( | 49 $('second-custodian-email').innerHTML = loadTimeData.getString( |
46 'secondCustodianEmail'); | 50 'secondCustodianEmail'); |
47 } | 51 } |
48 } | 52 } |
49 var showDetailsLink = loadTimeData.getString('showDetailsLink'); | 53 var showDetailsLink = loadTimeData.getString('showDetailsLink'); |
50 $('show-details-link').hidden = !showDetailsLink; | 54 $('show-details-link').hidden = !showDetailsLink; |
51 $('back-button').hidden = showDetailsLink; | 55 $('back-button').hidden = showDetailsLink; |
Bernhard Bauer
2016/04/18 14:48:34
Do we want to hide the back button in this case?
aberent
2016/05/18 20:06:50
Done.
| |
52 $('back-button').onclick = function(event) { | 56 if (window.domAutomationController) { |
53 sendCommand('back'); | 57 $('back-button').onclick = function(event) { |
54 }; | 58 sendCommand('back'); |
59 }; | |
60 } | |
55 $('show-details-link').onclick = function(event) { | 61 $('show-details-link').onclick = function(event) { |
56 $('details').hidden = false; | 62 $('details').hidden = false; |
57 $('show-details-link').hidden = true; | 63 $('show-details-link').hidden = true; |
58 $('hide-details-link').hidden = false; | 64 $('hide-details-link').hidden = false; |
59 $('information-container').classList.add('hidden-on-mobile'); | 65 $('information-container').classList.add('hidden-on-mobile'); |
60 $('request-access-button').classList.add('hidden-on-mobile'); | 66 $('request-access-button').classList.add('hidden-on-mobile'); |
61 }; | 67 }; |
62 $('hide-details-link').onclick = function(event) { | 68 $('hide-details-link').onclick = function(event) { |
63 $('details').hidden = true; | 69 $('details').hidden = true; |
64 $('show-details-link').hidden = false; | 70 $('show-details-link').hidden = false; |
65 $('hide-details-link').hidden = true; | 71 $('hide-details-link').hidden = true; |
66 $('information-container').classList.remove('hidden-on-mobile'); | 72 $('information-container').classList.remove('hidden-on-mobile'); |
67 $('request-access-button').classList.remove('hidden-on-mobile'); | 73 $('request-access-button').classList.remove('hidden-on-mobile'); |
68 }; | 74 }; |
69 if (loadTimeData.getBoolean('showFeedbackLink')) { | 75 if (window.domAutomationController && |
Bernhard Bauer
2016/04/18 14:48:34
Not sure this is necessary -- just don't set 'show
aberent
2016/05/18 20:06:49
We could do, but the code that sets 'showFeedbackL
| |
76 loadTimeData.getBoolean('showFeedbackLink')) { | |
70 $('feedback-link').onclick = function(event) { | 77 $('feedback-link').onclick = function(event) { |
71 sendCommand('feedback'); | 78 sendCommand('feedback'); |
72 }; | 79 }; |
73 } else { | 80 } else { |
74 $('feedback').hidden = true; | 81 $('feedback').hidden = true; |
75 } | 82 } |
76 } | 83 } |
77 | 84 |
78 /** | 85 /** |
79 * Updates the interstitial to show that the request failed or was sent. | 86 * Updates the interstitial to show that the request failed or was sent. |
80 * @param {boolean} isSuccessful Whether the request was successful or not. | 87 * @param {boolean} isSuccessful Whether the request was successful or not. |
81 */ | 88 */ |
82 function setRequestStatus(isSuccessful) { | 89 function setRequestStatus(isSuccessful) { |
83 $('block-page-message').hidden = true; | 90 $('block-page-message').hidden = true; |
84 if (isSuccessful) { | 91 if (isSuccessful) { |
85 $('request-failed-message').hidden = true; | 92 $('request-failed-message').hidden = true; |
86 $('request-sent-message').hidden = false; | 93 $('request-sent-message').hidden = false; |
87 $('show-details-link').hidden = true; | 94 $('show-details-link').hidden = true; |
88 $('hide-details-link').hidden = true; | 95 $('hide-details-link').hidden = true; |
89 $('details').hidden = true; | 96 $('details').hidden = true; |
90 $('back-button').hidden = false; | 97 $('back-button').hidden = false; |
91 $('request-access-button').hidden = true; | 98 $('request-access-button').hidden = true; |
92 } else { | 99 } else { |
93 $('request-failed-message').hidden = false; | 100 $('request-failed-message').hidden = false; |
94 $('request-access-button').hidden = false; | 101 $('request-access-button').hidden = false; |
95 } | 102 } |
96 } | 103 } |
97 | 104 |
98 document.addEventListener('DOMContentLoaded', initialize); | 105 document.addEventListener('DOMContentLoaded', initialize); |
OLD | NEW |