~extension-hackers/messagingmenu-extension/1.0

« back to all changes in this revision

Viewing changes to res/modules/MessagingMenuModule.jsm

  • Committer: Chris Coulson
  • Date: 2012-09-11 20:40:33 UTC
  • Revision ID: chris.coulson@canonical.com-20120911204033-k88fp2i1816szyws
Don't null check the results of getService() - if it fails, then it throws

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
function openWindowByType(aType, aURL, aTimestamp) {
131
131
  let win = null;
132
132
  if (aType) {
133
 
    let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
134
 
             .getService(Ci.nsIWindowMediator);
135
 
    if (wm) {
136
 
      win = wm.getMostRecentWindow(aType);
137
 
    }
 
133
    win = Cc["@mozilla.org/appshell/window-mediator;1"]
 
134
          .getService(Ci.nsIWindowMediator).getMostRecentWindow(aType);
138
135
  }
139
136
 
140
137
  if (!win) {
141
 
    let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]
142
 
             .getService(Ci.nsIWindowWatcher);
143
 
    if (ww) {
144
 
      win = ww.openWindow(null, aURL, "",
145
 
                          "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", null);
146
 
    }
 
138
      win = Cc["@mozilla.org/embedcomp/window-watcher;1"]
 
139
            .getService(Ci.nsIWindowWatcher)
 
140
            .openWindow(null, aURL, "",
 
141
                        "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", null);
147
142
  }
148
143
 
149
144
  if (win) {
154
149
      // 3. Pre-TB17 (or pre-TB15 Ubuntu builds) with no access to handle
155
150
      let nsIBaseWindow = Ci.nsIBaseWindow_UBUNTU_ONLY || Ci.nsIBaseWindow;
156
151
      let baseWin = win.QueryInterface(Ci.nsIInterfaceRequestor)
157
 
                     .getInterface(Ci.nsIWebNavigation)
158
 
                     .QueryInterface(Ci.nsIDocShellTreeItem)
159
 
                     .treeOwner
160
 
                     .QueryInterface(nsIBaseWindow);
 
152
                    .getInterface(Ci.nsIWebNavigation)
 
153
                    .QueryInterface(Ci.nsIDocShellTreeItem)
 
154
                    .treeOwner
 
155
                    .QueryInterface(nsIBaseWindow);
161
156
      if (!("nativeHandle" in baseWin)) {
162
157
        injectTimestampHack(aTimestamp);
163
158
      } else {
164
159
        gdk.gdk_x11_window_set_user_time(gdk.GdkWindow
165
 
                                           .ptr(ctypes
166
 
                                                  .UInt64(baseWin
167
 
                                                          .nativeHandle)),
 
160
                                         .ptr(ctypes
 
161
                                              .UInt64(baseWin
 
162
                                                      .nativeHandle)),
168
163
                                         aTimestamp);
169
164
      }
170
165
    }