From 70e1e3d5c9e58b1f7ba60f4a6707df68a327268a Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Fri, 22 Jun 2012 22:28:23 -0700 Subject: [PATCH] Bug 763171 - Open tabs for URIs received from Sync; r=rnewman --- browser/base/content/browser-syncui.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/browser/base/content/browser-syncui.js b/browser/base/content/browser-syncui.js index 72e5729d869f..1e537a38e783 100644 --- a/browser/base/content/browser-syncui.js +++ b/browser/base/content/browser-syncui.js @@ -15,7 +15,9 @@ let gSyncUI = { "weave:ui:login:error", "weave:ui:sync:error", "weave:ui:sync:finish", - "weave:ui:clear-error"], + "weave:ui:clear-error", + "weave:engine:clients:display-uri", + ], _unloaded: false, @@ -395,6 +397,21 @@ let gSyncUI = { this.updateUI(); }, + /** + * Observer called when display URI command is received. + */ + onDisplayURI: function onDisplayURI(data) { + if (!gBrowser) { + return; + } + + try { + gBrowser.addTab(data.wrappedJSObject.object.uri); + } catch (ex) { + Cu.reportError("Error displaying tab received by Sync: " + ex); + } + }, + observe: function SUI_observe(subject, topic, data) { if (this._unloaded) { Cu.reportError("SyncUI observer called after unload: " + topic); @@ -444,6 +461,9 @@ let gSyncUI = { case "weave:ui:clear-error": this.clearError(); break; + case "weave:engine:clients:display-uri": + this.onDisplayURI(subject); + break; } },