Bug 89907; add new UI to Nav pref panel to simply making Mozilla the default browser; r=sgehanni, sr=ben

This commit is contained in:
law%netscape.com 2006-05-17 02:34:52 +00:00
Родитель c76ecf053d
Коммит 0c103e65bc
4 изменённых файлов: 213 добавлений и 34 удалений

Просмотреть файл

@ -86,17 +86,16 @@ nsPrefWindow.prototype =
onOK:
function ()
{
for( var i = 0; i < hPrefWindow.okHandlers.length; i++ )
{
hPrefWindow.okHandlers[i]();
}
var tag = document.getElementById( hPrefWindow.contentFrame ).getAttribute("tag");
if( tag == "" )
{
tag = document.getElementById( hPrefWindow.contentFrame ).getAttribute("src");
}
hPrefWindow.wsm.savePageData( tag );
for( var i = 0; i < hPrefWindow.okHandlers.length; i++ )
{
hPrefWindow.okHandlers[i]();
}
hPrefWindow.savePrefs();
},

Просмотреть файл

@ -23,6 +23,7 @@
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/pref/platformPrefOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/pref/pref-navigator.dtd" >
@ -43,16 +44,18 @@
]]>
</script>
<!-- navigator starts with -->
<groupbox>
<caption label="&navRadio;"/>
<radiogroup id="startupPage" prefstring="browser.startup.page">
<radio value="0" label="&blankPageRadio.label;" accesskey="&blankPageRadio.accesskey;"/>
<radio value="1" label="&homePageRadio.label;" accesskey="&homePageRadio.accesskey;"/>
<radio value="2" label="&lastPageRadio.label;" accesskey="&lastPageRadio.accesskey;"/>
</radiogroup>
</groupbox>
<hbox id="pref-nav-platform-extensions">
<!-- navigator starts with -->
<groupbox>
<caption label="&navRadio;"/>
<radiogroup id="startupPage" prefstring="browser.startup.page">
<radio value="0" label="&blankPageRadio.label;" accesskey="&blankPageRadio.accesskey;"/>
<radio value="1" label="&homePageRadio.label;" accesskey="&homePageRadio.accesskey;"/>
<radio value="2" label="&lastPageRadio.label;" accesskey="&lastPageRadio.accesskey;"/>
</radiogroup>
</groupbox>
</hbox>
<!-- homepage specification -->
<groupbox>

Просмотреть файл

@ -35,23 +35,8 @@ function dumpObject( obj, name ) {
// Top-level windows integration preferences.
if ( !( "winHooks" in parent ) ) {
parent.winHooks = new Object;
parent.winHooks.settings = [ "isHandlingHTML",
"isHandlingJPEG",
"isHandlingGIF",
"isHandlingPNG",
"isHandlingMNG",
"isHandlingBMP",
"isHandlingICO",
"isHandlingXML",
"isHandlingXHTML",
"isHandlingXUL",
"isHandlingHTTP",
"isHandlingHTTPS",
"isHandlingFTP",
"isHandlingCHROME",
"isHandlingGOPHER",
"showDialog" ];
parent.winHooks.settings = null;
parent.winHooks.winhooks = null;
parent.winHooks.prefs = null;
}
@ -104,14 +89,34 @@ function Startup() {
// Set globals.
parent.winHooks.winhooks = winhooks;
parent.winHooks.prefs = prefs;
// Register so we get called when pref window Ok is pressed.
parent.hPrefWindow.registerOKCallbackFunc( onOK );
}
}
catch(e) {
dump( e + "\n" );
}
}
if ( !settings ) {
// Set state specific to this panel (not shared with the "default browser"
// button state from the Navigator panel).
settings = parent.winHooks.settings = [ "isHandlingHTML",
"isHandlingJPEG",
"isHandlingGIF",
"isHandlingPNG",
"isHandlingMNG",
"isHandlingBMP",
"isHandlingICO",
"isHandlingXML",
"isHandlingXHTML",
"isHandlingXUL",
"isHandlingHTTP",
"isHandlingHTTPS",
"isHandlingFTP",
"isHandlingCHROME",
"isHandlingGOPHER",
"showDialog" ];
// Register so we get called when pref window Ok is pressed.
parent.hPrefWindow.registerOKCallbackFunc( onOK );
}
// Transfer object settings to the dialog checkboxes.
for( var index in settings ) {
var setting = settings[ index ];

Просмотреть файл

@ -21,9 +21,15 @@
Contributor(s):
Ben Goodger <ben@netscape.com>
Bill Law <law@netscape.com>
-->
<!DOCTYPE window SYSTEM "chrome://communicator-platform/locale/pref/platformPrefOverlay.dtd">
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd">
%brandDTD;
<!ENTITY % platformPrefOverlayDTD SYSTEM "chrome://communicator-platform/locale/pref/platformPrefOverlay.dtd">
%platformPrefOverlayDTD;
]>
<overlay id="platformPreferencesOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@ -36,6 +42,172 @@
</treerow>
</treeitem>
</treechildren>
<!-- Add "set default browser" button to Navigator panel. -->
<hbox id="pref-nav-platform-extensions">
<groupbox flex="1">
<caption label="&defaultBrowserGroup.label;"/>
<deck id="defaultBrowserDeck" flex="1">
<!-- We use a deck for the three cases:
o If not already the default, then use child 0 (with button enabled)
o If already the default, then use child 1 (with disabled button).
o If the user has already pushed the "Set As Default" button, then use child 2
(with different text and a disabled button).
-->
<vbox flex="1">
<description>&makeDefaultText;</description>
<hbox>
<spacer flex="1"/>
<button label="&defaultBrowserButton.label;"
oncommand="makeDefault()"/>
<spacer flex="1"/>
</hbox>
</vbox>
<vbox flex="1">
<description>&alreadyDefaultText;</description>
<hbox>
<spacer flex="1"/>
<button label="&defaultBrowserButton.label;"
autostretch="never"
disabled="true"/>
<spacer flex="1"/>
</hbox>
</vbox>
<vbox flex="1">
<description pack="start">&defaultPendingText;</description>
<hbox>
<spacer flex="1"/>
<button label="&defaultBrowserButton.label;"
autostretch="never"
disabled="true"/>
<spacer flex="1"/>
</hbox>
</vbox>
</deck>
</groupbox>
</hbox>
<script type="application/x-javascript">
<![CDATA[
// This overlay is pulled into multiple places. We only want this
// code to kick in when we're overlaid onto pref-navigator.xul. And,
// we don't want to conflict with code within other files. So,
// we use anonymous functions throughout.
if (document.documentElement.id == "pref-navigator") {
// "Install" the SetFields function. This will be
// called whenever the Navigator pane is shown.
window.SetFields = function( pageData ) {
// Determine if we have been selected as the default browser
// already, and enable/disable the "Set As Default" button
// accordingly.
// We store our state info in the same place as the code in
// pref-winhooks.js uses so that this panel and the
// Advanced/System panel are kept in synch.
if (!("winHooks" in parent)) {
// Neither the Advanced/System panel nor this panel has
// appeared. Initialize the state information.
parent.winHooks = new Object;
// Get winhooks service.
parent.winHooks.winhooks = Components.classes[ "@mozilla.org/winhooks;1" ]
.getService( Components.interfaces.nsIWindowsHooks );
// Extract current settings (these are what the user has checked on
// the Advanced/System panel).
parent.winHooks.prefs = parent.winHooks.winhooks.settings;
}
// Ensure our additional state info is set.
if (!("makeDefaultPending" in parent.winHooks)) {
parent.winHooks.makeDefaultPending = false;
}
// Figure out which <deck> child should be activated.
// Default is child 0 (with button enabled).
var deckState = 0;
// Start by checking http/https/ftp and html/xhtml/xml.
var prefs = parent.winHooks.prefs;
if (prefs.isHandlingHTTP &&
prefs.isHandlingHTTPS &&
prefs.isHandlingFTP &&
prefs.isHandlingHTML &&
prefs.isHandlingXHTML &&
prefs.isHandlingXML) {
// The user *wants* us to be the default, apparently. This means
// that the deck *might* be in one of the other two states (with
// button disabled), depending on whether the registry matches.
// We test the registry settings using a scratch copy of the
// settings because we don't care about some of them, but we
// don't want to mess up the user's choices from the
// Advanced/System panel.
var testSettings = parent.winHooks.winhooks.settings;
// Test that these are set.
testSettings.isHandlingHTTP = true;
testSettings.isHandlingHTTPS = true;
testSettings.isHandlingFTP = true;
testSettings.isHandlingHTML = true;
testSettings.isHandlingXHTML = true;
testSettings.isHandlingXML = true;
// Ignore the rest.
testSettings.isHandlingCHROME = false;
testSettings.isHandlingGOPHER = false;
testSettings.isHandlingJPEG = false;
testSettings.isHandlingGIF = false;
testSettings.isHandlingMNG = false;
testSettings.isHandlingPNG = false;
testSettings.isHandlingBMP = false;
testSettings.isHandlingICO = false;
testSettings.isHandlingXUL = false;
// Now test whether the registry matches that.
if ( testSettings.registryMatches ) {
// Disable the button. The only remaining question
// is what text appears alongside it. That will
// vary depending on whether the user has pressed
// the "Set As Default" button already.
if ( parent.winHooks.makeDefaultPending ) {
deckState = 2;
} else {
deckState = 1;
}
}
}
// Now, switch the deck to the appropriate state.
document.getElementById("defaultBrowserDeck").selectedIndex = deckState;
// Return true to tell caller to process the standard pref fields.
return true;
}
// "Install" the makeDefault function;
window.makeDefault = function() {
// Extract current settings (these are what the
// user has checked on the Advanced/System panel).
var settings = parent.winHooks.prefs;
// Turn on all "default browser" settings.
settings.isHandlingHTTP = true;
settings.isHandlingHTTPS = true;
settings.isHandlingFTP = true;
settings.isHandlingHTML = true;
settings.isHandlingXHTML = true;
settings.isHandlingXML = true;
// Register callback that will be called when and if the
// user presses the OK button.
parent.hPrefWindow.registerOKCallbackFunc( function () {
// Apply the settings.
parent.winHooks.winhooks.settings = parent.winHooks.prefs;
} );
// Flip the deck to the "make-default pending" state.
document.getElementById("defaultBrowserDeck").selectedIndex = 2;
// Remember this state when next displayed.
parent.winHooks.makeDefaultPending = true;
}
}
]]>
</script>
</overlay>