Camino only - Bug 411071: De-gecko-ize Privacy preference pane. Also clean up missed bits from the Security pane de-gecko-ization. r/sr=mento

This commit is contained in:
stuart.morgan%alumni.case.edu 2008-01-07 21:32:17 +00:00
Родитель fa62546309
Коммит 2f08f956c5
8 изменённых файлов: 439 добавлений и 476 удалений

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

@ -294,6 +294,10 @@
33C222870D106CDD00611936 /* PreferencesWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 33C222850D106CDD00611936 /* PreferencesWindow.m */; }; 33C222870D106CDD00611936 /* PreferencesWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 33C222850D106CDD00611936 /* PreferencesWindow.m */; };
33C222880D106CDD00611936 /* PreferencesWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 33C222840D106CDD00611936 /* PreferencesWindow.h */; }; 33C222880D106CDD00611936 /* PreferencesWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 33C222840D106CDD00611936 /* PreferencesWindow.h */; };
33C222890D106CDD00611936 /* PreferencesWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 33C222850D106CDD00611936 /* PreferencesWindow.m */; }; 33C222890D106CDD00611936 /* PreferencesWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 33C222850D106CDD00611936 /* PreferencesWindow.m */; };
33E95A770D31B6FA0054C01D /* CHCookieStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 33E95A750D31B6FA0054C01D /* CHCookieStorage.h */; };
33E95A780D31B6FA0054C01D /* CHCookieStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33E95A760D31B6FA0054C01D /* CHCookieStorage.mm */; };
33E95A790D31B6FA0054C01D /* CHCookieStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 33E95A750D31B6FA0054C01D /* CHCookieStorage.h */; };
33E95A7A0D31B6FA0054C01D /* CHCookieStorage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33E95A760D31B6FA0054C01D /* CHCookieStorage.mm */; };
33F3B70B0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */; }; 33F3B70B0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */; };
33F3B70C0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */; }; 33F3B70C0C63F5F7007DFBD0 /* ScriptingSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */; };
33FBAAF80C84D0AB00DD459E /* NSString+Gecko.h in Headers */ = {isa = PBXBuildFile; fileRef = 33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */; }; 33FBAAF80C84D0AB00DD459E /* NSString+Gecko.h in Headers */ = {isa = PBXBuildFile; fileRef = 33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */; };
@ -1108,7 +1112,6 @@
4D2996690869C5FA00E84287 /* libplds4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F6BD638201B30EA301A962F7 /* libplds4.dylib */; }; 4D2996690869C5FA00E84287 /* libplds4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F6BD638201B30EA301A962F7 /* libplds4.dylib */; };
4D29966A0869C5FA00E84287 /* libxpcom.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F57F0F470209DF5301A967DF /* libxpcom.dylib */; }; 4D29966A0869C5FA00E84287 /* libxpcom.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F57F0F470209DF5301A967DF /* libxpcom.dylib */; };
4D29966B0869C5FA00E84287 /* libxpcom_core.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F12FC56072E8ECB00995ED9 /* libxpcom_core.dylib */; }; 4D29966B0869C5FA00E84287 /* libxpcom_core.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F12FC56072E8ECB00995ED9 /* libxpcom_core.dylib */; };
4D29989F0869CA5200E84287 /* libxpcom_core.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F12FC56072E8ECB00995ED9 /* libxpcom_core.dylib */; };
4D5881770864B28D001305B3 /* Default Plugin.plugin in Copy Gecko Plugins */ = {isa = PBXBuildFile; fileRef = F56610BC0394775201A9666E /* Default Plugin.plugin */; }; 4D5881770864B28D001305B3 /* Default Plugin.plugin in Copy Gecko Plugins */ = {isa = PBXBuildFile; fileRef = F56610BC0394775201A9666E /* Default Plugin.plugin */; };
4D58817B0864B2AE001305B3 /* Default Plugin.plugin in Copy Gecko Plugins */ = {isa = PBXBuildFile; fileRef = F56610BC0394775201A9666E /* Default Plugin.plugin */; }; 4D58817B0864B2AE001305B3 /* Default Plugin.plugin in Copy Gecko Plugins */ = {isa = PBXBuildFile; fileRef = F56610BC0394775201A9666E /* Default Plugin.plugin */; };
4DC28F5E099184B80081939B /* libucvmath.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DC28F5D099184B80081939B /* libucvmath.a */; }; 4DC28F5E099184B80081939B /* libucvmath.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DC28F5D099184B80081939B /* libucvmath.a */; };
@ -2483,6 +2486,8 @@
33B778800C55C57800A6D67F /* libnssdbm3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libnssdbm3.dylib; path = ../dist/lib/libnssdbm3.dylib; sourceTree = SOURCE_ROOT; }; 33B778800C55C57800A6D67F /* libnssdbm3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libnssdbm3.dylib; path = ../dist/lib/libnssdbm3.dylib; sourceTree = SOURCE_ROOT; };
33C222840D106CDD00611936 /* PreferencesWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesWindow.h; sourceTree = "<group>"; }; 33C222840D106CDD00611936 /* PreferencesWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreferencesWindow.h; sourceTree = "<group>"; };
33C222850D106CDD00611936 /* PreferencesWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindow.m; sourceTree = "<group>"; }; 33C222850D106CDD00611936 /* PreferencesWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PreferencesWindow.m; sourceTree = "<group>"; };
33E95A750D31B6FA0054C01D /* CHCookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CHCookieStorage.h; path = src/embedding/CHCookieStorage.h; sourceTree = "<group>"; };
33E95A760D31B6FA0054C01D /* CHCookieStorage.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = CHCookieStorage.mm; path = src/embedding/CHCookieStorage.mm; sourceTree = "<group>"; };
33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = ScriptingSupport.mm; path = src/appleevents/ScriptingSupport.mm; sourceTree = "<group>"; }; 33F3B70A0C63F5F7007DFBD0 /* ScriptingSupport.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = ScriptingSupport.mm; path = src/appleevents/ScriptingSupport.mm; sourceTree = "<group>"; };
33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSString+Gecko.h"; path = "src/extensions/NSString+Gecko.h"; sourceTree = "<group>"; }; 33FBAAF30C84D0A500DD459E /* NSString+Gecko.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "NSString+Gecko.h"; path = "src/extensions/NSString+Gecko.h"; sourceTree = "<group>"; };
33FBAAFA0C84D0CA00DD459E /* NSString+Gecko.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = "NSString+Gecko.mm"; path = "src/extensions/NSString+Gecko.mm"; sourceTree = "<group>"; }; 33FBAAFA0C84D0CA00DD459E /* NSString+Gecko.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = "NSString+Gecko.mm"; path = "src/extensions/NSString+Gecko.mm"; sourceTree = "<group>"; };
@ -3138,7 +3143,6 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
3F44ADD005BDFBA000CB4B08 /* Cocoa.framework in Frameworks */, 3F44ADD005BDFBA000CB4B08 /* Cocoa.framework in Frameworks */,
4D29989F0869CA5200E84287 /* libxpcom_core.dylib in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -4294,6 +4298,8 @@
335639BC0C84E85600DC4D06 /* Browser View */, 335639BC0C84E85600DC4D06 /* Browser View */,
6021CDD70C84FDC4000E7754 /* CHStringBundleOverride.h */, 6021CDD70C84FDC4000E7754 /* CHStringBundleOverride.h */,
6021CDD80C84FDC4000E7754 /* CHStringBundleOverride.mm */, 6021CDD80C84FDC4000E7754 /* CHStringBundleOverride.mm */,
33E95A750D31B6FA0054C01D /* CHCookieStorage.h */,
33E95A760D31B6FA0054C01D /* CHCookieStorage.mm */,
F50D9DED02EE0AB101BB4219 /* CHDownloadProgressDisplay.h */, F50D9DED02EE0AB101BB4219 /* CHDownloadProgressDisplay.h */,
F50D9DEE02EE0AB101BB4219 /* CHDownloadProgressDisplay.mm */, F50D9DEE02EE0AB101BB4219 /* CHDownloadProgressDisplay.mm */,
0F0F5E3C08FC660300B4EBCD /* CHISupportsOwner.h */, 0F0F5E3C08FC660300B4EBCD /* CHISupportsOwner.h */,
@ -4782,6 +4788,7 @@
E43EFBB50D143F2600DACA10 /* FindBarController.h in Headers */, E43EFBB50D143F2600DACA10 /* FindBarController.h in Headers */,
E43EFBB70D143F2600DACA10 /* FindBarView.h in Headers */, E43EFBB70D143F2600DACA10 /* FindBarView.h in Headers */,
7BB8FC1C0D2D58AF00CC63B0 /* KeychainDenyList.h in Headers */, 7BB8FC1C0D2D58AF00CC63B0 /* KeychainDenyList.h in Headers */,
33E95A770D31B6FA0054C01D /* CHCookieStorage.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -4956,6 +4963,7 @@
E43EFBB90D143F2600DACA10 /* FindBarController.h in Headers */, E43EFBB90D143F2600DACA10 /* FindBarController.h in Headers */,
E43EFBBB0D143F2600DACA10 /* FindBarView.h in Headers */, E43EFBBB0D143F2600DACA10 /* FindBarView.h in Headers */,
7BB8FC1E0D2D58C600CC63B0 /* KeychainDenyList.h in Headers */, 7BB8FC1E0D2D58C600CC63B0 /* KeychainDenyList.h in Headers */,
33E95A790D31B6FA0054C01D /* CHCookieStorage.h in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -5106,7 +5114,6 @@
3F44ADC605BDFBA000CB4B08 /* Resources */, 3F44ADC605BDFBA000CB4B08 /* Resources */,
3F44ADCA05BDFBA000CB4B08 /* Sources */, 3F44ADCA05BDFBA000CB4B08 /* Sources */,
3F44ADCD05BDFBA000CB4B08 /* Frameworks */, 3F44ADCD05BDFBA000CB4B08 /* Frameworks */,
3F44ADD705BDFBA000CB4B08 /* Rez */,
); );
buildRules = ( buildRules = (
); );
@ -5126,7 +5133,6 @@
3F44ADDE05BDFBA000CB4B08 /* Resources */, 3F44ADDE05BDFBA000CB4B08 /* Resources */,
3F44ADE105BDFBA000CB4B08 /* Sources */, 3F44ADE105BDFBA000CB4B08 /* Sources */,
3F44ADE405BDFBA000CB4B08 /* Frameworks */, 3F44ADE405BDFBA000CB4B08 /* Frameworks */,
3F44ADEE05BDFBA000CB4B08 /* Rez */,
); );
buildRules = ( buildRules = (
); );
@ -5627,20 +5633,6 @@
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
3F44ADD705BDFBA000CB4B08 /* Rez */ = {
isa = PBXRezBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
3F44ADEE05BDFBA000CB4B08 /* Rez */ = {
isa = PBXRezBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXRezBuildPhase section */ /* End PBXRezBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */
@ -5823,6 +5815,7 @@
E43EFBB60D143F2600DACA10 /* FindBarController.mm in Sources */, E43EFBB60D143F2600DACA10 /* FindBarController.mm in Sources */,
E43EFBB80D143F2600DACA10 /* FindBarView.mm in Sources */, E43EFBB80D143F2600DACA10 /* FindBarView.mm in Sources */,
7BB8FC1D0D2D58BB00CC63B0 /* KeychainDenyList.mm in Sources */, 7BB8FC1D0D2D58BB00CC63B0 /* KeychainDenyList.mm in Sources */,
33E95A780D31B6FA0054C01D /* CHCookieStorage.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -5990,6 +5983,7 @@
E43EFBBA0D143F2600DACA10 /* FindBarController.mm in Sources */, E43EFBBA0D143F2600DACA10 /* FindBarController.mm in Sources */,
E43EFBBC0D143F2600DACA10 /* FindBarView.mm in Sources */, E43EFBBC0D143F2600DACA10 /* FindBarView.mm in Sources */,
7BB8FC1F0D2D58D000CC63B0 /* KeychainDenyList.mm in Sources */, 7BB8FC1F0D2D58D000CC63B0 /* KeychainDenyList.mm in Sources */,
33E95A7A0D31B6FA0054C01D /* CHCookieStorage.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -6549,23 +6543,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */; baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = ( GCC_PREFIX_HEADER = "";
../dist/include,
../dist/include/cookie,
../dist/include/necko,
../dist/include/nspr,
../dist/include/pref,
../dist/include/string,
../dist/include/xpcom,
);
INFOPLIST_FILE = "Info-PrivacyPrefPane.plist"; INFOPLIST_FILE = "Info-PrivacyPrefPane.plist";
LIBRARY_SEARCH_PATHS = ../dist/lib;
OTHER_CFLAGS = (
"$(OTHER_CFLAGS)",
"-DDEBUG",
"-DMOZ_DEBUG",
"-DTRACING",
);
PRODUCT_NAME = Privacy; PRODUCT_NAME = Privacy;
}; };
name = Development; name = Development;
@ -6574,17 +6553,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */; baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = ( GCC_PREFIX_HEADER = "";
../dist/include,
../dist/include/cookie,
../dist/include/necko,
../dist/include/nspr,
../dist/include/pref,
../dist/include/string,
../dist/include/xpcom,
);
INFOPLIST_FILE = "Info-PrivacyPrefPane.plist"; INFOPLIST_FILE = "Info-PrivacyPrefPane.plist";
LIBRARY_SEARCH_PATHS = ../dist/lib;
PRODUCT_NAME = Privacy; PRODUCT_NAME = Privacy;
}; };
name = Deployment; name = Deployment;
@ -6593,19 +6563,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */; baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = ( GCC_PREFIX_HEADER = "";
../dist/include,
../dist/include/nspr,
../dist/include/pref,
../dist/include/xpcom,
);
INFOPLIST_FILE = "Info-SecurityPrefPane.plist"; INFOPLIST_FILE = "Info-SecurityPrefPane.plist";
OTHER_CFLAGS = (
"$(OTHER_CFLAGS)",
"-DDEBUG",
"-DMOZ_DEBUG",
"-DTRACING",
);
PRODUCT_NAME = Security; PRODUCT_NAME = Security;
}; };
name = Development; name = Development;
@ -6614,12 +6573,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */; baseConfigurationReference = 332377D10C4D88D300A34879 /* PrefPane.xcconfig */;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = ( GCC_PREFIX_HEADER = "";
../dist/include,
../dist/include/nspr,
../dist/include/pref,
../dist/include/xpcom,
);
INFOPLIST_FILE = "Info-SecurityPrefPane.plist"; INFOPLIST_FILE = "Info-SecurityPrefPane.plist";
PRODUCT_NAME = Security; PRODUCT_NAME = Security;
}; };

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

@ -17,6 +17,10 @@
<string>446.1</string> <string>446.1</string>
<key>IBOldestOS</key> <key>IBOldestOS</key>
<integer>3</integer> <integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>401</integer>
</array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>8S2167</string> <string>8S2167</string>
</dict> </dict>

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

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

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

@ -40,11 +40,6 @@
#import "PreferencePaneBase.h" #import "PreferencePaneBase.h"
#include "nsCOMArray.h"
class nsICookieManager;
class nsICookie;
@class ExtendedTableView; @class ExtendedTableView;
// network.cookie.cookieBehavior settings // network.cookie.cookieBehavior settings
@ -79,20 +74,19 @@ typedef enum ECookiePolicyPopupIndex
IBOutlet ExtendedTableView* mPermissionsTable; IBOutlet ExtendedTableView* mPermissionsTable;
IBOutlet NSTableColumn* mPermissionColumn; IBOutlet NSTableColumn* mPermissionColumn;
IBOutlet NSSearchField* mPermissionFilterField; IBOutlet NSSearchField* mPermissionFilterField;
NSMutableArray* mCachedPermissions; // parallel list for speed, STRONG NSMutableArray* mCachedPermissions; // strong
// cookie sheet // cookie sheet
IBOutlet id mCookiesPanel; IBOutlet id mCookiesPanel;
IBOutlet ExtendedTableView* mCookiesTable; IBOutlet ExtendedTableView* mCookiesTable;
IBOutlet NSSearchField* mCookiesFilterField; IBOutlet NSSearchField* mCookiesFilterField;
nsICookieManager* mCookieManager; NSMutableArray* mCookies; // strong
nsCOMArray<nsICookie>* mCachedCookies;
// Keychain Exclusions sheet // Keychain Exclusions sheet
IBOutlet id mKeychainExclusionsPanel; IBOutlet id mKeychainExclusionsPanel;
IBOutlet ExtendedTableView* mKeychainExclusionsTable; IBOutlet ExtendedTableView* mKeychainExclusionsTable;
IBOutlet NSSearchField* mKeychainExclusionsFilterField; IBOutlet NSSearchField* mKeychainExclusionsFilterField;
NSMutableArray* mKeychainExclusions; NSMutableArray* mKeychainExclusions; // strong
} }
// main panel button actions // main panel button actions

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

@ -38,26 +38,12 @@
#import "PrivacyPane.h" #import "PrivacyPane.h"
#import "NSString+Gecko.h"
#import "NSArray+Utils.h" #import "NSArray+Utils.h"
#import "CHCookieStorage.h"
#import "CHPermissionManager.h" #import "CHPermissionManager.h"
#import "ExtendedTableView.h" #import "ExtendedTableView.h"
#import "KeychainDenyList.h" #import "KeychainDenyList.h"
#include "nsCOMPtr.h"
#include "nsServiceManagerUtils.h"
#include "nsNetCID.h"
#include "nsICookie.h"
#include "nsICookieManager.h"
#include "nsIPref.h"
#include "nsISimpleEnumerator.h"
#include "nsNetUtil.h"
#include "nsString.h"
// we should really get this from "CHBrowserService.h",
// but that requires linkage and extra search paths.
static NSString* XPCOMShutDownNotificationName = @"XPCOMShutDown";
// prefs for keychain password autofill // prefs for keychain password autofill
static const char* const gUseKeychainPref = "chimera.store_passwords_with_keychain"; static const char* const gUseKeychainPref = "chimera.store_passwords_with_keychain";
@ -121,129 +107,35 @@ const int kSortReverse = 1;
} }
@end @end
PR_STATIC_CALLBACK(int) compareCookieHosts(nsICookie* aCookie1, nsICookie* aCookie2, void* aData)
{
nsCAutoString host1;
aCookie1->GetHost(host1);
NSString* host1String = [NSString stringWithUTF8String:host1.get()];
nsCAutoString host2;
aCookie2->GetHost(host2);
NSString* host2String = [NSString stringWithUTF8String:host2.get()];
if ((int)aData == kSortReverse)
return (int)[host2String reverseHostnameCompare:host1String];
else
return (int)[host1String reverseHostnameCompare:host2String];
}
PR_STATIC_CALLBACK(int) compareNames(nsICookie* aCookie1, nsICookie* aCookie2, void* aData)
{
nsCAutoString name1;
aCookie1->GetName(name1);
nsCAutoString name2;
aCookie2->GetName(name2);
if ((int)aData == kSortReverse)
return Compare(name2, name1);
else
return Compare(name1, name2);
}
PR_STATIC_CALLBACK(int) comparePaths(nsICookie* aCookie1, nsICookie* aCookie2, void* aData)
{
nsCAutoString path1;
aCookie1->GetPath(path1);
nsCAutoString path2;
aCookie2->GetPath(path2);
if ((int)aData == kSortReverse)
return Compare(path1, path2);
else
return Compare(path2, path1);
}
PR_STATIC_CALLBACK(int) compareSecures(nsICookie* aCookie1, nsICookie* aCookie2, void* aData)
{
PRBool secure1;
aCookie1->GetIsSecure(&secure1);
PRBool secure2;
aCookie2->GetIsSecure(&secure2);
if (secure1 == secure2)
return 0;
if ((int)aData == kSortReverse)
return (secure2) ? -1 : 1;
else
return (secure1) ? -1 : 1;
}
PR_STATIC_CALLBACK(int) compareExpires(nsICookie* aCookie1, nsICookie* aCookie2, void* aData)
{
PRUint64 expires1;
aCookie1->GetExpires(&expires1);
PRUint64 expires2;
aCookie2->GetExpires(&expires2);
if (expires1 == expires2) return 0;
if ((int)aData == kSortReverse)
return (expires2 < expires1) ? -1 : 1;
else
return (expires1 < expires2) ? -1 : 1;
}
PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, void* aData)
{
nsCAutoString value1;
aCookie1->GetValue(value1);
nsCAutoString value2;
aCookie2->GetValue(value2);
if ((int)aData == kSortReverse)
return Compare(value2, value1);
else
return Compare(value1, value2);
}
#pragma mark - #pragma mark -
@implementation OrgMozillaCaminoPreferencePrivacy @implementation OrgMozillaCaminoPreferencePrivacy
-(void) dealloc -(void) dealloc
{ {
[[NSNotificationCenter defaultCenter] removeObserver:self]; // These should have been released when the sheets closed, but make sure.
[mCachedPermissions release];
[mCookies release];
[mKeychainExclusions release];
// NOTE: no need to worry about mCachedPermissions or mCachedCookies because
// if we're going away the respective sheets have closed and cleaned up.
NS_IF_RELEASE(mCookieManager);
[super dealloc]; [super dealloc];
} }
- (void)xpcomShutdown:(NSNotification*)notification
{
// this nulls the pointer
NS_IF_RELEASE(mCookieManager);
}
-(void) mainViewDidLoad -(void) mainViewDidLoad
{ {
if (!mPrefService)
return;
// we need to register for xpcom shutdown so that we can clear the
// services before XPCOM is shut down. We can't rely on dealloc,
// because we don't know when it will get called (we might be autoreleased).
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(xpcomShutdown:)
name:XPCOMShutDownNotificationName
object:nil];
// Hookup cookie prefs. // Hookup cookie prefs.
PRInt32 acceptCookies = eAcceptAllCookies; BOOL gotPref = NO;
mPrefService->GetIntPref("network.cookie.cookieBehavior", &acceptCookies); BOOL acceptCookies = [self getBooleanPref:"network.cookie.cookieBehavior"
withSuccess:&gotPref];
if (!gotPref)
acceptCookies = eAcceptAllCookies;
[self mapCookiePrefToGUI:acceptCookies]; [self mapCookiePrefToGUI:acceptCookies];
// lifetimePolicy now controls asking about cookies, despite being totally unintuitive // lifetimePolicy now controls asking about cookies, despite being totally unintuitive
PRInt32 lifetimePolicy = kAcceptCookiesNormally; int lifetimePolicy = [self getIntPref:"network.cookie.lifetimePolicy"
mPrefService->GetIntPref("network.cookie.lifetimePolicy", &lifetimePolicy); withSuccess:&gotPref];
if (!gotPref)
lifetimePolicy = kAcceptCookiesNormally;
if (lifetimePolicy == kWarnAboutCookies) if (lifetimePolicy == kWarnAboutCookies)
[mAskAboutCookies setState:NSOnState]; [mAskAboutCookies setState:NSOnState];
else if (lifetimePolicy == kAcceptCookiesNormally) else if (lifetimePolicy == kAcceptCookiesNormally)
@ -251,14 +143,8 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
else else
[mAskAboutCookies setState:NSMixedState]; [mAskAboutCookies setState:NSMixedState];
// store cookie manager service
nsCOMPtr<nsICookieManager> cm(do_GetService(NS_COOKIEMANAGER_CONTRACTID));
mCookieManager = cm.get();
NS_IF_ADDREF(mCookieManager);
// Keychain checkbox // Keychain checkbox
PRBool storePasswords = PR_TRUE; BOOL storePasswords = [self getBooleanPref:gUseKeychainPref withSuccess:NULL];
mPrefService->GetBoolPref(gUseKeychainPref, &storePasswords);
[mStorePasswords setState:(storePasswords ? NSOnState : NSOffState)]; [mStorePasswords setState:(storePasswords ? NSOnState : NSOffState)];
// set up policy popups // set up policy popups
@ -282,29 +168,18 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
-(void) populateCookieCache -(void) populateCookieCache
{ {
nsCOMPtr<nsISimpleEnumerator> cookieEnum; if (mCookies)
if (mCookieManager) [mCookies release];
mCookieManager->GetEnumerator(getter_AddRefs(cookieEnum)); mCookies = [[[CHCookieStorage cookieStorage] cookies] mutableCopy];
if (!mCookies)
mCachedCookies = new nsCOMArray<nsICookie>; mCookies = [[NSMutableArray alloc] init];
if (mCachedCookies && cookieEnum) {
mCachedCookies->Clear();
PRBool hasMoreElements = PR_FALSE;
cookieEnum->HasMoreElements(&hasMoreElements);
while (hasMoreElements) {
nsCOMPtr<nsICookie> cookie;
cookieEnum->GetNext(getter_AddRefs(cookie));
mCachedCookies->AppendObject(cookie);
cookieEnum->HasMoreElements(&hasMoreElements);
}
}
} }
-(IBAction) editCookies:(id)aSender -(IBAction) editCookies:(id)aSender
{ {
// build parallel cookie list // build cookie list
[self populateCookieCache]; [self populateCookieCache];
[mCookiesTable setDeleteAction:@selector(removeCookies:)]; [mCookiesTable setDeleteAction:@selector(removeCookies:)];
[mCookiesTable setTarget:self]; [mCookiesTable setTarget:self];
@ -315,21 +190,18 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
//[cookieDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; //[cookieDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
//[cookieDateFormatter setDateStyle:NSDateFormatterMediumStyle]; //[cookieDateFormatter setDateStyle:NSDateFormatterMediumStyle];
//[cookieDateFormatter setTimeStyle:NSDateFormatterNoStyle]; //[cookieDateFormatter setTimeStyle:NSDateFormatterNoStyle];
[[[mCookiesTable tableColumnWithIdentifier:@"Expires"] dataCell] setFormatter:cookieDateFormatter]; [[[mCookiesTable tableColumnWithIdentifier:@"expiresDate"] dataCell] setFormatter:cookieDateFormatter];
[cookieDateFormatter release]; [cookieDateFormatter release];
// start sorted by host // start sorted by host
mCachedCookies->Sort(compareCookieHosts, nsnull);
NSTableColumn* sortedColumn = [mCookiesTable tableColumnWithIdentifier:@"Website"];
[mCookiesTable setHighlightedTableColumn:sortedColumn];
[mCookiesTable setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"]
inTableColumn:sortedColumn];
mSortedAscending = YES; mSortedAscending = YES;
[self sortCookiesByColumn:[mCookiesTable tableColumnWithIdentifier:@"domain"]
inAscendingOrder:YES];
// ensure a row is selected (cocoa doesn't do this for us, but will keep // ensure a row is selected (cocoa doesn't do this for us, but will keep
// us from unselecting a row once one is set; go figure). // us from unselecting a row once one is set; go figure).
[mCookiesTable selectRow:0 byExtendingSelection:NO]; [mCookiesTable selectRow:0 byExtendingSelection:NO];
[mCookiesTable setUsesAlternatingRowBackgroundColors:YES]; [mCookiesTable setUsesAlternatingRowBackgroundColors:YES];
NSArray* columns = [mCookiesTable tableColumns]; NSArray* columns = [mCookiesTable tableColumns];
if (columns) { if (columns) {
@ -337,15 +209,10 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
for (int i = 0; i < numColumns; ++i) for (int i = 0; i < numColumns; ++i)
[[[columns objectAtIndex:i] dataCell] setDrawsBackground:NO]; [[[columns objectAtIndex:i] dataCell] setDrawsBackground:NO];
} }
//clear the filter field //clear the filter field
[mCookiesFilterField setStringValue:@""]; [mCookiesFilterField setStringValue:@""];
// we shouldn't need to do this, but the scrollbar won't enable unless we
// force the table to reload its data. Oddly it gets the number of rows correct,
// it just forgets to tell the scrollbar. *shrug*
[mCookiesTable reloadData];
[mCookiesPanel setFrameAutosaveName:@"cookies_sheet"]; [mCookiesPanel setFrameAutosaveName:@"cookies_sheet"];
// bring up sheet // bring up sheet
@ -360,35 +227,27 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
-(IBAction) removeCookies:(id)aSender -(IBAction) removeCookies:(id)aSender
{ {
int rowToSelect = -1; CHCookieStorage* cookieStorage = [CHCookieStorage cookieStorage];
if (mCachedCookies && mCookieManager) { // Walk the selected rows backwards, removing cookies.
NSArray *rows = [[mCookiesTable selectedRowEnumerator] allObjects]; NSIndexSet* selectedIndexes = [mCookiesTable selectedRowIndexes];
NSEnumerator *e = [rows reverseObjectEnumerator]; for (unsigned int i = [selectedIndexes lastIndex];
NSNumber *index; i != NSNotFound;
while ((index = [e nextObject])) i = [selectedIndexes indexLessThanIndex:i])
{ {
int row = [index intValue]; [cookieStorage deleteCookie:[mCookies objectAtIndex:i]];
if (rowToSelect == -1) [mCookies removeObjectAtIndex:i];
rowToSelect = row;
else
--rowToSelect;
nsCAutoString host, name, path;
mCachedCookies->ObjectAt(row)->GetHost(host);
mCachedCookies->ObjectAt(row)->GetName(name);
mCachedCookies->ObjectAt(row)->GetPath(path);
mCookieManager->Remove(host, name, path, PR_FALSE); // don't block permanently
mCachedCookies->RemoveObjectAt(row);
}
} }
[mCookiesTable reloadData]; [mCookiesTable reloadData];
if (rowToSelect >=0 && rowToSelect < [mCookiesTable numberOfRows]) // Select the row after the last deleted row.
if ([mCookiesTable numberOfRows] > 0) {
int rowToSelect = [selectedIndexes lastIndex] - ([selectedIndexes count] - 1);
if ((rowToSelect < 0) || (rowToSelect >= [mCookiesTable numberOfRows]))
rowToSelect = [mCookiesTable numberOfRows] - 1;
[mCookiesTable selectRow:rowToSelect byExtendingSelection:NO]; [mCookiesTable selectRow:rowToSelect byExtendingSelection:NO];
else }
[mCookiesTable deselectAll:self];
} }
-(IBAction) removeAllCookies: (id)aSender -(IBAction) removeAllCookies: (id)aSender
@ -399,13 +258,11 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
[self localizedStringForKey:@"CancelButtonText"], [self localizedStringForKey:@"CancelButtonText"],
nil) == NSAlertDefaultReturn) nil) == NSAlertDefaultReturn)
{ {
if (mCookieManager) { [[CHCookieStorage cookieStorage] deleteAllCookies];
// remove all cookies from cookie manager
mCookieManager->RemoveAll(); [mCookies release];
// create new cookie cache mCookies = [[NSMutableArray alloc] init];
delete mCachedCookies;
mCachedCookies = new nsCOMArray<nsICookie>;
}
[mCookiesTable reloadData]; [mCookiesTable reloadData];
} }
} }
@ -422,47 +279,19 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
-(IBAction) removeCookiesAndBlockSites:(id)aSender -(IBAction) removeCookiesAndBlockSites:(id)aSender
{ {
if (mCachedCookies) { // Block the sites.
// first fetch the list of sites CHPermissionManager* permManager = [CHPermissionManager permissionManager];
NSArray* selectedSites = [self selectedCookieSites]; NSArray* selectedSites = [self selectedCookieSites];
int rowToSelect = -1; NSEnumerator* sitesEnum = [selectedSites objectEnumerator];
NSString* curSite;
// remove the cookies while ((curSite = [sitesEnum nextObject])) {
for (int row = 0; row < mCachedCookies->Count(); row++) { [permManager setPolicy:CHPermissionDeny
nsCAutoString host, name, path; forHost:curSite
// only search on the host type:CHPermissionTypeCookie];
mCachedCookies->ObjectAt(row)->GetHost(host);
NSString* cookieHost = [NSString stringWith_nsACString:host];
if ([selectedSites containsObject:cookieHost])
{
if (rowToSelect == -1)
rowToSelect = row;
mCachedCookies->ObjectAt(row)->GetName(name);
mCachedCookies->ObjectAt(row)->GetPath(path);
mCookieManager->Remove(host, name, path, PR_FALSE); // don't block permanently
mCachedCookies->RemoveObjectAt(row);
--row; // to account for removal
}
}
// and block the sites
CHPermissionManager* permManager = [CHPermissionManager permissionManager];
NSEnumerator* sitesEnum = [selectedSites objectEnumerator];
NSString* curSite;
while ((curSite = [sitesEnum nextObject]))
[permManager setPolicy:CHPermissionDeny
forHost:curSite
type:CHPermissionTypeCookie];
// and reload data
[mCookiesTable reloadData];
if (rowToSelect >=0 && rowToSelect < [mCookiesTable numberOfRows])
[mCookiesTable selectRow:rowToSelect byExtendingSelection:NO];
else
[mCookiesTable deselectAll:self];
} }
// Then remove the cookies.
[self removeCookies:aSender];
} }
-(IBAction) editCookiesDone:(id)aSender -(IBAction) editCookiesDone:(id)aSender
@ -471,8 +300,8 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
[mCookiesPanel orderOut:self]; [mCookiesPanel orderOut:self];
[NSApp endSheet:mCookiesPanel]; [NSApp endSheet:mCookiesPanel];
delete mCachedCookies; [mCookies release];
mCachedCookies = nsnull; mCookies = nil;
} }
// //
@ -654,18 +483,16 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
if (aTableView == mPermissionsTable) { if (aTableView == mPermissionsTable) {
numRows = [mCachedPermissions count]; numRows = [mCachedPermissions count];
} else if (aTableView == mCookiesTable) { } else if (aTableView == mCookiesTable) {
if (mCachedCookies) numRows = [mCookies count];
numRows = mCachedCookies->Count();
} else if (aTableView == mKeychainExclusionsTable) { } else if (aTableView == mKeychainExclusionsTable) {
numRows = [mKeychainExclusions count]; numRows = [mKeychainExclusions count];
} }
return (int) numRows; return numRows;
} }
-(id) tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex -(id) tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{ {
id retVal = nil;
if (aTableView == mPermissionsTable) { if (aTableView == mPermissionsTable) {
if ([[aTableColumn identifier] isEqualToString: @"host"]) { if ([[aTableColumn identifier] isEqualToString: @"host"]) {
return [[mCachedPermissions objectAtIndex:rowIndex] host]; return [[mCachedPermissions objectAtIndex:rowIndex] host];
@ -676,38 +503,27 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
} }
} }
else if (aTableView == mCookiesTable) { else if (aTableView == mCookiesTable) {
if (mCachedCookies) { if ([[aTableColumn identifier] isEqualToString: @"isSecure"]) {
nsCAutoString cookieVal; BOOL secure = [[mCookies objectAtIndex:rowIndex] isSecure];
if ([[aTableColumn identifier] isEqualToString: @"Website"]) { return [self localizedStringForKey:(secure ? @"yes": @"no")];
mCachedCookies->ObjectAt(rowIndex)->GetHost(cookieVal); } else if ([[aTableColumn identifier] isEqualToString: @"expiresDate"]) {
} else if ([[aTableColumn identifier] isEqualToString: @"Name"]) { NSHTTPCookie* cookie = [mCookies objectAtIndex:rowIndex];
mCachedCookies->ObjectAt(rowIndex)->GetName(cookieVal); BOOL isSessionCookie = [cookie isSessionOnly];
} else if ([[aTableColumn identifier] isEqualToString: @"Path"]) { // If it's a session cookie, set the expiration date to the epoch,
mCachedCookies->ObjectAt(rowIndex)->GetPath(cookieVal); // so the custom formatter can display a localized string.
} else if ([[aTableColumn identifier] isEqualToString: @"Secure"]) { return isSessionCookie ? [NSDate dateWithTimeIntervalSince1970:0]
PRBool secure = PR_FALSE; : [cookie expiresDate];
mCachedCookies->ObjectAt(rowIndex)->GetIsSecure(&secure); } else {
return [self localizedStringForKey:(secure ? @"yes": @"no")]; // special case return return [[mCookies objectAtIndex:rowIndex] valueForKey:[aTableColumn identifier]];
} else if ([[aTableColumn identifier] isEqualToString: @"Expires"]) {
PRUint64 expires = 0;
mCachedCookies->ObjectAt(rowIndex)->GetExpires(&expires);
// If expires is 0, it's a session cookie.
// We use a custom formatter to display a localised string in this case.
NSDate *date = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)expires];
return date; // special case return
} else if ([[aTableColumn identifier] isEqualToString: @"Value"]) {
mCachedCookies->ObjectAt(rowIndex)->GetValue(cookieVal);
}
retVal = [NSString stringWithCString: cookieVal.get()];
} }
} }
else if (aTableView == mKeychainExclusionsTable) { else if (aTableView == mKeychainExclusionsTable) {
if ([[aTableColumn identifier] isEqualToString:@"Website"]) { if ([[aTableColumn identifier] isEqualToString:@"Website"]) {
retVal = [mKeychainExclusions objectAtIndex:rowIndex]; return [mKeychainExclusions objectAtIndex:rowIndex];
} }
} }
return retVal; return nil;
} }
// currently, this only applies to the site allow/deny, since that's the only editable column // currently, this only applies to the site allow/deny, since that's the only editable column
@ -761,24 +577,30 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
-(void) sortCookiesByColumn:(NSTableColumn *)aTableColumn inAscendingOrder:(BOOL)ascending -(void) sortCookiesByColumn:(NSTableColumn *)aTableColumn inAscendingOrder:(BOOL)ascending
{ {
if(mCachedCookies) { NSArray* sortDescriptors = nil;
if ([[aTableColumn identifier] isEqualToString:@"Website"]) if ([[aTableColumn identifier] isEqualToString:@"domain"]) {
mCachedCookies->Sort(compareCookieHosts, (ascending) ? nsnull : (void *)kSortReverse); NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:@"domain"
else if ([[aTableColumn identifier] isEqualToString:@"Name"]) ascending:ascending
mCachedCookies->Sort(compareNames, (ascending) ? nsnull : (void *)kSortReverse); selector:@selector(reverseHostnameCompare:)] autorelease];
else if ([[aTableColumn identifier] isEqualToString:@"Path"]) sortDescriptors = [NSArray arrayWithObject:sort];
mCachedCookies->Sort(comparePaths, (ascending) ? nsnull : (void *)kSortReverse);
else if ([[aTableColumn identifier] isEqualToString:@"Secure"])
mCachedCookies->Sort(compareSecures, (ascending) ? nsnull : (void *)kSortReverse);
else if ([[aTableColumn identifier] isEqualToString:@"Expires"])
mCachedCookies->Sort(compareExpires, (ascending) ? nsnull : (void *)kSortReverse);
else if ([[aTableColumn identifier] isEqualToString:@"Value"])
mCachedCookies->Sort(compareValues, (ascending) ? nsnull : (void *)kSortReverse);
[mCookiesTable reloadData];
[self updateSortIndicatorWithColumn:aTableColumn];
} }
else if ([[aTableColumn identifier] isEqualToString:@"expiresDate"]) {
NSSortDescriptor *sessionSort = [[[NSSortDescriptor alloc] initWithKey:@"isSessionOnly"
ascending:ascending] autorelease];
NSSortDescriptor *expirySort = [[[NSSortDescriptor alloc] initWithKey:@"expiresDate"
ascending:ascending] autorelease];
sortDescriptors = [NSArray arrayWithObjects:sessionSort, expirySort, nil];
}
else { // All the other column just use a default sort
NSSortDescriptor *sort = [[[NSSortDescriptor alloc] initWithKey:[aTableColumn identifier]
ascending:ascending] autorelease];
sortDescriptors = [NSArray arrayWithObject:sort];
}
[mCookies sortUsingDescriptors:sortDescriptors];
[mCookiesTable reloadData];
[self updateSortIndicatorWithColumn:aTableColumn];
} }
- (void)sortKeychainExclusionsByColumn:(NSTableColumn*)tableColumn - (void)sortKeychainExclusionsByColumn:(NSTableColumn*)tableColumn
@ -820,84 +642,49 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
mSortedAscending = !mSortedAscending; mSortedAscending = !mSortedAscending;
else else
mSortedAscending = YES; mSortedAscending = YES;
NSArray* dataSource = nil;
if (aTableView == mPermissionsTable)
dataSource = mCachedPermissions;
else if (aTableView == mCookiesTable)
dataSource = mCookies;
else if (aTableView == mKeychainExclusionsTable)
dataSource = mKeychainExclusions;
if (!dataSource)
return;
// Save the currently selected rows, if any.
NSMutableArray* selectedItems = [NSMutableArray array];
NSIndexSet* selectedIndexes = [aTableView selectedRowIndexes];
for (unsigned int i = [selectedIndexes lastIndex];
i != NSNotFound;
i = [selectedIndexes indexLessThanIndex:i])
{
[selectedItems addObject:[dataSource objectAtIndex:i]];
}
// Sort the table data.
if (aTableView == mPermissionsTable) { if (aTableView == mPermissionsTable) {
if (mCachedPermissions) { [self sortPermissionsByKey:[aTableColumn identifier]
// save the currently selected rows, if any. inAscendingOrder:mSortedAscending];
NSMutableArray* selectedItems = [NSMutableArray array];
NSIndexSet* selectedIndexes = [mPermissionsTable selectedRowIndexes];
for (unsigned int i = [selectedIndexes lastIndex];
i != NSNotFound;
i = [selectedIndexes indexLessThanIndex:i])
{
[selectedItems addObject:[mCachedPermissions objectAtIndex:i]];
}
// sort the table data
[self sortPermissionsByKey:[aTableColumn identifier] inAscendingOrder:mSortedAscending];
// if any rows were selected before, find them again
[mPermissionsTable deselectAll:self];
int selectedItemCount = [selectedItems count];
for (int i = 0; i < selectedItemCount; ++i) {
int newRowIndex = [mCachedPermissions indexOfObject:[selectedItems objectAtIndex:i]];
if (newRowIndex != NSNotFound) {
// scroll to the first item (arbitrary, but at least one should show)
if (i == 0)
[mPermissionsTable scrollRowToVisible:newRowIndex];
[mPermissionsTable selectRow:newRowIndex byExtendingSelection:YES];
}
}
}
} else if (aTableView == mCookiesTable) { } else if (aTableView == mCookiesTable) {
if (mCachedCookies) { [self sortCookiesByColumn:aTableColumn
// save the currently selected rows, if any. inAscendingOrder:mSortedAscending];
nsCOMArray<nsICookie> selectedItems;
NSEnumerator *e = [mCookiesTable selectedRowEnumerator];
NSNumber *index;
while ((index = [e nextObject])) {
int row = [index intValue];
selectedItems.AppendObject(mCachedCookies->ObjectAt(row));
}
// sort the table data
[self sortCookiesByColumn:aTableColumn inAscendingOrder:mSortedAscending];
// if any rows were selected before, find them again
[mCookiesTable deselectAll:self];
for (int i = 0; i < selectedItems.Count(); ++i) {
int newRowIndex = mCachedCookies->IndexOf(selectedItems.ObjectAt(i));
if (newRowIndex >= 0) {
// scroll to the first item (arbitrary, but at least one should show)
if (i == 0)
[mCookiesTable scrollRowToVisible:newRowIndex];
[mCookiesTable selectRow:newRowIndex byExtendingSelection:YES];
}
}
}
} else if (aTableView == mKeychainExclusionsTable) { } else if (aTableView == mKeychainExclusionsTable) {
// Save the currently selected rows, if any.
NSMutableArray* selectedItems = [NSMutableArray arrayWithCapacity:[mKeychainExclusionsTable numberOfSelectedRows]];
NSIndexSet* selectedIndexes = [mKeychainExclusionsTable selectedRowIndexes];
for (unsigned int index = [selectedIndexes lastIndex];
index != NSNotFound;
index = [selectedIndexes indexLessThanIndex:index]) {
[selectedItems addObject:[mKeychainExclusions objectAtIndex:index]];
}
[self sortKeychainExclusionsByColumn:aTableColumn [self sortKeychainExclusionsByColumn:aTableColumn
inAscendingOrder:mSortedAscending]; inAscendingOrder:mSortedAscending];
}
// If any rows were selected before, find them again. // If any rows were selected before, find them again.
[mKeychainExclusionsTable deselectAll:self]; [aTableView deselectAll:self];
for (unsigned int i = 0; i < [selectedItems count]; ++i) { for (unsigned int i = 0; i < [selectedItems count]; ++i) {
int newRowIndex = [mKeychainExclusions indexOfObject:[selectedItems objectAtIndex:i]]; int newRowIndex = [dataSource indexOfObject:[selectedItems objectAtIndex:i]];
if (newRowIndex != NSNotFound) { if (newRowIndex != NSNotFound) {
// scroll to the first item (arbitrary, but at least one should show) // scroll to the first item (arbitrary, but at least one should show)
if (i == 0) { if (i == 0)
[mKeychainExclusionsTable scrollRowToVisible:newRowIndex]; [aTableView scrollRowToVisible:newRowIndex];
} [aTableView selectRow:newRowIndex byExtendingSelection:YES];
[mKeychainExclusionsTable selectRow:newRowIndex
byExtendingSelection:YES];
}
} }
} }
} }
@ -925,10 +712,7 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
// //
-(IBAction) clickStorePasswords:(id)sender -(IBAction) clickStorePasswords:(id)sender
{ {
if (!mPrefService) [self setPref:gUseKeychainPref toBoolean:([mStorePasswords state] == NSOnState)];
return;
mPrefService->SetBoolPref(gUseKeychainPref,
([mStorePasswords state] == NSOnState) ? PR_TRUE : PR_FALSE);
} }
-(IBAction) launchKeychainAccess:(id)sender -(IBAction) launchKeychainAccess:(id)sender
@ -969,7 +753,7 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
- (IBAction)cookieFilterChanged:(id)sender - (IBAction)cookieFilterChanged:(id)sender
{ {
if (!mCachedCookies || !mCookieManager) if (!mCookies)
return; return;
NSString* filterString = [sender stringValue]; NSString* filterString = [sender stringValue];
@ -1026,25 +810,17 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
- (void) filterCookiesWithString: (NSString*) inFilterString - (void) filterCookiesWithString: (NSString*) inFilterString
{ {
// reinitialize the list of cookies in case user deleted a letter or replaced a letter // Reinitialize the list in case the user deleted or replaced a letter.
[self populateCookieCache]; [self populateCookieCache];
if ([inFilterString length]) { if ([inFilterString length] == 0)
NSMutableArray *indexToRemove = [NSMutableArray array]; return;
for (int row = 0; row < mCachedCookies->Count(); row++) {
nsCAutoString host; for (int i = [mCookies count] - 1; i >= 0; --i) {
// only search on the host NSString* host = [[mCookies objectAtIndex:i] domain];
mCachedCookies->ObjectAt(row)->GetHost(host); // Only search by host; other fields are probably not interesting to users
if ([[NSString stringWithUTF8String:host.get()] rangeOfString:inFilterString].location == NSNotFound) if ([host rangeOfString:inFilterString].location == NSNotFound)
[indexToRemove addObject:[NSNumber numberWithInt:row]]; [mCookies removeObjectAtIndex:i];
}
//remove the items at the saved indexes
//
NSEnumerator *theEnum = [indexToRemove reverseObjectEnumerator];
NSNumber *currentItem;
while ((currentItem = [theEnum nextObject]))
mCachedCookies->RemoveObjectAt([currentItem intValue]);
} }
} }
@ -1062,22 +838,18 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
- (void)addPermissionForSelection:(int)inPermission - (void)addPermissionForSelection:(int)inPermission
{ {
if (mCachedCookies) { CHPermissionManager* permManager = [CHPermissionManager permissionManager];
CHPermissionManager* permManager = [CHPermissionManager permissionManager]; NSIndexSet* selectedIndexes = [mCookiesTable selectedRowIndexes];
NSArray* rows = [[mCookiesTable selectedRowEnumerator] allObjects]; for (unsigned int index = [selectedIndexes lastIndex];
NSEnumerator* e = [rows reverseObjectEnumerator]; index != NSNotFound;
NSNumber* index; index = [selectedIndexes indexLessThanIndex:index])
while ((index = [e nextObject])) {
{ NSString* host = [[mCookies objectAtIndex:index] domain];
int row = [index intValue]; if ([host hasPrefix:@"."] && [host length] > 1)
host = [host substringFromIndex:1];
nsCAutoString host; [permManager setPolicy:inPermission
mCachedCookies->ObjectAt(row)->GetHost(host); forHost:host
[permManager setPolicy:inPermission type:CHPermissionTypeCookie];
forHost:[NSString stringWith_nsACString:host]
type:CHPermissionTypeCookie];
}
} }
} }
@ -1125,17 +897,12 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2,
{ {
// the set does the uniquifying for us // the set does the uniquifying for us
NSMutableSet* selectedHostsSet = [[[NSMutableSet alloc] init] autorelease]; NSMutableSet* selectedHostsSet = [[[NSMutableSet alloc] init] autorelease];
NSEnumerator* e = [mCookiesTable selectedRowEnumerator]; NSIndexSet* selectedIndexes = [mCookiesTable selectedRowIndexes];
NSNumber* index; for (unsigned int index = [selectedIndexes lastIndex];
while ((index = [e nextObject])) index != NSNotFound;
index = [selectedIndexes indexLessThanIndex:index])
{ {
int row = [index intValue]; [selectedHostsSet addObject:[[mCookies objectAtIndex:index] domain]];
nsCAutoString host;
mCachedCookies->ObjectAt(row)->GetHost(host);
NSString* hostString = [NSString stringWith_nsACString:host];
[selectedHostsSet addObject:hostString];
} }
return [selectedHostsSet allObjects]; return [selectedHostsSet allObjects];
} }

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

@ -37,9 +37,6 @@
#import "SecurityPane.h" #import "SecurityPane.h"
#include "nsServiceManagerUtils.h"
#include "nsIPref.h"
// prefs for showing security dialogs // prefs for showing security dialogs
#define LEAVE_SITE_PREF "security.warn_leaving_secure" #define LEAVE_SITE_PREF "security.warn_leaving_secure"
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed" #define MIXEDCONTENT_PREF "security.warn_viewing_mixed"

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

@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Camino code.
*
* The Initial Developer of the Original Code is
* Stuart Morgan
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Morgan <stuart.morgan@alumni.case.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Cocoa/Cocoa.h>
class nsICookieManager;
// Provides access to and management of stored cookies. Wraps the Gecko
// nsICookieManager.
@interface CHCookieStorage : NSObject {
@private
nsICookieManager* mManager; // strong
}
// Returns the shared CHCookieStorage instance.
+ (CHCookieStorage*)cookieStorage;
// Returns all cookies.
- (NSArray*)cookies;
// Deletes a specific cookie.
- (void)deleteCookie:(NSHTTPCookie*)cookie;
// Deletes all stored cookies.
- (void)deleteAllCookies;
@end

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

@ -0,0 +1,185 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Camino code.
*
* The Initial Developer of the Original Code is
* Stuart Morgan
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Morgan <stuart.morgan@alumni.case.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "CHCookieStorage.h"
// For shutdown notification names.
#import "CHBrowserService.h"
#include "nsCOMPtr.h"
#include "nsNetCID.h"
#include "nsString.h"
#include "nsServiceManagerUtils.h"
#include "nsICookie.h"
#include "nsICookie2.h"
#include "nsICookieManager.h"
#include "nsISimpleEnumerator.h"
// Xcode 2.x's ld dead-strips this symbol. Xcode 3.0's ld is fine.
asm(".no_dead_strip .objc_class_name_CHCookieStorage");
@interface NSHTTPCookie (GeckoConstructor)
+ (id)cookieFromGeckoCookie:(nsICookie2*)geckoCookie;
@end
@implementation NSHTTPCookie (GeckoConstructor)
// Creates an autoreleased NSHTTPCookie from the data in the given Gecko cookie.
+ (id)cookieFromGeckoCookie:(nsICookie2*)geckoCookie
{
NSMutableDictionary* properties = [NSMutableDictionary dictionaryWithCapacity:6];
nsCAutoString val;
geckoCookie->GetHost(val);
[properties setObject:[NSString stringWithCString:val.get()] forKey:NSHTTPCookieDomain];
geckoCookie->GetName(val);
[properties setObject:[NSString stringWithCString:val.get()] forKey:NSHTTPCookieName];
geckoCookie->GetPath(val);
[properties setObject:[NSString stringWithCString:val.get()] forKey:NSHTTPCookiePath];
geckoCookie->GetValue(val);
[properties setObject:[NSString stringWithCString:val.get()] forKey:NSHTTPCookieValue];
PRBool secure = PR_FALSE;
geckoCookie->GetIsSecure(&secure);
[properties setObject:(secure ? @"TRUE" : @"FALSE") forKey:NSHTTPCookieSecure];
PRUint64 expiry = 0;
geckoCookie->GetExpires(&expiry);
NSDate *date = [NSDate dateWithTimeIntervalSince1970:(NSTimeInterval)expiry];
[properties setObject:date forKey:NSHTTPCookieExpires];
PRBool isSession = PR_FALSE;
geckoCookie->GetIsSession(&isSession);
if (isSession)
[properties setObject:@"TRUE" forKey:NSHTTPCookieDiscard];
return [self cookieWithProperties:properties];
}
@end
static CHCookieStorage* sCookieStorage = nil;
@implementation CHCookieStorage
+ (CHCookieStorage*)cookieStorage
{
if (!sCookieStorage)
sCookieStorage = [[self alloc] init];
return sCookieStorage;
}
- (id)init
{
if ((self = [super init])) {
nsCOMPtr<nsICookieManager> cm(do_GetService(NS_COOKIEMANAGER_CONTRACTID));
mManager = cm.get();
if (!mManager) {
[self release];
return nil;
}
NS_ADDREF(mManager);
// Register for xpcom shutdown so that we can release the manager.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(xpcomShutdown:)
name:XPCOMShutDownNotificationName
object:nil];
}
return self;
}
- (void)dealloc
{
sCookieStorage = nil;
NS_IF_RELEASE(mManager);
[super dealloc];
}
- (void)xpcomShutdown:(NSNotification*)notification
{
// This nulls out the pointer
NS_IF_RELEASE(mManager);
}
- (NSArray*)cookies
{
if (!mManager)
return nil;
nsCOMPtr<nsISimpleEnumerator> cookieEnumerator;
mManager->GetEnumerator(getter_AddRefs(cookieEnumerator));
if (!cookieEnumerator)
return nil;
NSMutableArray* cookies = [NSMutableArray array];
PRBool hasMoreElements;
cookieEnumerator->HasMoreElements(&hasMoreElements);
while (hasMoreElements) {
nsCOMPtr<nsICookie2> cookie;
cookieEnumerator->GetNext(getter_AddRefs(cookie));
if (cookie)
[cookies addObject:[NSHTTPCookie cookieFromGeckoCookie:cookie.get()]];
cookieEnumerator->HasMoreElements(&hasMoreElements);
}
return cookies;
}
- (void)deleteCookie:(NSHTTPCookie*)cookie
{
if (!mManager)
return;
mManager->Remove(nsDependentCString([[cookie domain] UTF8String]),
nsDependentCString([[cookie name] UTF8String]),
nsDependentCString([[cookie path] UTF8String]),
PR_FALSE); // don't block permanently
}
- (void)deleteAllCookies
{
if (!mManager)
return;
mManager->RemoveAll();
}
@end