Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: chrome/browser/resources/gcm_internals.js

Issue 176823009: Show device information in chrome://gcm-internals page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 cr.define('gcminternals', function() { 5 cr.define('gcm_internals', function() {
6 'use strict'; 6 'use strict';
7 7
8 /**
9 * If the info dictionary has property prop, then set the tex 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 {HTMLElement} element An HTML element.
14 */
15 function setIfExists(info, prop, element) {
16 if (info.hasOwnProperty(prop)) {
17 $(element).textContent = info[prop];
18 }
19 }
20
21 /**
22 * Display device informations.
23 * @param {!Object} info A dictionary of device infos to be displayed.
24 */
25 function displayDeviceInfo(info) {
26 setIfExists(info, 'userProfileExists', 'profile-exists');
27 setIfExists(info, 'profileServiceCreated', 'profile-service-created');
28 setIfExists(info, 'gcmEnabledState', 'gcm-enabled-state');
29 setIfExists(info, 'userSignedIn', 'user-signed-in');
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');
35 }
36
8 function initialize() { 37 function initialize() {
38 chrome.send('getGcmInternalsInfo');
39 }
40
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.
44 */
45 function setGcmInternalsInfo(infos) {
46 if (infos.hasOwnProperty('deviceInfo')) {
47 displayDeviceInfo(infos.deviceInfo);
48 }
9 } 49 }
10 50
11 // Return an object with all of the exports. 51 // Return an object with all of the exports.
12 return { 52 return {
13 initialize: initialize, 53 initialize: initialize,
54 setGcmInternalsInfo: setGcmInternalsInfo,
14 }; 55 };
15 }); 56 });
16 57
17 document.addEventListener('DOMContentLoaded', gcminternals.initialize); 58 document.addEventListener('DOMContentLoaded', gcm_internals.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698