| 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 updateAfterRequestSent(); | 17 $('request-access-button').hidden = true; |
| 18 sendCommand('request'); | 18 sendCommand('request'); |
| 19 }; | 19 }; |
| 20 } else { | 20 } else { |
| 21 $('request-access-button').hidden = true; | 21 $('request-access-button').hidden = true; |
| 22 } | 22 } |
| 23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); | 23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); |
| 24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); | 24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); |
| 25 if (avatarURL1x) { | 25 if (avatarURL1x) { |
| 26 $('avatar-img').style.content = makeImageSet(avatarURL1x, avatarURL2x); | 26 $('avatar-img').style.content = makeImageSet(avatarURL1x, avatarURL2x); |
| 27 $('avatar-img').hidden = false; | 27 $('avatar-img').hidden = false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 44 if (loadTimeData.getBoolean('showFeedbackLink')) { | 44 if (loadTimeData.getBoolean('showFeedbackLink')) { |
| 45 $('feedback-link').onclick = function(event) { | 45 $('feedback-link').onclick = function(event) { |
| 46 sendCommand('feedback'); | 46 sendCommand('feedback'); |
| 47 }; | 47 }; |
| 48 } else { | 48 } else { |
| 49 $('feedback-link').style.display = 'none'; | 49 $('feedback-link').style.display = 'none'; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Updates the interstitial to show that the request was sent. | 54 * Updates the interstitial to show that the request failed or was sent. |
| 55 * @param {boolean} isSuccessful Whether the request was successful or not. |
| 55 */ | 56 */ |
| 56 function updateAfterRequestSent() { | 57 function setRequestStatus(isSuccessful) { |
| 57 $('error-img').hidden = true; | 58 $('error-img').hidden = true; |
| 58 $('request-access-button').hidden = true; | |
| 59 $('block-page-message').hidden = true; | 59 $('block-page-message').hidden = true; |
| 60 $('request-sent-message').hidden = false; | 60 if (isSuccessful) { |
| 61 if ($('avatar-img').hidden) { | 61 $('request-failed-message').hidden = true; |
| 62 $('request-sent-message').style.marginTop = '40px'; | 62 $('request-sent-message').hidden = false; |
| 63 if ($('avatar-img').hidden) { |
| 64 $('request-sent-message').style.marginTop = '40px'; |
| 65 } |
| 66 } else { |
| 67 $('request-failed-message').hidden = false; |
| 68 $('request-access-button').hidden = false; |
| 63 } | 69 } |
| 64 } | 70 } |
| 65 | 71 |
| 66 document.addEventListener('DOMContentLoaded', initialize); | 72 document.addEventListener('DOMContentLoaded', initialize); |
| OLD | NEW |