Fix infinite recursion on hiding panel when created during fullscreen mode.
[chromium-blink-merge.git] / chrome / browser / resources / gcm_internals.js
blobf309479eb7c29cc9716bc9aca39439c8cbaeaf00
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 cr.define('gcmInternals', function() {
6 'use strict';
8 /**
9 * If the info dictionary has property prop, then set the text content of
10 * element to the value of this property.
11 * @param {!Object} info A dictionary of device infos to be displayed.
12 * @param {string} prop Name of the property.
13 * @param {string} element The id of a HTML element.
15 function setIfExists(info, prop, element) {
16 if (info[prop] !== undefined) {
17 $(element).textContent = info[prop];
21 /**
22 * Display device informations.
23 * @param {!Object} info A dictionary of device infos to be displayed.
25 function displayDeviceInfo(info) {
26 setIfExists(info, 'androidId', 'android-id');
27 setIfExists(info, 'profileServiceCreated', 'profile-service-created');
28 setIfExists(info, 'gcmEnabledState', 'gcm-enabled-state');
29 setIfExists(info, 'signedInUserName', 'signed-in-username');
30 setIfExists(info, 'gcmClientCreated', 'gcm-client-created');
31 setIfExists(info, 'gcmClientState', 'gcm-client-state');
32 setIfExists(info, 'gcmClientReady', 'gcm-client-ready');
33 setIfExists(info, 'connectionClientCreated', 'connection-client-created');
34 setIfExists(info, 'connectionState', 'connection-state');
37 function initialize() {
38 chrome.send('getGcmInternalsInfo');
41 /**
42 * Callback function accepting a dictionary of info items to be displayed.
43 * @param {!Object} infos A dictionary of info items to be displayed.
45 function setGcmInternalsInfo(infos) {
46 if (infos.deviceInfo !== undefined) {
47 displayDeviceInfo(infos.deviceInfo);
51 // Return an object with all of the exports.
52 return {
53 initialize: initialize,
54 setGcmInternalsInfo: setGcmInternalsInfo,
56 });
58 document.addEventListener('DOMContentLoaded', gcmInternals.initialize);