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(setRequestStatus); |
| 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 || !window.domAutomationController; |
52 $('back-button').onclick = function(event) { | 56 $('back-button').onclick = function(event) { |
53 sendCommand('back'); | 57 sendCommand('back'); |
54 }; | 58 }; |
55 $('show-details-link').onclick = function(event) { | 59 $('show-details-link').onclick = function(event) { |
56 $('details').hidden = false; | 60 $('details').hidden = false; |
57 $('show-details-link').hidden = true; | 61 $('show-details-link').hidden = true; |
58 $('hide-details-link').hidden = false; | 62 $('hide-details-link').hidden = false; |
59 $('information-container').classList.add('hidden-on-mobile'); | 63 $('information-container').classList.add('hidden-on-mobile'); |
60 $('request-access-button').classList.add('hidden-on-mobile'); | 64 $('request-access-button').classList.add('hidden-on-mobile'); |
61 }; | 65 }; |
62 $('hide-details-link').onclick = function(event) { | 66 $('hide-details-link').onclick = function(event) { |
63 $('details').hidden = true; | 67 $('details').hidden = true; |
64 $('show-details-link').hidden = false; | 68 $('show-details-link').hidden = false; |
65 $('hide-details-link').hidden = true; | 69 $('hide-details-link').hidden = true; |
66 $('information-container').classList.remove('hidden-on-mobile'); | 70 $('information-container').classList.remove('hidden-on-mobile'); |
67 $('request-access-button').classList.remove('hidden-on-mobile'); | 71 $('request-access-button').classList.remove('hidden-on-mobile'); |
68 }; | 72 }; |
69 if (loadTimeData.getBoolean('showFeedbackLink')) { | 73 if (window.domAutomationController && |
| 74 loadTimeData.getBoolean('showFeedbackLink')) { |
70 $('feedback-link').onclick = function(event) { | 75 $('feedback-link').onclick = function(event) { |
71 sendCommand('feedback'); | 76 sendCommand('feedback'); |
72 }; | 77 }; |
73 } else { | 78 } else { |
74 $('feedback').hidden = true; | 79 $('feedback').hidden = true; |
75 } | 80 } |
76 } | 81 } |
77 | 82 |
78 /** | 83 /** |
79 * Updates the interstitial to show that the request failed or was sent. | 84 * Updates the interstitial to show that the request failed or was sent. |
80 * @param {boolean} isSuccessful Whether the request was successful or not. | 85 * @param {boolean} isSuccessful Whether the request was successful or not. |
81 */ | 86 */ |
82 function setRequestStatus(isSuccessful) { | 87 function setRequestStatus(isSuccessful) { |
| 88 console.log('setRequestStatus(' + isSuccessful +')'); |
83 $('block-page-message').hidden = true; | 89 $('block-page-message').hidden = true; |
84 if (isSuccessful) { | 90 if (isSuccessful) { |
85 $('request-failed-message').hidden = true; | 91 $('request-failed-message').hidden = true; |
86 $('request-sent-message').hidden = false; | 92 $('request-sent-message').hidden = false; |
87 $('show-details-link').hidden = true; | 93 $('show-details-link').hidden = true; |
88 $('hide-details-link').hidden = true; | 94 $('hide-details-link').hidden = true; |
89 $('details').hidden = true; | 95 $('details').hidden = true; |
90 $('back-button').hidden = false; | 96 $('back-button').hidden = !window.domAutomationController; |
91 $('request-access-button').hidden = true; | 97 $('request-access-button').hidden = true; |
92 } else { | 98 } else { |
93 $('request-failed-message').hidden = false; | 99 $('request-failed-message').hidden = false; |
94 $('request-access-button').hidden = false; | 100 $('request-access-button').hidden = false; |
95 } | 101 } |
96 } | 102 } |
97 | 103 |
98 document.addEventListener('DOMContentLoaded', initialize); | 104 document.addEventListener('DOMContentLoaded', initialize); |
OLD | NEW |