Fix bug 279982: remove "Use system homepage" and associated Internet Config code, other than the code to fetch the downloads folder. r=pinkerton

This commit is contained in:
smfr%smfr.org 2005-08-25 22:23:48 +00:00
Родитель a5bf7e7be2
Коммит f8776f4089
8 изменённых файлов: 56 добавлений и 207 удалений

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

@ -50,9 +50,37 @@
const int kDefaultExpireDays = 9;
// handly stack-based class to start and stop an Internet Config session
class StInternetConfigSession
{
public:
StInternetConfigSession(OSType inSignature)
: mICInstance(NULL)
, mStartedOK(false)
{
mStartedOK = (::ICStart(&mICInstance, inSignature) == noErr);
}
~StInternetConfigSession()
{
if (mStartedOK)
::ICStop(mICInstance);
}
bool Available() const { return mStartedOK; }
ICInstance Instance() const { return mICInstance; }
private:
ICInstance mICInstance;
bool mStartedOK;
};
@interface OrgMozillaChimeraPreferenceDownloads(Private)
- (NSString*)getInternetConfigString:(ConstStr255Param)icPref;
- (NSString*)getDownloadFolderDescription;
- (void)setupDownloadMenuWithPath:(NSString*)inDLPath;
- (void)setDownloadFolder:(NSString*)inNewFolder;
@ -132,8 +160,8 @@ const int kDefaultExpireDays = 9;
return [NSString stringWithUTF8String:(const char*)utf8path];
}
// Sets the IC download pref to the given path
// NOTE: THIS DOES NOT WORK.
// Sets the IC download pref to the given path. We write to Internet Config
// because Gecko reads from IC when getting NS_MAC_DEFAULT_DOWNLOAD_DIR.
- (void)setDownloadFolder:(NSString*)inNewFolder
{
if (!inNewFolder)
@ -141,68 +169,38 @@ const int kDefaultExpireDays = 9;
// it would be nice to use PreferenceManager, but I don't want to drag
// all that code into the plugin
ICInstance icInstance = nil;
OSStatus error = ::ICStart(&icInstance, 'CHIM');
if (error != noErr)
StInternetConfigSession icSession('CHIM');
if (!icSession.Available())
return;
// make a ICFileSpec out of our path and shove it into IC. This requires
// creating an FSSpec and an alias. We can't just bail on error because
// we have to make sure we call ICStop() below.
BOOL noErrors = NO;
// creating an FSSpec and an alias.
FSRef fsRef;
Boolean isDir;
AliasHandle alias = nil;
OSStatus error = ::FSPathMakeRef((UInt8 *)[inNewFolder fileSystemRepresentation], &fsRef, &isDir);
if (error != noErr)
return;
FSSpec fsSpec;
error = ::FSPathMakeRef((UInt8 *)[inNewFolder fileSystemRepresentation], &fsRef, &isDir);
if (!error) {
error = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNone, nil, nil, &fsSpec, nil);
if (!error) {
error = ::FSNewAlias(nil, &fsRef, &alias);
if (!error)
noErrors = YES;
}
}
error = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNone, nil, nil, &fsSpec, nil);
if (error != noErr)
return;
AliasHandle alias = nil;
error = ::FSNewAlias(nil, &fsRef, &alias);
// copy the data out of our variables into the ICFileSpec and hand it to IC.
if (noErrors) {
if (error == noErr && alias)
{
long headerSize = offsetof(ICFileSpec, alias);
long aliasSize = ::GetHandleSize((Handle)alias);
ICFileSpec* realbuffer = (ICFileSpec*) calloc(headerSize + aliasSize, 1);
realbuffer->fss = fsSpec;
memcpy(&realbuffer->alias, *alias, aliasSize);
::ICSetPref(icInstance, kICDownloadFolder, kICAttrNoChange, (const void*)realbuffer, headerSize + aliasSize);
::ICSetPref(icSession.Instance(), kICDownloadFolder, kICAttrNoChange, (const void*)realbuffer, headerSize + aliasSize);
free(realbuffer);
::DisposeHandle((Handle)alias);
}
::ICStop(icInstance);
}
- (NSString*)getInternetConfigString:(ConstStr255Param)icPref
{
NSString* resultString = @"";
ICInstance icInstance = NULL;
// it would be nice to use PreferenceManager, but I don't want to drag
// all that code into the plugin
OSStatus error = ICStart(&icInstance, 'CHIM');
if (error != noErr) {
NSLog(@"Error from ICStart");
return resultString;
}
ICAttr dummyAttr;
Str255 homePagePStr;
long prefSize = sizeof(homePagePStr);
error = ICGetPref(icInstance, icPref, &dummyAttr, homePagePStr, &prefSize);
if (error == noErr)
resultString = [NSString stringWithCString: (const char*)&homePagePStr[1] length:homePagePStr[0]];
else
NSLog(@"Error getting pref from Internet Config");
ICStop(icInstance);
return resultString;
}
// Given a full path to the d/l dir, display the leaf name and the finder icon associated

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

@ -13,17 +13,12 @@
SUPERCLASS = NSObject;
},
{
ACTIONS = {
checkboxStartPageClicked = id;
checkboxUseSystemHomePageClicked = id;
defaultBrowserChange = id;
};
ACTIONS = {checkboxStartPageClicked = id; defaultBrowserChange = id; };
CLASS = OrgMozillaChimeraPreferenceNavigation;
LANGUAGE = ObjC;
OUTLETS = {
checkboxNewTabBlank = NSButton;
checkboxNewWindowBlank = NSButton;
checkboxUseSystemHomePage = NSButton;
defaultBrowserPopUp = NSPopUpButton;
textFieldHomePage = NSTextField;
};

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

@ -5,8 +5,8 @@
<key>IBDocumentLocation</key>
<string>257 70 522 320 0 0 1920 1178 </string>
<key>IBFramework Version</key>
<string>364.0</string>
<string>437.0</string>
<key>IBSystem Version</key>
<string>7W98</string>
<string>8C46</string>
</dict>
</plist>

Двоичные данные
camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/keyedobjects.nib сгенерированный

Двоичный файл не отображается.

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

@ -43,13 +43,11 @@
{
IBOutlet NSTextField *textFieldHomePage;
IBOutlet NSButton *checkboxUseSystemHomePage;
IBOutlet NSButton *checkboxNewTabBlank;
IBOutlet NSButton *checkboxNewWindowBlank;
IBOutlet NSPopUpButton *defaultBrowserPopUp;
}
- (IBAction)checkboxUseSystemHomePageClicked:(id)sender;
- (IBAction)checkboxStartPageClicked:(id)sender;
- (IBAction)defaultBrowserChange:(id)sender;

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

@ -72,8 +72,6 @@ extern "C" {
@interface OrgMozillaChimeraPreferenceNavigation(Private)
- (NSString*)getInternetConfigString:(ConstStr255Param)icPref;
- (NSString*)getSystemHomePage;
- (NSString*)getCurrentHomePage;
+ (NSArray*)getWebBrowserList;
+ (NSString*)displayNameForURL:(NSURL*)url;
@ -149,11 +147,6 @@ int compareBundleIDAppDisplayNames(id a, id b, void *context)
if (([self getIntPref:"browser.tabs.startPage" withSuccess:&gotPref] == 1))
[checkboxNewTabBlank setState:YES];
BOOL useSystemHomePage = [self getBooleanPref:"chimera.use_system_home_page" withSuccess:&gotPref] && gotPref;
if (useSystemHomePage)
[textFieldHomePage setEnabled:NO];
[checkboxUseSystemHomePage setState:useSystemHomePage];
[textFieldHomePage setStringValue:[self getCurrentHomePage]];
// set up default browser menu
@ -165,30 +158,11 @@ int compareBundleIDAppDisplayNames(id a, id b, void *context)
if (!mPrefService)
return;
// only save the home page pref if it's not the system one
if (![checkboxUseSystemHomePage state])
[self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]];
[self setPref:"browser.startup.homepage" toString:[textFieldHomePage stringValue]];
// ensure that the prefs exist
[self setPref:"browser.startup.page" toInt: [checkboxNewWindowBlank state] ? 1 : 0];
[self setPref:"browser.tabs.startPage" toInt: [checkboxNewTabBlank state] ? 1 : 0];
}
- (IBAction)checkboxUseSystemHomePageClicked:(id)sender
{
if (!mPrefService)
return;
BOOL useSystemHomePage = [sender state];
// save the mozilla pref
if (useSystemHomePage)
[self setPref:"browser.startup.homepage" toString:[textFieldHomePage stringValue]];
[self setPref:"chimera.use_system_home_page" toBoolean:useSystemHomePage];
[textFieldHomePage setStringValue:[self getCurrentHomePage]];
[textFieldHomePage setEnabled:!useSystemHomePage];
[self setPref:"browser.startup.page" toInt:[checkboxNewWindowBlank state] ? 1 : 0];
[self setPref:"browser.tabs.startPage" toInt:[checkboxNewTabBlank state] ? 1 : 0];
}
- (IBAction)checkboxStartPageClicked:(id)sender
@ -206,45 +180,10 @@ int compareBundleIDAppDisplayNames(id a, id b, void *context)
[self setPref:prefName toInt: [sender state] ? 1 : 0];
}
- (NSString*)getInternetConfigString:(ConstStr255Param)icPref
{
NSString* resultString = @"";
ICInstance icInstance = NULL;
// it would be nice to use PreferenceManager, but I don't want to drag
// all that code into the plugin
OSStatus error = ICStart(&icInstance, 'CHIM');
if (error != noErr) {
NSLog(@"Error from ICStart");
return resultString;
}
ICAttr dummyAttr;
Str255 homePagePStr;
long prefSize = sizeof(homePagePStr);
error = ICGetPref(icInstance, icPref, &dummyAttr, homePagePStr, &prefSize);
if (error == noErr)
resultString = [NSString stringWithCString:(const char*)&homePagePStr[1] length:homePagePStr[0]];
else
NSLog(@"Error getting pref from Internet Config");
ICStop(icInstance);
return resultString;
}
- (NSString*) getSystemHomePage
{
return [self getInternetConfigString:kICWWWHomePage];
}
- (NSString*) getCurrentHomePage
{
BOOL gotPref;
if ([self getBooleanPref:"chimera.use_system_home_page" withSuccess:&gotPref] && gotPref)
return [self getSystemHomePage];
return [self getStringPref:"browser.startup.homepage" withSuccess:&gotPref];
}

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

@ -45,7 +45,6 @@ class nsIPref;
{
@private
NSUserDefaults* mDefaults;
ICInstance mInternetConfig;
nsProfileDirServiceProvider* mProfileProvider;
nsIPref* mPrefs;
long mLastRunPrefsVersion;
@ -58,12 +57,10 @@ class nsIPref;
- (id) init;
- (void) dealloc;
- (BOOL) initInternetConfig;
- (BOOL) initMozillaPrefs;
- (void) syncMozillaPrefs;
- (void) savePrefsFile;
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
- (NSString *) homePage:(BOOL) checkStartupPagePref;
- (NSString *) searchPage;

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

@ -142,11 +142,6 @@ static BOOL gMadePrefManager;
[self registerNotificationListener];
if ([self initInternetConfig] == NO) {
// XXXw. throw here
NSLog (@"Failed to initialize Internet Config");
}
if ([self initMozillaPrefs] == NO) {
// XXXw. throw here too
NSLog (@"Failed to initialize mozilla prefs");
@ -167,8 +162,6 @@ static BOOL gMadePrefManager;
- (void)termEmbedding: (NSNotification*)aNotification
{
::ICStop(mInternetConfig);
mInternetConfig = nil;
NS_IF_RELEASE(mPrefs);
// remove our runloop observer
if (mRunLoopSource)
@ -221,18 +214,6 @@ static BOOL gMadePrefManager;
prefsService->SavePrefFile(nsnull);
}
- (BOOL)initInternetConfig
{
OSStatus error;
error = ::ICStart(&mInternetConfig, 'CHIM');
if (error != noErr) {
// XXX throw here?
NSLog(@"Error initializing IC");
return NO;
}
return YES;
}
- (BOOL)initMozillaPrefs
{
nsresult rv;
@ -782,53 +763,6 @@ typedef enum EProxyConfig {
(void)mPrefs->SetBoolPref(prefName, (PRBool)value);
}
//- (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
//{
// ICAttr dummy;
// OSStatus error;
// SInt32 size;
// Boolean buf;
// error = ICGetPref (internetConfig, prefKey, &dummy, &buf, &size);
// if (error == noErr && buf)
// return YES;
// else
// return NO;
// }
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
{
NSString *string;
ICAttr dummy;
OSStatus error;
SInt32 size = 256;
char *buf;
do {
if ((buf = (char*)malloc((unsigned int)size)) == NULL) {
return nil;
}
error = ICGetPref (mInternetConfig, prefKey, &dummy, buf, &size);
if (error != noErr && error != icTruncatedErr) {
free (buf);
NSLog (@"[IC error %d in [PreferenceManager getICStringPref]", (int) error);
return nil;
}
size *= 2;
} while (error == icTruncatedErr);
if (*buf == 0) {
NSLog (@"ICGetPref returned empty string");
free (buf);
return nil;
}
CopyPascalStringToC ((ConstStr255Param) buf, buf);
string = [NSString stringWithCString:buf];
free(buf);
return string;
}
- (NSString *) homePage:(BOOL)checkStartupPagePref
{
if (!mPrefs)
@ -842,18 +776,10 @@ typedef enum EProxyConfig {
// but we don't care about that. Default to 1 unless |checkStartupPagePref|
// is true.
nsresult rv = NS_OK;
if ( checkStartupPagePref )
if (checkStartupPagePref)
rv = mPrefs->GetIntPref("browser.startup.page", &mode);
if (NS_FAILED(rv) || mode == 1) {
// see which home page to use
PRBool boolPref;
if (NS_SUCCEEDED(mPrefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref) {
NSString* homePage = [self getICStringPref:kICWWWHomePage];
if (!homePage)
homePage = @"about:blank";
return homePage;
}
if (NS_FAILED(rv) || mode == 1) {
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mPrefs);
if (!prefBranch) return @"about:blank";
@ -884,10 +810,6 @@ typedef enum EProxyConfig {
if (!mPrefs)
return resultString;
PRBool boolPref;
if (NS_SUCCEEDED(mPrefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
return [self getICStringPref:kICWebSearchPagePrefs];
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(mPrefs);
if (!prefBranch)
return resultString;