~ubuntu-branches/ubuntu/intrepid/xulrunner-1.9/intrepid

« back to all changes in this revision

Viewing changes to mozilla/xpfe/components/winhooks/nsSetDefaultBrowser.js

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Fabien Tassin
  • Date: 2008-02-13 11:47:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080213114721-7om0mgzngvuk9czv
Tags: 1.9~b3+nobinonly-0ubuntu1
* release FIREFOX_3_0b3_RELEASE

[ Alexander Sack ]
* submit patch that ships xpcshell to bugzilla
  - rename debian/patches/ship_xpcshell.patch =>
           debian/patches/bz410617_att295212_ship_xpcshell.patch
  - update debian/patches/series
* fix tooltip in epiphany: previously displayed out of screen bounds
  (LP: #37507)
  - add debian/patches/bz233371_att297343_fix_outofscreen_embed_tooltip.patch
  - update debian/patches/series
* use default upstream gcc tweaks for improved performance - especially of the
  javascript engine
  - update debian/rules
* update global extension/plugin patch to apply cleanly against latest code
  - update debian/patches/bzXXX_gre_extension_plugin_support.patch
* fix pyxpcom build failure introduced by recent commit
  - add debian/patches/bzXXX_fix_pyxpcom_build_failure.patch
  - update debian/patches/series
* add distro independent global install locations for extensions,
  /usr/lib/mozilla/extensions and /usr/share/mozilla/extensions
  - update debian/xulrunner-1.9.dirs
* support embedded tarball layout when either there is a *.tar.bz2 in orig tarball
  or if DEBIAN_MOZCLIENT_EMBEDDED is not unset (you will need this to produce embedded
  tarballs during |get-orig-source|
  - update debian/rules
* bump minimum libnss3-dev build requirements to >= 3.12.0~1.9b3
  - update debian/control
* bump minimum libnspr4-dev build requirements to >= 4.7.0~1.9b3
  - update debian/control

[ Fabien Tassin ]
* Drop patches applied upstream
  - drop debian/patches/bz410617_att295212_ship_xpcshell.patch
  - drop debian/patches/bz404634_att294921.patch
  - drop debian/patches/bz386610_python2.5_ftbfs_amd64.patch
  - drop debian/patches/bz373918_att295042.patch
  - drop debian/patches/bz408062_unstable_pc.patch
  - drop debian/patches/bz384304_fix_recursive_symlinks.patch
  - update debian/patches/series
* Refresh diverged patches:
  - update debian/patches/bzXXX_pc_honour_system_nspr_nss.patch
  - update debian/patches/rename_venkman_addon.patch
  - update debian/patches/bz344818_cairo_xrender.patch
* Install links for all .so libs in the -dev package
  - update debian/patches/dont_install_so_in_dev.patch
* Bump gtk requirement to 2.12 as per Mozilla bug 412432
  - update debian/control
* Add #DEBHELPER# token to postinst/prerm scripts
  - update debian/xulrunner-1.9.{postinst,prerm}
* Install previously missed libdbusservice.so
  - update debian/xulrunner-1.9.install
* Update venkman patch to also rename locales
  - update debian/patches/rename_venkman_addon.patch
* Bump requirement for system cairo to >= 1.5.8 as we now need
  the newly added cairo_path_extents()
  - update debian/rules
* Include mozilla-devscripts file using -include so ifneq could be omitted
  - update debian/rules
* Fix missing .so symlinks regression
  - update debian/patches/dont_install_so_in_dev.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ***** BEGIN LICENSE BLOCK *****
2
 
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
 *
4
 
 * The contents of this file are subject to the Mozilla Public License Version
5
 
 * 1.1 (the "License"); you may not use this file except in compliance with
6
 
 * the License. You may obtain a copy of the License at
7
 
 * http://www.mozilla.org/MPL/
8
 
 *
9
 
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 
 * for the specific language governing rights and limitations under the
12
 
 * License.
13
 
 *
14
 
 * The Original Code is Mozilla Default Browser.
15
 
 *
16
 
 * The Initial Developer of the Original Code is
17
 
 * Netscape Communications Corp.
18
 
 * Portions created by the Initial Developer are Copyright (C) 2002
19
 
 * the Initial Developer. All Rights Reserved.
20
 
 *
21
 
 * Contributor(s):
22
 
 *   Bill Law  <law@netscape.com>
23
 
 *
24
 
 * Alternatively, the contents of this file may be used under the terms of
25
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
26
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
28
 
 * of those above. If you wish to allow use of your version of this file only
29
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
30
 
 * use your version of this file under the terms of the MPL, indicate your
31
 
 * decision by deleting the provisions above and replace them with the notice
32
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
33
 
 * the provisions above, a recipient may use your version of this file under
34
 
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 
 *
36
 
 * ***** END LICENSE BLOCK ***** */
37
 
 
38
 
/* This file implements the nsICmdLineHandler interface.  See nsICmdLineHandler.idl
39
 
 * at http://lxr.mozilla.org/seamonkey/source/xpfe/appshell/public/nsICmdLineHandler.idl.
40
 
 *
41
 
 * This component handles the startup command line argument of the form:
42
 
 *   -setDefaultBrowser
43
 
 * by making the current executable the "default browser."  It accomplishes
44
 
 * that via use of the nsIWindowsHooks interface (see implementation below).
45
 
 *
46
 
 * The module is registered under the contractid
47
 
 *   "@mozilla.org/commandlinehandler/general-startup;1?type=setDefaultBrowser"
48
 
 *
49
 
 * The implementation consists of a JavaScript "class" named nsKillAll,
50
 
 * comprised of:
51
 
 *   - a JS constructor function
52
 
 *   - a prototype providing all the interface methods and implementation stuff
53
 
 *
54
 
 * In addition, this file implements an nsIModule object that registers the
55
 
 * nsSetDefaultBrowser component.
56
 
 */
57
 
 
58
 
/* ctor
59
 
 */
60
 
function nsSetDefaultBrowser() {
61
 
}
62
 
 
63
 
nsSetDefaultBrowser.prototype = {
64
 
 
65
 
    // nsICmdLineHandler interface
66
 
    get commandLineArgument() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
67
 
    get prefNameForStartup()  { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
68
 
 
69
 
    get chromeUrlForTask()    {
70
 
      // First, get winhooks service.
71
 
      var winHooks = Components.classes[ "@mozilla.org/winhooks;1" ]
72
 
                        .getService( Components.interfaces.nsIWindowsHooks );
73
 
 
74
 
      // Next, extract current settings (these are what the user
75
 
      // had previously checked on the Advanced/System pref panel).
76
 
      var settings = winHooks.settings;
77
 
 
78
 
      // Now, turn on all "default browser" settings.
79
 
      settings.isHandlingHTTP  = true;
80
 
      settings.isHandlingHTTPS = true;
81
 
      settings.isHandlingFTP   = true;
82
 
      settings.isHandlingHTML  = true;
83
 
      settings.isHandlingXHTML = true;
84
 
      settings.isHandlingXML   = true;
85
 
 
86
 
      // Finally, apply the (new) settings.
87
 
      winHooks.settings = settings;
88
 
 
89
 
      // Now, get the cmd line service.
90
 
      var cmdLineService = Components.classes[ "@mozilla.org/app-startup/commandLineService;1" ]
91
 
                              .getService( Components.interfaces.nsICmdLineService );
92
 
 
93
 
      // See if "-setDefaultBrowser" was specified.  The value will be "1" if
94
 
      // -setDefaultBrowser is in the service's list of cmd line arguments, and
95
 
      // null otherwise.  -setDefaultBrowser will only be in the service's
96
 
      // arg list if the application was not already running.  That's because
97
 
      // if it was already running, then the service reflects the arguments
98
 
      // that were specified when *that* process was started, *not* the ones
99
 
      // passed via IPC from the second instance.
100
 
      var option = cmdLineService.getCmdLineValue( "-setDefaultBrowser" );
101
 
      if (!option) {
102
 
        // Already running, so we don't have to worry about opening
103
 
        // another window, etc.
104
 
        throw Components.results.NS_ERROR_NOT_AVAILABLE;
105
 
      }
106
 
 
107
 
      // Return URL for dummy window that will auto-close.  We do this rather
108
 
      // than throw NS_ERROR_NOT_AVAILABLE, which *should* work, because it
109
 
      // seems that if we don't open a window, we get a crash when trying to
110
 
      // release this (or some other) JS component during XPCOM shutdown.
111
 
      return "chrome://global/content/dummyWindow.xul";
112
 
    },
113
 
 
114
 
    get helpText()            { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
115
 
    get handlesArgs()         { return false; },
116
 
    get defaultArgs()         { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
117
 
    get openWindowWithArgs()  { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
118
 
 
119
 
    // nsISupports interface
120
 
 
121
 
    // This "class" supports nsICmdLineHandler and nsISupports.
122
 
    QueryInterface: function (iid) {
123
 
        if (iid.equals(Components.interfaces.nsICmdLineHandler) ||
124
 
            iid.equals(Components.interfaces.nsISupports))
125
 
            return this;
126
 
 
127
 
        Components.returnCode = Components.results.NS_ERROR_NO_INTERFACE;
128
 
        return null;
129
 
    },
130
 
 
131
 
    // This Component's module implementation.  All the code below is used to get this
132
 
    // component registered and accessible via XPCOM.
133
 
    module: {
134
 
        // registerSelf: Register this component.
135
 
        registerSelf: function (compMgr, fileSpec, location, type) {
136
 
            var compReg = compMgr.QueryInterface( Components.interfaces.nsIComponentRegistrar );
137
 
            compReg.registerFactoryLocation( this.cid,
138
 
                                             "Default Browser Component",
139
 
                                             this.contractId,
140
 
                                             fileSpec,
141
 
                                             location,
142
 
                                             type );
143
 
        },
144
 
 
145
 
        // getClassObject: Return this component's factory object.
146
 
        getClassObject: function (compMgr, cid, iid) {
147
 
            if (!cid.equals(this.cid))
148
 
                throw Components.results.NS_ERROR_NO_INTERFACE;
149
 
 
150
 
            if (!iid.equals(Components.interfaces.nsIFactory))
151
 
                throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
152
 
 
153
 
            return this.factory;
154
 
        },
155
 
 
156
 
        /* CID for this class */
157
 
        cid: Components.ID("{C66E05DC-509C-4972-A1F2-EE5AC34B9800}"),
158
 
 
159
 
        /* Contract ID for this class */
160
 
        contractId: "@mozilla.org/commandlinehandler/general-startup;1?type=setDefaultBrowser",
161
 
 
162
 
        /* factory object */
163
 
        factory: {
164
 
            // createInstance: Return a new nsSetDefaultBrowser object.
165
 
            createInstance: function (outer, iid) {
166
 
                if (outer != null)
167
 
                    throw Components.results.NS_ERROR_NO_AGGREGATION;
168
 
 
169
 
                return (new nsSetDefaultBrowser()).QueryInterface(iid);
170
 
            }
171
 
        },
172
 
 
173
 
        // canUnload: n/a (returns true)
174
 
        canUnload: function(compMgr) {
175
 
            return true;
176
 
        }
177
 
    }
178
 
}
179
 
 
180
 
// NSGetModule: Return the nsIModule object.
181
 
function NSGetModule(compMgr, fileSpec) {
182
 
    return nsSetDefaultBrowser.prototype.module;
183
 
}