зеркало из https://github.com/mozilla/gecko-dev.git
rtm+ bug 27187; add code to make Mozilla the 'default browser'; r=ssu@netscape.com; sr=scc@netscape.com
This commit is contained in:
Родитель
1998a4a631
Коммит
251d8346a3
|
@ -0,0 +1,2 @@
|
|||
en-US.jar:
|
||||
locale/en-US/global/nsWindowsHooks.properties (locale/en-US/nsWindowsHooks.properties)
|
|
@ -0,0 +1,7 @@
|
|||
title=Desktop Integration
|
||||
yesButtonLabel=Yes
|
||||
noButtonLabel=No
|
||||
cancelButtonLabel=Cancel
|
||||
checkBoxLabel=Check at startup next time, too.
|
||||
promptText=Windows is not currently set up to match your Desktop Integration preferences. This means that Windows will not use this application when you open all the types of documents and Internet shortcuts that you have indicated. Do you want to update Windows to match your Desktop Integration preferences?
|
||||
initialPromptText=Do you want to set up Windows so that it will use this application whenever you open the kinds of documents and Internet shortcuts that this application can view?
|
|
@ -91,6 +91,8 @@
|
|||
* can be set up using the implementation of the interfaces defined here.
|
||||
*/
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
|
||||
/* nsIWindowsHooksSettings
|
||||
*
|
||||
* This interface is used to get/set the user preferences relating to
|
||||
|
@ -116,6 +118,10 @@ interface nsIWindowsHooksSettings : nsISupports {
|
|||
attribute boolean isHandlingXML;
|
||||
attribute boolean isHandlingXUL;
|
||||
|
||||
// Nag dialog flag. Set this so that dialog
|
||||
// appears on startup if there is a mismatch
|
||||
// between registry and these settings.
|
||||
attribute boolean showDialog;
|
||||
};
|
||||
|
||||
/* nsIWindowsHooks
|
||||
|
@ -127,10 +133,23 @@ interface nsIWindowsHooksSettings : nsISupports {
|
|||
[scriptable, uuid(19c9fbb0-06a3-11d4-8076-00600811a9c3)]
|
||||
interface nsIWindowsHooks : nsISupports {
|
||||
|
||||
// Settings. Get/set this to query or modify them. The Windows
|
||||
// settings
|
||||
// --------
|
||||
// Get/set this to query or modify them. The Windows
|
||||
// registry is updated when you set this attribute.
|
||||
attribute nsIWindowsHooksSettings settings;
|
||||
|
||||
// checkSettings
|
||||
// -------------
|
||||
// Check that registry matches settings and if not,
|
||||
// prompt user for whether to reset. This is
|
||||
// controlled by the showDialog setting. This will
|
||||
// perform the check only the first time the
|
||||
// service is called.
|
||||
// aParent - parent window for any dialogs that
|
||||
// will appear
|
||||
void checkSettings( in nsIDOMWindowInternal aParent );
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -25,6 +25,13 @@
|
|||
|
||||
// Implementation utilities.
|
||||
#include "nsWindowsHooksUtil.cpp"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICommonDialogs.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
// Objects that describe the Windows registry entries that we need to tweak.
|
||||
static ProtocolRegistryEntry
|
||||
|
@ -100,6 +107,8 @@ DEFINE_GETTER_AND_SETTER( IsHandlingHTTP, mHandleHTTP )
|
|||
DEFINE_GETTER_AND_SETTER( IsHandlingHTTPS, mHandleHTTPS )
|
||||
DEFINE_GETTER_AND_SETTER( IsHandlingFTP, mHandleFTP )
|
||||
DEFINE_GETTER_AND_SETTER( IsHandlingCHROME, mHandleCHROME )
|
||||
DEFINE_GETTER_AND_SETTER( ShowDialog, mShowDialog )
|
||||
DEFINE_GETTER_AND_SETTER( HaveBeenSet, mHaveBeenSet )
|
||||
|
||||
|
||||
// Implementation of the nsIWindowsHooks interface.
|
||||
|
@ -139,6 +148,8 @@ nsWindowsHooks::GetSettings( nsWindowsHooksSettings **result ) {
|
|||
prefs->mHandlePNG = (void*)( BoolRegistryEntry( "isHandlingPNG" ) ) ? PR_TRUE : PR_FALSE;
|
||||
prefs->mHandleXML = (void*)( BoolRegistryEntry( "isHandlingXML" ) ) ? PR_TRUE : PR_FALSE;
|
||||
prefs->mHandleXUL = (void*)( BoolRegistryEntry( "isHandlingXUL" ) ) ? PR_TRUE : PR_FALSE;
|
||||
prefs->mShowDialog = (void*)( BoolRegistryEntry( "showDialog" ) ) ? PR_TRUE : PR_FALSE;
|
||||
prefs->mHaveBeenSet = (void*)( BoolRegistryEntry( "haveBeenSet" ) ) ? PR_TRUE : PR_FALSE;
|
||||
|
||||
#ifdef DEBUG_law
|
||||
NS_WARN_IF_FALSE( NS_SUCCEEDED( rv ), "GetPreferences failed" );
|
||||
|
@ -164,6 +175,245 @@ nsWindowsHooks::GetSettings( nsIWindowsHooksSettings **_retval ) {
|
|||
return rv;
|
||||
}
|
||||
|
||||
static PRBool misMatch( const PRBool &flag, const ProtocolRegistryEntry &entry ) {
|
||||
PRBool result = PR_FALSE;
|
||||
// Check if we care.
|
||||
if ( flag ) {
|
||||
// Compare registry entry setting to what it *should* be.
|
||||
if ( entry.currentSetting() != entry.setting ) {
|
||||
result = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Implementation of method that checks settings versus registry and prompts user
|
||||
// if out of synch.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::CheckSettings( nsIDOMWindowInternal *aParent ) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Only do this once!
|
||||
static PRBool alreadyChecked = PR_FALSE;
|
||||
if ( alreadyChecked ) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
alreadyChecked = PR_TRUE;
|
||||
}
|
||||
|
||||
// Get settings.
|
||||
nsWindowsHooksSettings *settings;
|
||||
rv = this->GetSettings( &settings );
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) && settings ) {
|
||||
// If not set previously, set to defaults so that they are
|
||||
// set properly when/if the user says to.
|
||||
if ( !settings->mHaveBeenSet ) {
|
||||
settings->mHandleHTTP = PR_TRUE;
|
||||
settings->mHandleHTTPS = PR_TRUE;
|
||||
settings->mHandleFTP = PR_TRUE;
|
||||
settings->mHandleCHROME = PR_TRUE;
|
||||
settings->mHandleHTML = PR_TRUE;
|
||||
settings->mHandleJPEG = PR_TRUE;
|
||||
settings->mHandleGIF = PR_TRUE;
|
||||
settings->mHandlePNG = PR_TRUE;
|
||||
settings->mHandleXML = PR_TRUE;
|
||||
settings->mHandleXUL = PR_TRUE;
|
||||
|
||||
settings->mShowDialog = PR_TRUE;
|
||||
}
|
||||
|
||||
// If launched with "-installer" then override mShowDialog.
|
||||
PRBool installing = PR_FALSE;
|
||||
if ( !settings->mShowDialog ) {
|
||||
// Get command line service.
|
||||
nsCID cmdLineCID = NS_COMMANDLINE_SERVICE_CID;
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs( do_GetService( cmdLineCID, &rv ) );
|
||||
if ( NS_SUCCEEDED( rv ) && cmdLineArgs ) {
|
||||
// See if "-installer" was specified.
|
||||
nsXPIDLCString installer;
|
||||
rv = cmdLineArgs->GetCmdLineValue( "-installer", getter_Copies( installer ) );
|
||||
if ( NS_SUCCEEDED( rv ) && installer ) {
|
||||
installing = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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->mHandleHTML, mozillaMarkup )
|
||||
||
|
||||
misMatch( settings->mHandleJPEG, jpg )
|
||||
||
|
||||
misMatch( settings->mHandleGIF, gif )
|
||||
||
|
||||
misMatch( settings->mHandlePNG, png )
|
||||
||
|
||||
misMatch( settings->mHandleXML, xml )
|
||||
||
|
||||
misMatch( settings->mHandleXUL, xul ) ) {
|
||||
// Need to prompt user.
|
||||
// First:
|
||||
// o We need the common dialog service to show the dialog.
|
||||
// o We need the string bundle service to fetch the appropriate
|
||||
// dialog text.
|
||||
nsCID commonDlgCID = NS_CommonDialog_CID;
|
||||
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
|
||||
nsCOMPtr<nsICommonDialogs> commonDlgService( do_GetService( commonDlgCID, &rv ) );
|
||||
nsCOMPtr<nsIStringBundleService> bundleService( do_GetService( bundleCID, &rv ) );
|
||||
|
||||
if ( commonDlgService && bundleService ) {
|
||||
// Next, get bundle that provides text for dialog.
|
||||
nsILocale *locale = 0;
|
||||
nsIStringBundle *bundle;
|
||||
rv = bundleService->CreateBundle( "chrome://global/locale/nsWindowsHooks.properties",
|
||||
locale,
|
||||
getter_AddRefs( &bundle ) );
|
||||
if ( NS_SUCCEEDED( rv ) && bundle ) {
|
||||
// Get text for dialog and checkbox label.
|
||||
//
|
||||
// The window text depends on whether this is the first time
|
||||
// the user is seeing this dialog.
|
||||
const char *textKey = "promptText";
|
||||
if ( !settings->mHaveBeenSet ) {
|
||||
textKey = "initialPromptText";
|
||||
}
|
||||
nsXPIDLString text, label, title, yesButtonLabel, noButtonLabel, cancelButtonLabel;
|
||||
if ( NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_ConvertASCIItoUCS2( textKey ).GetUnicode(),
|
||||
getter_Copies( text ) ) ) )
|
||||
&&
|
||||
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "checkBoxLabel" ),
|
||||
getter_Copies( label ) ) ) )
|
||||
&&
|
||||
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "title" ),
|
||||
getter_Copies( title ) ) ) )
|
||||
&&
|
||||
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "yesButtonLabel" ),
|
||||
getter_Copies( yesButtonLabel ) ) ) )
|
||||
&&
|
||||
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "noButtonLabel" ),
|
||||
getter_Copies( noButtonLabel ) ) ) )
|
||||
&&
|
||||
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "cancelButtonLabel" ),
|
||||
getter_Copies( cancelButtonLabel ) ) ) ) ) {
|
||||
// Got the text, now show dialog.
|
||||
PRBool showDialog = settings->mShowDialog;
|
||||
PRInt32 dlgResult = -1;
|
||||
// No checkbox for initial display.
|
||||
const PRUnichar *labelArg = 0;
|
||||
if ( settings->mHaveBeenSet ) {
|
||||
// Subsequent display uses label string.
|
||||
labelArg = label;
|
||||
}
|
||||
// Note that the buttons need to be passed in this order:
|
||||
// o Yes
|
||||
// o Cancel
|
||||
// o No
|
||||
// because UniversalDialog will move "Cancel" to the right.
|
||||
rv = commonDlgService->UniversalDialog( aParent,
|
||||
0, // title
|
||||
title, // dlg title
|
||||
text, // dlg text
|
||||
labelArg, // Checkbox label
|
||||
yesButtonLabel, // yes button
|
||||
cancelButtonLabel, // cancel button
|
||||
noButtonLabel, // no button
|
||||
0, // button 3
|
||||
0, // edit 1 msg
|
||||
0, // edit 2 msg
|
||||
0, // edit 1 value
|
||||
0, // edit 2 value
|
||||
0, // icon (q-mark)
|
||||
&showDialog,
|
||||
3, // 3 buttons
|
||||
0, // no edit fields
|
||||
PR_FALSE, // no pw
|
||||
&dlgResult );
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// Did they say go ahead?
|
||||
switch ( dlgResult ) {
|
||||
case 0:
|
||||
// User says: make the changes.
|
||||
// Remember "show dialog" choice.
|
||||
settings->mShowDialog = showDialog;
|
||||
// Apply settings; this single line of
|
||||
// code will do different things depending
|
||||
// on whether this is the first time (i.e.,
|
||||
// when "haveBeenSet" is false). The first
|
||||
// time, this will set all prefs to true
|
||||
// (because that's how we initialized 'em
|
||||
// in GetSettings, above) and will update the
|
||||
// registry accordingly. On subsequent passes,
|
||||
// this will only update the registry (because
|
||||
// the settings we got from GetSettings will
|
||||
// not have changed).
|
||||
//
|
||||
// BTW, the term "prefs" in this context does not
|
||||
// refer to conventional Mozilla "prefs." Instead,
|
||||
// it refers to "Desktop Integration" prefs which
|
||||
// are stored in the windows registry.
|
||||
rv = SetSettings( settings );
|
||||
#ifdef DEBUG_law
|
||||
printf( "Yes, SetSettings returned 0x%08X\n", (int)rv );
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// User says: Don't mess with Windows.
|
||||
// We update only the "showDialog" and
|
||||
// "haveBeenSet" keys. Note that this will
|
||||
// have the effect of setting all the prefs
|
||||
// *off* if the user says no to the initial
|
||||
// prompt.
|
||||
BoolRegistryEntry( "haveBeenSet" ).set();
|
||||
if ( showDialog ) {
|
||||
BoolRegistryEntry( "showDialog" ).set();
|
||||
} else {
|
||||
BoolRegistryEntry( "showDialog" ).reset();
|
||||
}
|
||||
#ifdef DEBUG_law
|
||||
printf( "No, haveBeenSet=1 and showDialog=%d\n", (int)showDialog );
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
// User says: I dunno. Make no changes (which
|
||||
// should produce the same dialog next time).
|
||||
#ifdef DEBUG_law
|
||||
printf( "Cancel\n" );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_law
|
||||
else { printf( "Registry and prefs match\n" ); }
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG_law
|
||||
else { printf( "showDialog is false and not installing\n" ); }
|
||||
#endif
|
||||
|
||||
// Release the settings.
|
||||
settings->Release();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Utility to set PRBool registry value from getter method.
|
||||
nsresult putPRBoolIntoRegistry( const char* valueName,
|
||||
nsIWindowsHooksSettings *prefs,
|
||||
|
@ -195,6 +445,10 @@ nsWindowsHooks::SetSettings(nsIWindowsHooksSettings *prefs) {
|
|||
putPRBoolIntoRegistry( "isHandlingPNG", prefs, &nsIWindowsHooksSettings::GetIsHandlingPNG );
|
||||
putPRBoolIntoRegistry( "isHandlingXML", prefs, &nsIWindowsHooksSettings::GetIsHandlingXML );
|
||||
putPRBoolIntoRegistry( "isHandlingXUL", prefs, &nsIWindowsHooksSettings::GetIsHandlingXUL );
|
||||
putPRBoolIntoRegistry( "showDialog", prefs, &nsIWindowsHooksSettings::GetShowDialog );
|
||||
|
||||
// Indicate that these settings have indeed been set.
|
||||
BoolRegistryEntry( "haveBeenSet" ).set();
|
||||
|
||||
rv = SetRegistry();
|
||||
|
||||
|
@ -258,9 +512,9 @@ nsWindowsHooks::SetRegistry() {
|
|||
(void) ftp.reset();
|
||||
}
|
||||
if ( prefs->mHandleCHROME ) {
|
||||
(void) ftp.set();
|
||||
(void) chrome.set();
|
||||
} else {
|
||||
(void) ftp.reset();
|
||||
(void) chrome.reset();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -66,6 +66,15 @@ private:
|
|||
PRBool mHandleXML;
|
||||
PRBool mHandleXUL;
|
||||
};
|
||||
struct {
|
||||
PRBool mShowDialog;
|
||||
};
|
||||
// Special member to handle initialization.
|
||||
PRBool mHaveBeenSet;
|
||||
NS_IMETHOD GetHaveBeenSet( PRBool * );
|
||||
NS_IMETHOD SetHaveBeenSet( PRBool );
|
||||
|
||||
// Give nsWindowsHooks full access.
|
||||
friend class nsWindowsHooks;
|
||||
}; // nsWindowsHooksSettings
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
// Where Mozilla stores its own registry values.
|
||||
|
@ -32,7 +33,7 @@ static const char chromeSuffix[] = " -chrome \"%1\"";
|
|||
|
||||
// Returns the (fully-qualified) name of this executable.
|
||||
static nsCString thisApplication() {
|
||||
static nsCString result;
|
||||
static nsCAutoString result;
|
||||
|
||||
if ( result.IsEmpty() ) {
|
||||
char buffer[MAX_PATH] = { 0 };
|
||||
|
@ -121,7 +122,7 @@ struct ProtocolRegistryEntry : public SavedRegistryEntry {
|
|||
keyName += "\\shell\\open\\command";
|
||||
|
||||
// Append appropriate suffix to setting.
|
||||
if ( this->protocol.Equals( "chrome" ) ) {
|
||||
if ( this->protocol.Equals( "chrome" ) || this->protocol.Equals( "MozillaXUL" ) ) {
|
||||
// Use "-chrome" command line flag.
|
||||
setting += chromeSuffix;
|
||||
} else {
|
||||
|
@ -136,14 +137,31 @@ struct ProtocolRegistryEntry : public SavedRegistryEntry {
|
|||
// DDERegistryEntry
|
||||
//
|
||||
// Like a protocol registry entry, but for the shell\open\ddeexec subkey.
|
||||
// We don't need to do anything special for set/reset, either.
|
||||
//
|
||||
// set/reset handle setting/resetting various ddeexec sub-entries, also.
|
||||
struct DDERegistryEntry : public SavedRegistryEntry {
|
||||
DDERegistryEntry( const char *protocol )
|
||||
: SavedRegistryEntry( HKEY_LOCAL_MACHINE, "", "", thisApplication() ) {
|
||||
: SavedRegistryEntry( HKEY_LOCAL_MACHINE, "", "", "-url \"%1\"" ),
|
||||
app( HKEY_LOCAL_MACHINE, "", "", "Mozilla" ),
|
||||
topic( HKEY_LOCAL_MACHINE, "", "", "WWW_OpenURL" ) {
|
||||
// Derive keyName from protocol.
|
||||
keyName = "Software\\Classes\\";
|
||||
keyName += protocol;
|
||||
keyName += "\\shell\\open\\ddeexec";
|
||||
// Set subkey names.
|
||||
app.keyName = keyName;
|
||||
app.keyName += "\\Application";
|
||||
topic.keyName = keyName;
|
||||
topic.keyName += "\\Topic";
|
||||
// Use -chrome for some protocols, though.
|
||||
nsCAutoString strProtocol( protocol );
|
||||
if ( strProtocol.Equals( "chrome" ) || strProtocol.Equals( "MozillaXUL" ) ) {
|
||||
setting = "-chrome \"%1\"";
|
||||
}
|
||||
}
|
||||
nsresult set();
|
||||
nsresult reset();
|
||||
SavedRegistryEntry app, topic;
|
||||
};
|
||||
|
||||
// FileTypeRegistryEntry
|
||||
|
@ -198,7 +216,7 @@ nsCString RegistryEntry::fullName() const {
|
|||
PRBool RegistryEntry::isAlreadySet() const {
|
||||
PRBool result = FALSE;
|
||||
|
||||
nsCString current(currentSetting());
|
||||
nsCAutoString current( currentSetting() );
|
||||
|
||||
result = ( current == setting );
|
||||
|
||||
|
@ -247,7 +265,7 @@ NS_WARN_IF_FALSE( rc == ERROR_SUCCESS, (const char*)fullName() );
|
|||
// Get current setting, set new one, then save the previous.
|
||||
nsresult SavedRegistryEntry::set() {
|
||||
nsresult rv = NS_OK;
|
||||
nsCString prev(currentSetting());
|
||||
nsCAutoString prev( currentSetting() );
|
||||
// See if value is changing.
|
||||
if ( setting != prev ) {
|
||||
// Set new.
|
||||
|
@ -266,27 +284,21 @@ nsresult ProtocolRegistryEntry::set() {
|
|||
// Set this entry.
|
||||
nsresult rv = SavedRegistryEntry::set();
|
||||
|
||||
// Save and set corresponding DDE entry. This stops Windows from trying to use
|
||||
// DDE (and getting an error).
|
||||
nsCString ddeName("Software\\Classes\\");
|
||||
ddeName += protocol;
|
||||
ddeName += "\\shell\\open\\ddeexec";
|
||||
SavedRegistryEntry( HKEY_LOCAL_MACHINE, ddeName, NULL, NULL ).set();
|
||||
// Save and set corresponding DDE entry(ies).
|
||||
DDERegistryEntry( protocol ).set();
|
||||
|
||||
// Special case.
|
||||
if ( protocol.Equals( "http" ) ) {
|
||||
// We need to zap HKLM\Software\Classes\http\shell\open\ddeexec\Application
|
||||
// because Communicator looks there to determine whether they're the
|
||||
// "default browser." If they are (the value there is "NSShell" or "Netscape")
|
||||
// then it will reset lots of registry entries, "stealing" them from us.
|
||||
SavedRegistryEntry special( HKEY_LOCAL_MACHINE, "Software\\Classes\\http\\shell\\open\\ddeexec\\Application", NULL, NULL );
|
||||
nsCString specialVal(special.currentSetting());
|
||||
if ( specialVal.Equals( "NSShell" ) || specialVal.Equals( "Netscape" ) ) {
|
||||
// Reset this so Communicator will at least prompt the user.
|
||||
special.set();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Set ddexec values:
|
||||
// .../ddeexec -url "%1" / -chrome "%1"
|
||||
// /Application Mozilla
|
||||
// /Topic WWW_OpenURL
|
||||
nsresult DDERegistryEntry::set() {
|
||||
// Root (parameter to load url or chrome)
|
||||
nsresult rv = SavedRegistryEntry::set();
|
||||
rv = app.set();
|
||||
rv = topic.set();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -307,7 +319,7 @@ nsresult SavedRegistryEntry::reset() {
|
|||
nsresult result = NS_OK;
|
||||
|
||||
// Get current setting for this key/value.
|
||||
nsCString current(currentSetting());
|
||||
nsCAutoString current( currentSetting() );
|
||||
|
||||
// Test if we "own" it.
|
||||
if ( current == setting ) {
|
||||
|
@ -334,15 +346,17 @@ nsresult ProtocolRegistryEntry::reset() {
|
|||
// Restore this entry.
|
||||
nsresult rv = SavedRegistryEntry::reset();
|
||||
|
||||
// Do same for corresponding DDE entry (which we had to zap to stop DDE).
|
||||
// Do same for corresponding DDE entry.
|
||||
DDERegistryEntry( protocol ).reset();
|
||||
|
||||
// Special case.
|
||||
if ( protocol = "http" ) {
|
||||
// We had to zap HKLM\Software\Classes\http\shell\open\ddeexec\Application
|
||||
// (see comment above under ProtocolRegistryEntry::set). Restore it here.
|
||||
SavedRegistryEntry( HKEY_LOCAL_MACHINE, "Software\\Classes\\http\\shell\\open\\ddeexec\\Application", NULL, NULL ).reset();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Reset the main (ddeexec) value but also the Application and Topic.
|
||||
nsresult DDERegistryEntry::reset() {
|
||||
nsresult rv = SavedRegistryEntry::reset();
|
||||
rv = app.reset();
|
||||
rv = topic.reset();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -372,7 +386,7 @@ nsresult FileTypeRegistryEntry::set() {
|
|||
|
||||
// Set file extensions.
|
||||
for ( int i = 0; NS_SUCCEEDED( rv ) && ext[i]; i++ ) {
|
||||
nsCString thisExt("Software\\Classes\\");
|
||||
nsCAutoString thisExt( "Software\\Classes\\" );
|
||||
thisExt += ext[i];
|
||||
rv = SavedRegistryEntry( HKEY_LOCAL_MACHINE, thisExt, "", fileType ).set();
|
||||
}
|
||||
|
@ -383,18 +397,18 @@ nsresult FileTypeRegistryEntry::set() {
|
|||
|
||||
// If we just created this file type entry, set description and default icon.
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
nsCString descKey("Software\\Classes\\");
|
||||
nsCAutoString descKey( "Software\\Classes\\" );
|
||||
descKey += protocol;
|
||||
RegistryEntry descEntry( HKEY_LOCAL_MACHINE, descKey, NULL, desc );
|
||||
if ( descEntry.currentSetting().IsEmpty() ) {
|
||||
descEntry.set();
|
||||
}
|
||||
nsCString iconKey("Software\\Classes\\");
|
||||
nsCAutoString iconKey( "Software\\Classes\\" );
|
||||
iconKey += protocol;
|
||||
iconKey += "\\DefaultIcon";
|
||||
|
||||
RegistryEntry iconEntry( HKEY_LOCAL_MACHINE, iconKey, NULL,
|
||||
nsCAutoString( thisApplication() + NS_LITERAL_CSTRING(",1") ) );
|
||||
nsCAutoString( thisApplication() + NS_LITERAL_CSTRING(",0") ) );
|
||||
|
||||
if ( iconEntry.currentSetting().IsEmpty() ) {
|
||||
iconEntry.set();
|
||||
|
@ -412,7 +426,7 @@ nsresult FileTypeRegistryEntry::reset() {
|
|||
nsresult rv = ProtocolRegistryEntry::reset();
|
||||
|
||||
for ( int i = 0; ext[ i ]; i++ ) {
|
||||
nsCString thisExt("Software\\Classes\\");
|
||||
nsCAutoString thisExt( "Software\\Classes\\" );
|
||||
thisExt += ext[i];
|
||||
(void)SavedRegistryEntry( HKEY_LOCAL_MACHINE, thisExt, "", fileType ).reset();
|
||||
}
|
||||
|
@ -429,10 +443,10 @@ nsresult FileTypeRegistryEntry::reset() {
|
|||
nsresult EditableFileTypeRegistryEntry::set() {
|
||||
nsresult rv = FileTypeRegistryEntry::set();
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
nsCString editKey("Software\\Classes\\");
|
||||
nsCAutoString editKey( "Software\\Classes\\" );
|
||||
editKey += protocol;
|
||||
editKey += "\\shell\\edit\\command";
|
||||
nsCString editor(thisApplication());
|
||||
nsCAutoString editor( thisApplication() );
|
||||
editor += " -edit \"%1\"";
|
||||
rv = RegistryEntry( HKEY_LOCAL_MACHINE, editKey, "", editor ).set();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче