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.
5 function sendCommand(cmd) {
6 window.domAutomationController.setAutomationId(1);
7 window.domAutomationController.send(cmd);
10 function makeImageSet(url1x, url2x) {
11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)';
14 function initialize() {
15 if (loadTimeData.getBoolean('allowAccessRequests')) {
16 $('request-access-button').onclick = function(event) {
17 $('request-access-button').hidden = true;
18 sendCommand('request');
21 $('request-access-button').hidden = true;
23 var avatarURL1x = loadTimeData.getString('avatarURL1x');
24 var avatarURL2x = loadTimeData.getString('avatarURL2x');
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 = '6px';
37 $('avatar-img').style.zIndex = '1';
38 $('second-avatar-img').style.left = '-6px';
41 $('back-button').onclick = function(event) {
44 if (loadTimeData.getBoolean('showFeedbackLink')) {
45 $('feedback-link').onclick = function(event) {
46 sendCommand('feedback');
49 $('feedback-link').style.display = 'none';
54 * Updates the interstitial to show that the request failed or was sent.
55 * @param {boolean} isSuccessful Whether the request was successful or not.
57 function setRequestStatus(isSuccessful) {
58 $('error-img').hidden = true;
59 $('block-page-message').hidden = true;
61 $('request-failed-message').hidden = true;
62 $('request-sent-message').hidden = false;
63 if ($('avatar-img').hidden) {
64 $('request-sent-message').style.marginTop = '40px';
67 $('request-failed-message').hidden = false;
68 $('request-access-button').hidden = false;
72 document.addEventListener('DOMContentLoaded', initialize);