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

Unified Diff: chrome/browser/resources/chat_manager/js/gmailbridgehook.js

Issue 3455024: Notify all rosters on opening and closing chats,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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
Index: chrome/browser/resources/chat_manager/js/gmailbridgehook.js
===================================================================
--- chrome/browser/resources/chat_manager/js/gmailbridgehook.js (revision 59993)
+++ chrome/browser/resources/chat_manager/js/gmailbridgehook.js (working copy)
@@ -25,15 +25,22 @@
}
/**
+ * @param {string} eventType the event type.
+ * @param {string} chatJid the jid to route the chat event to.
+ * TODO(seh): Move into a common JS file and reference from chatbridgehook.js.
+ */
+function dispatchChatEvent(eventType, chatJid) {
+ var chatEvent = document.createEvent('MessageEvent');
+ chatEvent.initMessageEvent(eventType, true, true, chatJid);
+ divGmailHandler.dispatchEvent(chatEvent);
+}
+
+/**
* Forward central roster Jid to page.
* @param {string} jid the central roster Jid.
*/
function dispatchCentralJid(jid) {
- var outgoingChatEvent = document.createEvent('MessageEvent');
- outgoingChatEvent.initMessageEvent(
- ChatBridgeEventTypes.CENTRAL_USER_UPDATE,
- true, true, jid);
- divGmailHandler.dispatchEvent(outgoingChatEvent);
+ dispatchChatEvent(ChatBridgeEventTypes.CENTRAL_USER_UPDATE, jid);
}
/**
@@ -48,8 +55,10 @@
centralJidListenerGmailPort = chrome.extension.connect(
{name: 'centralJidListener'});
centralJidListenerGmailPort.onMessage.addListener(function(msg) {
- centralRosterJid = msg.jid;
- dispatchCentralJid(centralRosterJid);
+ if (msg.eventType == ChatBridgeEventTypes.CENTRAL_USER_UPDATE) {
+ centralRosterJid = msg.jid;
+ }
+ dispatchChatEvent(msg.eventType, msg.jid);
});
}
}
« no previous file with comments | « chrome/browser/resources/chat_manager/js/chatbridgehook.js ('k') | chrome/browser/resources/chat_manager/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698