diff --git a/MacPass/Base.lproj/GeneralPreferences.xib b/MacPass/Base.lproj/GeneralPreferences.xib
index 700d352c..327233be 100644
--- a/MacPass/Base.lproj/GeneralPreferences.xib
+++ b/MacPass/Base.lproj/GeneralPreferences.xib
@@ -19,13 +19,14 @@
+
-
+
@@ -208,7 +209,7 @@
-
+
@@ -273,18 +274,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ By default web site icon is downloaded directly from entry's host URL. For some websites it doesn't work and you might prefer using 3rdparty APIs. In this case only host from the URL will be used to get the icon from selected service.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
-
+
diff --git a/MacPass/MPGeneralPreferencesController.h b/MacPass/MPGeneralPreferencesController.h
index d55a6ca8..3d45de0b 100644
--- a/MacPass/MPGeneralPreferencesController.h
+++ b/MacPass/MPGeneralPreferencesController.h
@@ -37,5 +37,6 @@
@property (strong) IBOutlet NSButton *enableAutosaveCheckButton;
@property (strong) IBOutlet NSButton *rememberKeyFileCheckButton;
@property (strong) IBOutlet NSPopUpButton *fileChangeStrategyPopup;
+@property (strong) IBOutlet NSPopUpButton *faviconDownloadMethodPopup;
@end
diff --git a/MacPass/MPGeneralPreferencesController.m b/MacPass/MPGeneralPreferencesController.m
index 759e4132..0a566e3c 100644
--- a/MacPass/MPGeneralPreferencesController.m
+++ b/MacPass/MPGeneralPreferencesController.m
@@ -56,6 +56,19 @@
[self.enableAutosaveCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEnableAutosave] options:nil];
[self.rememberKeyFileCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyRememberKeyFilesForDatabases] options:nil];
+ /* Favicon download method menu */
+ NSDictionary *faviconDownloadMethodDict = @{ @(MPFaviconDownloadMethodDirect) : NSLocalizedString(@"FAVICON_DOWNLOAD_METHOD_DIRECT", @"Favicon download method: directly download from the host"),
+ @(MPFaviconDownloadMethodDuckDuckGo) : NSLocalizedString(@"FAVICON_DOWNLOAD_METHOD_DUCKDUCKGO", @"Favicon download method: use DuckDuckGo's favicon fetching service"),
+ @(MPFaviconDownloadMethodGoogle) : NSLocalizedString(@"FAVICON_DOWNLOAD_METHOD_GOOGLE", @"Favicon download method: use Google's favicon fetching service"),
+ };
+ [self.faviconDownloadMethodPopup.menu removeAllItems];
+ for(NSNumber *key in faviconDownloadMethodDict) {
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:faviconDownloadMethodDict[key] action:NULL keyEquivalent:@""];
+ item.tag = key.integerValue;
+ [self.faviconDownloadMethodPopup.menu addItem:item];
+ }
+ [self.faviconDownloadMethodPopup bind:NSSelectedTagBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyFaviconDownloadMethod] options:nil];
+
/* File Change Strategy Menu */
NSDictionary *fileChangeStragegyDict = @{ @(MPFileChangeStrategyAsk) : NSLocalizedString(@"FILE_CHANGE_STRATEGY_ASK", @"External file change strategy option: ask what to do"),
@(MPFileChangeStrategyUseOther) : NSLocalizedString(@"FILE_CHANGE_STRATEGY_USE_OTHER", @"External file change strategy option: Use the changed file and discard local changes"),
@@ -69,6 +82,6 @@
[self.fileChangeStrategyPopup.menu addItem:item];
}
[self.fileChangeStrategyPopup bind:NSSelectedTagBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyFileChangeStrategy] options:nil];
-
+
}
@end
diff --git a/MacPass/MPIconHelper.m b/MacPass/MPIconHelper.m
index 15e7ad28..b2664da6 100644
--- a/MacPass/MPIconHelper.m
+++ b/MacPass/MPIconHelper.m
@@ -21,6 +21,7 @@
//
#import "MPIconHelper.h"
+#import "MPSettingsHelper.h"
#import "KeePassKit/KeePassKit.h"
@implementation MPIconHelper
@@ -44,11 +45,11 @@
dispatch_once(&onceToken, ^{
NSDictionary *imageNames = [MPIconHelper availableIconNames];
NSMutableArray *mutableIcons = [[NSMutableArray alloc] initWithCapacity:imageNames.count];
-
+
NSArray *sortedImageNames = [imageNames.allKeys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [imageNames[obj1] compare:imageNames[obj2]];
}];
-
+
for(NSNumber *iconNumber in sortedImageNames) {
if(iconNumber.integerValue > MPCustomIconTypeBegin) {
continue; // Skip all non-db Keys
@@ -68,7 +69,7 @@
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSDictionary *imageNames = [MPIconHelper availableIconNames];
-
+
NSArray *sortedImageNames = [[imageNames allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [[imageNames objectForKey:obj1] compare:[imageNames objectForKey:obj2]];
}];
@@ -163,7 +164,7 @@
@(MPIconAddEntry): @"addEntryTemplate",
@(MPIconContextTriangle): @"contextTriangleTemplate",
@(MPIconKeyboard): @"keyboardTemplate",
-
+
@(MPIconExpiredEntry): NSImageNameCaution,
@(MPIconExpiredGroup): NSImageNameCaution
};
@@ -177,14 +178,24 @@
return; // no url, no handler so no need to do anything
}
+ // default setting value is direct download
NSString *urlString = [NSString stringWithFormat:@"%@://%@/favicon.ico", url.scheme, url.host ? url.host : @""];
+
+ MPFaviconDownloadMethod faviconDownloadMethod = (MPFaviconDownloadMethod)[NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyFaviconDownloadMethod];
+ if (faviconDownloadMethod == MPFaviconDownloadMethodDuckDuckGo) {
+ urlString = [NSString stringWithFormat:@"https://icons.duckduckgo.com/ip3/%@.ico", url.host ? url.host : @""];
+ }
+ else if (faviconDownloadMethod == MPFaviconDownloadMethodGoogle) {
+ urlString = [NSString stringWithFormat:@"https://www.google.com/s2/favicons?domain=%@", url.host ? url.host : @""];
+ }
+
NSURL *favIconURL = [NSURL URLWithString:urlString];
if(!favIconURL) {
/* call the handler with nil data */
handler(nil);
return;
}
-
+
NSURLSessionTask *task = [NSURLSession.sharedSession dataTaskWithURL:favIconURL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if(error) {
handler(nil);
diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h
index 786b8b17..05baf6e1 100644
--- a/MacPass/MPSettingsHelper.h
+++ b/MacPass/MPSettingsHelper.h
@@ -91,11 +91,14 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyHideIncopatiblePluginsWarning; // D
APPKIT_EXTERN NSString *const kMPSettingsKeyAllowRemoteFetchOfPluginRepository; // Allow the download of the plugin repository file
APPKIT_EXTERN NSString *const kMPSettingsKeyPluginHideAksForRemoveConnectionPermission;
+/* Network */
+APPKIT_EXTERN NSString *const kMPSettingsKeyFaviconDownloadMethod;
+
typedef NS_ENUM(NSUInteger, MPFileChangeStrategy) {
MPFileChangeStrategyAsk,
MPFileChangeStrategyKeepMine,
MPFileChangeStrategyUseOther,
- MPFileChangeStrategyMerge
+ MPFileChangeStrategyMerge,
};
typedef NS_ENUM(NSUInteger, MPDoubleClickURLAction) {
@@ -108,6 +111,12 @@ typedef NS_ENUM(NSUInteger, MPDoubleClickTitleAction) {
MPDoubleClickTitleActionIgnore,
};
+typedef NS_ENUM(NSUInteger, MPFaviconDownloadMethod) {
+ MPFaviconDownloadMethodDirect,
+ MPFaviconDownloadMethodDuckDuckGo,
+ MPFaviconDownloadMethodGoogle,
+};
+
/* Password Generation */
APPKIT_EXTERN NSString *const kMPSettingsKeyCopyGeneratedPasswordToClipboard;
APPKIT_EXTERN NSString *const kMPSettingsKeyDefaultPasswordLength;
diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m
index 766f51e8..e9e0c920 100644
--- a/MacPass/MPSettingsHelper.m
+++ b/MacPass/MPSettingsHelper.m
@@ -87,6 +87,8 @@ NSString *const kMPSettingsKeyDisabledPlugins = @"Disabl
NSString *const kMPSettingsKeyHideIncopatiblePluginsWarning = @"HideIncopatiblePluginsWarning";
NSString *const kMPSettingsKeyAllowRemoteFetchOfPluginRepository = @"AllowRemoteFetchOfPluginRepository";
+NSString *const kMPSettingsKeyFaviconDownloadMethod = @"FaviconDownloadMethod";
+
/* Deprecated */
NSString *const kMPDeprecatedSettingsKeyRememberKeyFilesForDatabases = @"kMPSettingsKeyRememberKeyFilesForDatabases";
NSString *const kMPDeprecatedSettingsKeyLastDatabasePath = @"MPLastDatabasePath";
@@ -164,7 +166,8 @@ NSString *const kMPDepricatedSettingsKeyAutotypeHideAccessibiltyWarning = @"Au
kMPSettingsKeyLoadIncompatiblePlugins: @NO,
kMPSettingsKeyQuitOnLastWindowClose: @NO,
kMPSettingsKeyEnableAutosave: @YES,
- kMPSettingsKeyHideAfterCopyToClipboard: @NO
+ kMPSettingsKeyHideAfterCopyToClipboard: @NO,
+ kMPSettingsKeyFaviconDownloadMethod: @(MPFaviconDownloadMethodDirect) // Download directly from host
};
});
return standardDefaults;
@@ -203,17 +206,17 @@ NSString *const kMPDepricatedSettingsKeyAutotypeHideAccessibiltyWarning = @"Au
/*
MacPass < 0.4 did use compare: for the entry table view,
this was changed in 0.4 to localizedCaseInsensitiveCompare:
-
+
MacPass < 0.5.2 did use parent.name for group names,
this was changed in 0.6. to parent.title
-
+
*/
NSData *descriptorData = [NSUserDefaults.standardUserDefaults dataForKey:kMPSettingsKeyEntryTableSortDescriptors];
if(!descriptorData) {
return; // No user defaults
}
NSArray *sortDescriptors = [NSKeyedUnarchiver unarchiveObjectWithData:descriptorData];
-
+
for(NSSortDescriptor *descriptor in sortDescriptors) {
/* Brute force, just kill the settings if they might cause trouble */
if(descriptor.selector == @selector(compare:)
@@ -291,7 +294,7 @@ NSString *const kMPDepricatedSettingsKeyAutotypeHideAccessibiltyWarning = @"Au
if(oldValue != [[self _standardDefaults][kMPDepricatedSettingsKeyLoadUnsecurePlugins] boolValue]) {
[NSUserDefaults.standardUserDefaults setBool:oldValue forKey:kMPSettingsKeyLoadUnsecurePlugins];
}
-
+
}
@end
diff --git a/MacPass/PreferencesWindow.xib b/MacPass/PreferencesWindow.xib
index 67a449d7..d823a61c 100644
--- a/MacPass/PreferencesWindow.xib
+++ b/MacPass/PreferencesWindow.xib
@@ -15,10 +15,10 @@
-
+
-
+
diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings
index 2cecb643..2e12a9f8 100644
--- a/MacPass/en.lproj/Localizable.strings
+++ b/MacPass/en.lproj/Localizable.strings
@@ -382,6 +382,15 @@
/* The master key was changed by an external program! */
"EXTERN_CHANGE_OF_MASTERKEY" = "Master key was changed by another program";
+/* Direct download */
+"FAVICON_DOWNLOAD_METHOD_DIRECT" = "Direct download";
+
+/* DuckDuckGo */
+"FAVICON_DOWNLOAD_METHOD_DUCKDUCKGO" = "DuckDuckGo";
+
+/* Google */
+"FAVICON_DOWNLOAD_METHOD_GOOGLE" = "Google";
+
/* External file change strategy option: ask what to do */
"FILE_CHANGE_STRATEGY_ASK" = "Ask";
@@ -837,4 +846,3 @@
/* Yesterday */
"YESTERDAY" = "Yesterday";
-