Use DuckDuckGo favicon service (#1073)

* Use DuckDuckGo favicon service

There are multiple ways of how favicon of a website can be published:
- Have a `favicon.ico` file under the website root
- Set through `<link rel="shortcut icon" href="..." />` tag
- Set through `<link rel="icon" href="..." />` tag, or
- Set through platform-specific tags like `<link rel="apple-touch-icon" href="..." />`

Current implementation only supports first option, which does not work in many cases.

Instead of implementing favicon fetching logic from scratch, favicon fetching services can be used.
There are multiple of them, e.g.:
- https://icons.duckduckgo.com/ip3/www.google.com.ico
- https://www.google.com/s2/favicons?domain=www.google.com

This change switched from fetching favicon from the original host to DuckDuckGo.

* Create UX for favicon download method preferences

* Add preferences for favicon download method

* Adjust preferences window location

Also, sort localized resources

Co-authored-by: Alex Rakov <alexander-rakov@users.noreply.github.com>
This commit is contained in:
Alex Rakov
2020-05-15 10:37:52 -07:00
committed by GitHub
parent 67eee29fdf
commit c4fe593e8f
8 changed files with 120 additions and 21 deletions

View File

@@ -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