Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.25 KB | None | 0 0
  1. diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
  2. index a997c53d..7d5589b9 100644
  3. --- a/src/core/web_contents_delegate_qt.cpp
  4. +++ b/src/core/web_contents_delegate_qt.cpp
  5. @@ -61,6 +61,9 @@
  6.  
  7.  #include "components/web_cache/browser/web_cache_manager.h"
  8.  #include "content/browser/renderer_host/render_widget_host_impl.h"
  9. +#include "content/public/browser/browser_context.h".h"
  10. +#include "content/public/browser/download_manager.h"
  11. +#include "content/public/browser/download_item.h"
  12.  #include "content/public/browser/invalidate_type.h"
  13.  #include "content/public/browser/navigation_entry.h"
  14.  #include "content/public/browser/navigation_handle.h"
  15. @@ -147,16 +150,29 @@ void WebContentsDelegateQt::NavigationStateChanged(content::WebContents* source,
  16.  
  17.  bool WebContentsDelegateQt::ShouldPreserveAbortedURLs(content::WebContents *source)
  18.  {
  19. -    Q_UNUSED(source)
  20. -
  21. -    // Allow failed URLs to stick around in the URL bar, but only when the error-page is enabled.
  22.      WebEngineSettings *settings = m_viewClient->webEngineSettings();
  23.      bool isErrorPageEnabled = settings->testAttribute(settings->Attribute::ErrorPageEnabled);
  24.  
  25. -    if (isErrorPageEnabled)
  26. -        return true;
  27. +    // TODO: Comment
  28. +    if (!isErrorPageEnabled)
  29. +        return false;
  30.  
  31. -    return false;
  32. +    const content::NavigationController &controller = source->GetController();
  33. +    content::NavigationEntry *pending_entry = controller.GetPendingEntry();
  34. +
  35. +    // TODO: Comment
  36. +    if (pending_entry) {
  37. +        content::DownloadManager *downloadManager = content::BrowserContext::GetDownloadManager(source->GetBrowserContext());
  38. +        content::DownloadManager::DownloadVector downloadItems;
  39. +        downloadManager->GetAllDownloads(&downloadItems);
  40. +
  41. +        for (content::DownloadItem *downloadItem : downloadItems) {
  42. +            if (downloadItem->GetState() != content::DownloadItem::COMPLETE && downloadItem->GetURL() == pending_entry->GetURL())
  43. +                return false;
  44. +        }
  45. +    }
  46. +
  47. +    return true;
  48.  }
  49.  
  50.  void WebContentsDelegateQt::AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement