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

Unified 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: make string format portable. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/gcm_internals.html ('k') | chrome/browser/services/gcm/gcm_client_mock.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/gcm_internals.js
diff --git a/chrome/browser/resources/gcm_internals.js b/chrome/browser/resources/gcm_internals.js
index be7c447d7ab205168edff8b776cb2551b890da1a..f309479eb7c29cc9716bc9aca39439c8cbaeaf00 100644
--- a/chrome/browser/resources/gcm_internals.js
+++ b/chrome/browser/resources/gcm_internals.js
@@ -2,16 +2,57 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-cr.define('gcminternals', function() {
+cr.define('gcmInternals', function() {
'use strict';
+ /**
+ * If the info dictionary has property prop, then set the text content of
+ * element to the value of this property.
+ * @param {!Object} info A dictionary of device infos to be displayed.
+ * @param {string} prop Name of the property.
+ * @param {string} element The id of a HTML element.
+ */
+ function setIfExists(info, prop, element) {
+ if (info[prop] !== undefined) {
+ $(element).textContent = info[prop];
+ }
+ }
+
+ /**
+ * Display device informations.
+ * @param {!Object} info A dictionary of device infos to be displayed.
+ */
+ function displayDeviceInfo(info) {
+ setIfExists(info, 'androidId', 'android-id');
+ setIfExists(info, 'profileServiceCreated', 'profile-service-created');
+ setIfExists(info, 'gcmEnabledState', 'gcm-enabled-state');
+ setIfExists(info, 'signedInUserName', 'signed-in-username');
+ setIfExists(info, 'gcmClientCreated', 'gcm-client-created');
+ setIfExists(info, 'gcmClientState', 'gcm-client-state');
+ setIfExists(info, 'gcmClientReady', 'gcm-client-ready');
+ setIfExists(info, 'connectionClientCreated', 'connection-client-created');
+ setIfExists(info, 'connectionState', 'connection-state');
+ }
+
function initialize() {
+ chrome.send('getGcmInternalsInfo');
+ }
+
+ /**
+ * Callback function accepting a dictionary of info items to be displayed.
+ * @param {!Object} infos A dictionary of info items to be displayed.
+ */
+ function setGcmInternalsInfo(infos) {
+ if (infos.deviceInfo !== undefined) {
+ displayDeviceInfo(infos.deviceInfo);
+ }
}
// Return an object with all of the exports.
return {
initialize: initialize,
+ setGcmInternalsInfo: setGcmInternalsInfo,
};
});
-document.addEventListener('DOMContentLoaded', gcminternals.initialize);
+document.addEventListener('DOMContentLoaded', gcmInternals.initialize);
« no previous file with comments | « chrome/browser/resources/gcm_internals.html ('k') | chrome/browser/services/gcm/gcm_client_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698