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 2002-06-11 20:06:05 +00:00
Родитель 394af917c2
Коммит f0c6038400
7 изменённых файлов: 270 добавлений и 65 удалений

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

@ -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,6 +44,7 @@
]]>
</script>
<hbox id="pref-nav-platform-extensions">
<!-- navigator starts with -->
<groupbox>
<caption label="&navRadio;"/>
@ -53,6 +55,7 @@
</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">
@ -37,5 +43,171 @@
</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>

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

@ -143,6 +143,12 @@ interface nsIWindowsHooksSettings : nsISupports {
// appears on startup if there is a mismatch
// between registry and these settings.
attribute boolean showDialog;
// Registry mismatch indicator.
// This is true if the Win32 registry is
// currently set to match the preferences
// in this object.
readonly attribute boolean registryMatches;
};
/* nsIWindowsHooks

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

@ -291,6 +291,48 @@ static PRBool isAccessRestricted() {
// Implementation of method that checks whether the settings match what's in the
// Windows registry.
NS_IMETHODIMP
nsWindowsHooksSettings::GetRegistryMatches( PRBool *_retval ) {
NS_ENSURE_ARG( _retval );
*_retval = PR_TRUE;
// Test registry for all selected attributes.
if ( misMatch( mHandleHTTP, http )
||
misMatch( mHandleHTTPS, https )
||
misMatch( mHandleFTP, ftp )
||
misMatch( mHandleCHROME, chrome )
||
misMatch( mHandleGOPHER, gopher )
||
misMatch( mHandleHTML, mozillaMarkup )
||
misMatch( mHandleJPEG, jpg )
||
misMatch( mHandleGIF, gif )
||
misMatch( mHandlePNG, png )
||
misMatch( mHandleMNG, mng )
||
misMatch( mHandleBMP, bmp )
||
misMatch( mHandleICO, ico )
||
misMatch( mHandleXML, xml )
||
misMatch( mHandleXHTML, xhtml )
||
misMatch( mHandleXUL, xul ) ) {
// Registry is out of synch.
*_retval = PR_FALSE;
}
return NS_OK;
}
// Implementation of method that checks settings versus registry and prompts user
// if out of synch.
NS_IMETHODIMP
@ -357,35 +399,9 @@ nsWindowsHooks::CheckSettings( nsIDOMWindowInternal *aParent,
// First, make sure the user cares.
if ( settings->mShowDialog || installing ) {
// Look at registry setting for all things that are set.
if ( misMatch( settings->mHandleHTTP, http )
||
misMatch( settings->mHandleHTTPS, https )
||
misMatch( settings->mHandleFTP, ftp )
||
misMatch( settings->mHandleCHROME, chrome )
||
misMatch( settings->mHandleGOPHER, gopher )
||
misMatch( settings->mHandleHTML, mozillaMarkup )
||
misMatch( settings->mHandleJPEG, jpg )
||
misMatch( settings->mHandleGIF, gif )
||
misMatch( settings->mHandlePNG, png )
||
misMatch( settings->mHandleMNG, mng )
||
misMatch( settings->mHandleBMP, bmp )
||
misMatch( settings->mHandleICO, ico )
||
misMatch( settings->mHandleXML, xml )
||
misMatch( settings->mHandleXHTML, xhtml )
||
misMatch( settings->mHandleXUL, xul )) {
PRBool matches = PR_TRUE;
settings->GetRegistryMatches( &matches );
if ( !matches ) {
// Need to prompt user.
// First:
// o We need the common dialog service to show the dialog.

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

@ -163,9 +163,13 @@ nsWidgetStateManager.prototype =
var pageData = this.dataManager.getPageData( aPageTag );
if( 'SetFields' in this.contentArea )
{
this.contentArea.SetFields( pageData );
if ( !this.contentArea.SetFields( pageData ) )
{
// If the function returns false (or null/undefined) then it
// doesn't want *us* to process the page data.
return;
}
}
for( var elementID in pageData )
{