Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Google with DuckDuckGo as the optional fallback favicon fetcher #2309

Conversation

kneitinger
Copy link
Contributor

Description

Transition to DuckDuckGo as Fallback Favicon Fetcher

Modified the fallback HTTP request to use DuckDuckGo (which uses paths to specify the site whose favicon should be retrieved) instead of Google which used params to specify the target site). Additionally, changed references to "Google" to "DuckDuckGo" in ui elements and variables.

Close Failed Favicon Fetch Progress Bars

Prior to my fix, when a fetch failed, it was being hidden (and not ever closed) immediately after failing, only to be unhidden by the timeout specified by setMinimumDuration() being reached. In EditWidgetIcons::fetchFinished(), the error state of the fetch is established, so it seemed like the correct place to close the UrlFetchProgressDialog. The only issue is that the progress widget is only ever bound to a variable locally in a different function. The EditWidgetIcons object is the parent of the progress widget, so we can get a reference to the progress widget via findChild(), however we need a name to lookup to use it. Since the url being queried is known at widget create time and destroy time, that seemed like the ideal choice to uniquely name the object.

Motivation and context

Transition to DuckDuckGo as fallback fetcher fixes #2258
Closing of progress bars of failed fetches fixes #2265

How has this been tested?

First, ran all existing unit test successfully. Then, manually tested functionality:

  • https://fedex.com is a URL that I know will always fall through to the fallback fetcher if enabled, so I deleted it's icon, and tried to fetch:
    attempting to fetch https://fedex.com's favicon with no fallback
    Screenshot shows that DuckDuckGo is the optional fallback that can be enabled according to the message.
  • The Security section of Tools indeed shows DuckDuckGo fallback as an option. I enabled it:
    Enabling DuckDuckGo favicon fetching in the Security settings
  • I returned to the Fedex entry and tried to fetch the favicon with DuckDuckGo fallback enabled. It successfully retrieved the favicon.
    Fedex icon shown correctly in Custom Icons
  • All progress bars are closed (no screenshot available 🙂)
  • To check safe failures when DuckDuckGo cannot fetch the icon, I first created a new entry of a nonexistent url:
    New entry with long random URL that does not point anywhere
  • I attempted to fetch the icon of this entry. All three attempts (2 regular attempts to directly grab a /favicon.ico file, and DuckDuckGo) fail and their progress bars disappear. An error message is correctly displayed:
    Correct error popup shown when attempting to fetch nonexistent URL's favicon

Types of changes

  • ✅ Bug fix (non-breaking change which fixes an issue)
  • ✅ New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

@kneitinger kneitinger force-pushed the feature/duckduckgo-for-favicon-fallback branch 2 times, most recently from 265d530 to 8f18515 Compare September 20, 2018 03:10
Copy link
Member

@droidmonkey droidmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, just naming convention changes.

@@ -148,7 +148,7 @@ void Config::init(const QString& fileName)
m_defaults.insert("security/passwordscleartext", false);
m_defaults.insert("security/hidepassworddetails", true);
m_defaults.insert("security/autotypeask", true);
m_defaults.insert("security/IconDownloadFallbackToGoogle", false);
m_defaults.insert("security/IconDownloadFallbackToDuckDuckGo", false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be best to name this "security/IconDownloadFallback" in case we change the service again in the future or allow for a choice in services.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

if (config()->get("security/IconDownloadFallbackToGoogle", false).toBool()) {
QUrl urlGoogle = QUrl("https://www.google.com/s2/favicons");
// Try to use DuckDuckGo fallback, if enabled
if (config()->get("security/IconDownloadFallbackToDuckDuckGo", false).toBool()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, let's keep this generic: "QUrl fallbackUrl = ..."

src/gui/EditWidgetIcons.cpp Show resolved Hide resolved
Name the UrlFetchProgressDialog() with the corresponding URL in order to
be identified by name by its parent when the failed request is handeled
in EditWidgetIcons::fetchFinished(). fetchFinished() retrieves the
relevant UrlFetchProgressDialog() and calls close() on it.

Fixes: keepassxreboot#2265
@droidmonkey droidmonkey force-pushed the feature/duckduckgo-for-favicon-fallback branch from 54519fe to b4ae46f Compare September 20, 2018 17:02
@droidmonkey
Copy link
Member

Whoops, something crazy happened. I rebased your changes onto develop and lost your last commit. Please reapply your fixes to the current head, thanks.

Change variables that reference the current external favicon fallback
service, DuckDuckGo, to instead generically reference fallback URLs
generically, to facilitate ease of any potential future service switch
@droidmonkey droidmonkey merged commit 341635f into keepassxreboot:develop Sep 21, 2018
@droidmonkey
Copy link
Member

Great work, looking forward to more PR's!

@kneitinger
Copy link
Contributor Author

Thanks!

@kneitinger kneitinger deleted the feature/duckduckgo-for-favicon-fallback branch September 21, 2018 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

downloading favicon shows progress bar twice Feature: Using DuckDuckGo for favicons
2 participants