| 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) { |
| 11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; |
| 12 } |
| 13 |
| 10 function initialize() { | 14 function initialize() { |
| 11 if (loadTimeData.getBoolean('allowAccessRequests')) { | 15 if (loadTimeData.getBoolean('allowAccessRequests')) { |
| 12 $('request-access-button').onclick = function(event) { | 16 $('request-access-button').onclick = function(event) { |
| 13 updateAfterRequestSent(); | 17 updateAfterRequestSent(); |
| 14 sendCommand('request'); | 18 sendCommand('request'); |
| 15 }; | 19 }; |
| 16 } else { | 20 } else { |
| 17 $('request-access-button').hidden = true; | 21 $('request-access-button').hidden = true; |
| 18 } | 22 } |
| 23 var avatarURL1x = loadTimeData.getString('avatarURL1x'); |
| 24 var avatarURL2x = loadTimeData.getString('avatarURL2x'); |
| 25 if (avatarURL1x) { |
| 26 $('avatar-img').style.content = makeImageSet(avatarURL1x, avatarURL2x); |
| 27 $('avatar-img').hidden = false; |
| 28 $('error-img').hidden = true; |
| 29 var secondAvatarURL1x = loadTimeData.getString('secondAvatarURL1x'); |
| 30 var secondAvatarURL2x = loadTimeData.getString('secondAvatarURL2x'); |
| 31 if (secondAvatarURL1x) { |
| 32 $('second-avatar-img').style.content = |
| 33 makeImageSet(secondAvatarURL1x, secondAvatarURL2x); |
| 34 $('second-avatar-img').hidden = false; |
| 35 // The avatar images should overlap a bit. |
| 36 $('avatar-img').style.left = '10px'; |
| 37 $('avatar-img').style.zIndex = '1'; |
| 38 $('second-avatar-img').style.left = '-10px'; |
| 39 } |
| 40 } |
| 19 $('back-button').onclick = function(event) { | 41 $('back-button').onclick = function(event) { |
| 20 sendCommand('back'); | 42 sendCommand('back'); |
| 21 }; | 43 }; |
| 22 } | 44 } |
| 23 | 45 |
| 24 /** | 46 /** |
| 25 * Updates the interstitial to show that the request was sent. | 47 * Updates the interstitial to show that the request was sent. |
| 26 */ | 48 */ |
| 27 function updateAfterRequestSent() { | 49 function updateAfterRequestSent() { |
| 28 $('error-img').hidden = true; | 50 $('error-img').hidden = true; |
| 29 $('request-access-button').hidden = true; | 51 $('request-access-button').hidden = true; |
| 30 $('block-page-message').hidden = true; | 52 $('block-page-message').hidden = true; |
| 31 $('request-sent-message').hidden = false; | 53 $('request-sent-message').hidden = false; |
| 54 if ($('avatar-img').hidden) { |
| 55 $('request-sent-message').style.marginTop = '40px'; |
| 56 } |
| 32 } | 57 } |
| 33 | 58 |
| 34 document.addEventListener('DOMContentLoaded', initialize); | 59 document.addEventListener('DOMContentLoaded', initialize); |
| OLD | NEW |