зеркало из https://github.com/mozilla/gecko-dev.git
Changing the home page behaviour. Now, if no user pref is set, we get the default home page from a .strings file, and set this in the user pref. Also using values from CHUserDefaults.h
This commit is contained in:
Родитель
f94048cccf
Коммит
afb901e71b
|
@ -39,8 +39,8 @@
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
@interface CHPreferenceManager : NSObject {
|
@interface CHPreferenceManager : NSObject {
|
||||||
NSUserDefaults *defaults;
|
NSUserDefaults* mDefaults;
|
||||||
ICInstance internetConfig;
|
ICInstance mInternetConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CHPreferenceManager *)sharedInstance;
|
+ (CHPreferenceManager *)sharedInstance;
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
- (BOOL) initInternetConfig;
|
- (BOOL) initInternetConfig;
|
||||||
- (BOOL) initMozillaPrefs;
|
- (BOOL) initMozillaPrefs;
|
||||||
- (void) syncMozillaPrefs;
|
- (void) syncMozillaPrefs;
|
||||||
// - (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
|
|
||||||
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
||||||
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,16 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#import <SystemConfiguration/SystemConfiguration.h>
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
#import "CHPreferenceManager.h"
|
#import "CHPreferenceManager.h"
|
||||||
|
#import "CHUserDefaults.h"
|
||||||
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIProfile.h"
|
#include "nsIProfile.h"
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
|
#include "nsIPrefBranch.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsEmbedAPI.h"
|
#include "nsEmbedAPI.h"
|
||||||
#include "AppDirServiceProvider.h"
|
#include "AppDirServiceProvider.h"
|
||||||
|
@ -74,6 +78,8 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
// XXXw. throw here too
|
// XXXw. throw here too
|
||||||
NSLog (@"Failed to initialize mozilla prefs.\n");
|
NSLog (@"Failed to initialize mozilla prefs.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +87,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
ICStop (internetConfig);
|
ICStop (mInternetConfig);
|
||||||
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||||
if (!NS_FAILED(rv))
|
if (!NS_FAILED(rv))
|
||||||
pref->SavePrefFile(nsnull);
|
pref->SavePrefFile(nsnull);
|
||||||
|
@ -91,7 +97,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (BOOL) initInternetConfig
|
- (BOOL) initInternetConfig
|
||||||
{
|
{
|
||||||
OSStatus error;
|
OSStatus error;
|
||||||
error = ICStart (&internetConfig, 'CHIM');
|
error = ICStart (&mInternetConfig, 'CHIM');
|
||||||
if (error != noErr) {
|
if (error != noErr) {
|
||||||
// XXX throw here?
|
// XXX throw here?
|
||||||
NSLog(@"Error initializing IC.\n");
|
NSLog(@"Error initializing IC.\n");
|
||||||
|
@ -350,7 +356,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
error = ICGetPref (internetConfig, prefKey, &dummy, buf, &size);
|
error = ICGetPref (mInternetConfig, prefKey, &dummy, buf, &size);
|
||||||
if (error != noErr && error != icTruncatedErr) {
|
if (error != noErr && error != icTruncatedErr) {
|
||||||
free (buf);
|
free (buf);
|
||||||
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
||||||
|
@ -392,8 +398,23 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
||||||
return [self getICStringPref:kICWWWHomePage];
|
return [self getICStringPref:kICWWWHomePage];
|
||||||
|
|
||||||
NSString* homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil );
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs);
|
||||||
if ([homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
if (!prefBranch) return @"about:blank";
|
||||||
|
|
||||||
|
NSString* homepagePref = nil;
|
||||||
|
PRInt32 haveUserPref;
|
||||||
|
if (NS_FAILED(prefBranch->PrefHasUserValue("browser.startup.homepage", &haveUserPref)) || !haveUserPref) {
|
||||||
|
// no home page pref is set in user prefs.
|
||||||
|
homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil);
|
||||||
|
// and let's copy this into the homepage pref if it's not bad
|
||||||
|
if (![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
|
prefs->SetCharPref("browser.startup.homepage", [homepagePref cString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (homepagePref && [homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
return homepagePref;
|
return homepagePref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
@interface CHPreferenceManager : NSObject {
|
@interface CHPreferenceManager : NSObject {
|
||||||
NSUserDefaults *defaults;
|
NSUserDefaults* mDefaults;
|
||||||
ICInstance internetConfig;
|
ICInstance mInternetConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CHPreferenceManager *)sharedInstance;
|
+ (CHPreferenceManager *)sharedInstance;
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
- (BOOL) initInternetConfig;
|
- (BOOL) initInternetConfig;
|
||||||
- (BOOL) initMozillaPrefs;
|
- (BOOL) initMozillaPrefs;
|
||||||
- (void) syncMozillaPrefs;
|
- (void) syncMozillaPrefs;
|
||||||
// - (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
|
|
||||||
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
||||||
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,16 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#import <SystemConfiguration/SystemConfiguration.h>
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
#import "CHPreferenceManager.h"
|
#import "CHPreferenceManager.h"
|
||||||
|
#import "CHUserDefaults.h"
|
||||||
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIProfile.h"
|
#include "nsIProfile.h"
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
|
#include "nsIPrefBranch.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsEmbedAPI.h"
|
#include "nsEmbedAPI.h"
|
||||||
#include "AppDirServiceProvider.h"
|
#include "AppDirServiceProvider.h"
|
||||||
|
@ -74,6 +78,8 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
// XXXw. throw here too
|
// XXXw. throw here too
|
||||||
NSLog (@"Failed to initialize mozilla prefs.\n");
|
NSLog (@"Failed to initialize mozilla prefs.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +87,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
ICStop (internetConfig);
|
ICStop (mInternetConfig);
|
||||||
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||||
if (!NS_FAILED(rv))
|
if (!NS_FAILED(rv))
|
||||||
pref->SavePrefFile(nsnull);
|
pref->SavePrefFile(nsnull);
|
||||||
|
@ -91,7 +97,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (BOOL) initInternetConfig
|
- (BOOL) initInternetConfig
|
||||||
{
|
{
|
||||||
OSStatus error;
|
OSStatus error;
|
||||||
error = ICStart (&internetConfig, 'CHIM');
|
error = ICStart (&mInternetConfig, 'CHIM');
|
||||||
if (error != noErr) {
|
if (error != noErr) {
|
||||||
// XXX throw here?
|
// XXX throw here?
|
||||||
NSLog(@"Error initializing IC.\n");
|
NSLog(@"Error initializing IC.\n");
|
||||||
|
@ -350,7 +356,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
error = ICGetPref (internetConfig, prefKey, &dummy, buf, &size);
|
error = ICGetPref (mInternetConfig, prefKey, &dummy, buf, &size);
|
||||||
if (error != noErr && error != icTruncatedErr) {
|
if (error != noErr && error != icTruncatedErr) {
|
||||||
free (buf);
|
free (buf);
|
||||||
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
||||||
|
@ -392,8 +398,23 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
||||||
return [self getICStringPref:kICWWWHomePage];
|
return [self getICStringPref:kICWWWHomePage];
|
||||||
|
|
||||||
NSString* homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil );
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs);
|
||||||
if ([homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
if (!prefBranch) return @"about:blank";
|
||||||
|
|
||||||
|
NSString* homepagePref = nil;
|
||||||
|
PRInt32 haveUserPref;
|
||||||
|
if (NS_FAILED(prefBranch->PrefHasUserValue("browser.startup.homepage", &haveUserPref)) || !haveUserPref) {
|
||||||
|
// no home page pref is set in user prefs.
|
||||||
|
homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil);
|
||||||
|
// and let's copy this into the homepage pref if it's not bad
|
||||||
|
if (![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
|
prefs->SetCharPref("browser.startup.homepage", [homepagePref cString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (homepagePref && [homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
return homepagePref;
|
return homepagePref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
@interface CHPreferenceManager : NSObject {
|
@interface CHPreferenceManager : NSObject {
|
||||||
NSUserDefaults *defaults;
|
NSUserDefaults* mDefaults;
|
||||||
ICInstance internetConfig;
|
ICInstance mInternetConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CHPreferenceManager *)sharedInstance;
|
+ (CHPreferenceManager *)sharedInstance;
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
- (BOOL) initInternetConfig;
|
- (BOOL) initInternetConfig;
|
||||||
- (BOOL) initMozillaPrefs;
|
- (BOOL) initMozillaPrefs;
|
||||||
- (void) syncMozillaPrefs;
|
- (void) syncMozillaPrefs;
|
||||||
// - (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
|
|
||||||
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
||||||
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,16 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#import <SystemConfiguration/SystemConfiguration.h>
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
#import "CHPreferenceManager.h"
|
#import "CHPreferenceManager.h"
|
||||||
|
#import "CHUserDefaults.h"
|
||||||
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIProfile.h"
|
#include "nsIProfile.h"
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
|
#include "nsIPrefBranch.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsEmbedAPI.h"
|
#include "nsEmbedAPI.h"
|
||||||
#include "AppDirServiceProvider.h"
|
#include "AppDirServiceProvider.h"
|
||||||
|
@ -74,6 +78,8 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
// XXXw. throw here too
|
// XXXw. throw here too
|
||||||
NSLog (@"Failed to initialize mozilla prefs.\n");
|
NSLog (@"Failed to initialize mozilla prefs.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +87,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
ICStop (internetConfig);
|
ICStop (mInternetConfig);
|
||||||
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||||
if (!NS_FAILED(rv))
|
if (!NS_FAILED(rv))
|
||||||
pref->SavePrefFile(nsnull);
|
pref->SavePrefFile(nsnull);
|
||||||
|
@ -91,7 +97,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (BOOL) initInternetConfig
|
- (BOOL) initInternetConfig
|
||||||
{
|
{
|
||||||
OSStatus error;
|
OSStatus error;
|
||||||
error = ICStart (&internetConfig, 'CHIM');
|
error = ICStart (&mInternetConfig, 'CHIM');
|
||||||
if (error != noErr) {
|
if (error != noErr) {
|
||||||
// XXX throw here?
|
// XXX throw here?
|
||||||
NSLog(@"Error initializing IC.\n");
|
NSLog(@"Error initializing IC.\n");
|
||||||
|
@ -350,7 +356,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
error = ICGetPref (internetConfig, prefKey, &dummy, buf, &size);
|
error = ICGetPref (mInternetConfig, prefKey, &dummy, buf, &size);
|
||||||
if (error != noErr && error != icTruncatedErr) {
|
if (error != noErr && error != icTruncatedErr) {
|
||||||
free (buf);
|
free (buf);
|
||||||
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
||||||
|
@ -392,8 +398,23 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
||||||
return [self getICStringPref:kICWWWHomePage];
|
return [self getICStringPref:kICWWWHomePage];
|
||||||
|
|
||||||
NSString* homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil );
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs);
|
||||||
if ([homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
if (!prefBranch) return @"about:blank";
|
||||||
|
|
||||||
|
NSString* homepagePref = nil;
|
||||||
|
PRInt32 haveUserPref;
|
||||||
|
if (NS_FAILED(prefBranch->PrefHasUserValue("browser.startup.homepage", &haveUserPref)) || !haveUserPref) {
|
||||||
|
// no home page pref is set in user prefs.
|
||||||
|
homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil);
|
||||||
|
// and let's copy this into the homepage pref if it's not bad
|
||||||
|
if (![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
|
prefs->SetCharPref("browser.startup.homepage", [homepagePref cString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (homepagePref && [homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
return homepagePref;
|
return homepagePref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
|
|
||||||
@interface CHPreferenceManager : NSObject {
|
@interface CHPreferenceManager : NSObject {
|
||||||
NSUserDefaults *defaults;
|
NSUserDefaults* mDefaults;
|
||||||
ICInstance internetConfig;
|
ICInstance mInternetConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CHPreferenceManager *)sharedInstance;
|
+ (CHPreferenceManager *)sharedInstance;
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
- (BOOL) initInternetConfig;
|
- (BOOL) initInternetConfig;
|
||||||
- (BOOL) initMozillaPrefs;
|
- (BOOL) initMozillaPrefs;
|
||||||
- (void) syncMozillaPrefs;
|
- (void) syncMozillaPrefs;
|
||||||
// - (BOOL) getICBoolPref:(ConstStr255Param) prefKey;
|
|
||||||
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
- (NSString *) getICStringPref:(ConstStr255Param) prefKey;
|
||||||
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
- (NSString *) homePage:(BOOL) checkStartupPagePref;
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,16 @@
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#import <SystemConfiguration/SystemConfiguration.h>
|
#import <SystemConfiguration/SystemConfiguration.h>
|
||||||
#import "CHPreferenceManager.h"
|
#import "CHPreferenceManager.h"
|
||||||
|
#import "CHUserDefaults.h"
|
||||||
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIProfile.h"
|
#include "nsIProfile.h"
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
|
#include "nsIPrefBranch.h"
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsEmbedAPI.h"
|
#include "nsEmbedAPI.h"
|
||||||
#include "AppDirServiceProvider.h"
|
#include "AppDirServiceProvider.h"
|
||||||
|
@ -74,6 +78,8 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
// XXXw. throw here too
|
// XXXw. throw here too
|
||||||
NSLog (@"Failed to initialize mozilla prefs.\n");
|
NSLog (@"Failed to initialize mozilla prefs.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDefaults = [NSUserDefaults standardUserDefaults];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +87,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
ICStop (internetConfig);
|
ICStop (mInternetConfig);
|
||||||
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
nsCOMPtr<nsIPrefService> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||||
if (!NS_FAILED(rv))
|
if (!NS_FAILED(rv))
|
||||||
pref->SavePrefFile(nsnull);
|
pref->SavePrefFile(nsnull);
|
||||||
|
@ -91,7 +97,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
- (BOOL) initInternetConfig
|
- (BOOL) initInternetConfig
|
||||||
{
|
{
|
||||||
OSStatus error;
|
OSStatus error;
|
||||||
error = ICStart (&internetConfig, 'CHIM');
|
error = ICStart (&mInternetConfig, 'CHIM');
|
||||||
if (error != noErr) {
|
if (error != noErr) {
|
||||||
// XXX throw here?
|
// XXX throw here?
|
||||||
NSLog(@"Error initializing IC.\n");
|
NSLog(@"Error initializing IC.\n");
|
||||||
|
@ -350,7 +356,7 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
NSLog (@"malloc failed in [PreferenceManager getICStringPref].");
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
error = ICGetPref (internetConfig, prefKey, &dummy, buf, &size);
|
error = ICGetPref (mInternetConfig, prefKey, &dummy, buf, &size);
|
||||||
if (error != noErr && error != icTruncatedErr) {
|
if (error != noErr && error != icTruncatedErr) {
|
||||||
free (buf);
|
free (buf);
|
||||||
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
NSLog (@"[IC error %d in [PreferenceManager getICStringPref].\n", (int) error);
|
||||||
|
@ -392,8 +398,23 @@ app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||||
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
if (NS_SUCCEEDED(prefs->GetBoolPref("chimera.use_system_home_page", &boolPref)) && boolPref)
|
||||||
return [self getICStringPref:kICWWWHomePage];
|
return [self getICStringPref:kICWWWHomePage];
|
||||||
|
|
||||||
NSString* homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil );
|
nsCOMPtr<nsIPrefBranch> prefBranch = do_QueryInterface(prefs);
|
||||||
if ([homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
if (!prefBranch) return @"about:blank";
|
||||||
|
|
||||||
|
NSString* homepagePref = nil;
|
||||||
|
PRInt32 haveUserPref;
|
||||||
|
if (NS_FAILED(prefBranch->PrefHasUserValue("browser.startup.homepage", &haveUserPref)) || !haveUserPref) {
|
||||||
|
// no home page pref is set in user prefs.
|
||||||
|
homepagePref = NSLocalizedStringFromTable( @"HomePageDefault", @"WebsiteDefaults", nil);
|
||||||
|
// and let's copy this into the homepage pref if it's not bad
|
||||||
|
if (![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
|
prefs->SetCharPref("browser.startup.homepage", [homepagePref cString]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
homepagePref = [self getMozillaPrefString:"browser.startup.homepage"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (homepagePref && [homepagePref length] > 0 && ![homepagePref isEqualToString:@"HomePageDefault"])
|
||||||
return homepagePref;
|
return homepagePref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче