Changeset 91540 in webkit


Ignore:
Timestamp:
Jul 21, 2011 5:40:30 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Local files cannot load icons.
https://bugs.webkit.org/show_bug.cgi?id=62459

Previous policy only allowed favicons for pages whose protocol was part of HTTP family.
Changed that to allow to any url that's not empty and whose protocol is not "about".
Also added this check where it attempts to start loading the favicon, so it can avoid
wasting time downloading a resource that won't be stored and won't be used.

Patch by Rafael Brandao <rafael.lobo@openbossa.org> on 2011-07-21
Reviewed by Adam Barth.

Test: manual-tests/resources/favicon-loads-for-local-files.html

  • loader/icon/IconController.cpp:

(WebCore::IconController::startLoader): Added check to avoid to request a favicon
when there's no way to store it.

  • loader/icon/IconDatabase.cpp:

(WebCore::IconDatabase::documentCanHaveIcon): Renamed function "pageCanHaveIcon"
to reflect better which url we're handling.

(WebCore::IconDatabase::synchronousIconForPageURL): Ditto.
(WebCore::IconDatabase::synchronousIconURLForPageURL): Ditto.
(WebCore::IconDatabase::retainIconForPageURL): Ditto.
(WebCore::IconDatabase::releaseIconForPageURL): Ditto.
(WebCore::IconDatabase::setIconURLForPageURL): Ditto.
(WebCore::IconDatabase::getOrCreatePageURLRecord): Ditto.
(WebCore::IconDatabase::importIconURLForPageURL): Ditto.
(WebCore::IconDatabase::performURLImport): Ditto.

  • loader/icon/IconDatabase.h:
  • loader/icon/IconDatabaseBase.h:

(WebCore::IconDatabaseBase::documentCanHaveIcon): Added it as virtual to replace its
default behavior of not allowing favicons when we have IconDatabase enabled.

  • manual-tests/resources/favicon-loads-for-local-files.html: Added.
  • manual-tests/resources/favicon.png: Added.
Location:
trunk/Source/WebCore
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91533 r91540  
     12011-07-21  Rafael Brandao  <rafael.lobo@openbossa.org>
     2
     3        Local files cannot load icons.
     4        https://bugs.webkit.org/show_bug.cgi?id=62459
     5       
     6        Previous policy only allowed favicons for pages whose protocol was part of HTTP family.
     7        Changed that to allow to any url that's not empty and whose protocol is not "about".
     8        Also added this check where it attempts to start loading the favicon, so it can avoid
     9        wasting time downloading a resource that won't be stored and won't be used.
     10
     11        Reviewed by Adam Barth.
     12
     13        Test: manual-tests/resources/favicon-loads-for-local-files.html
     14
     15        * loader/icon/IconController.cpp:
     16        (WebCore::IconController::startLoader): Added check to avoid to request a favicon
     17        when there's no way to store it.
     18       
     19        * loader/icon/IconDatabase.cpp:
     20        (WebCore::IconDatabase::documentCanHaveIcon): Renamed function "pageCanHaveIcon"
     21        to reflect better which url we're handling.
     22       
     23        (WebCore::IconDatabase::synchronousIconForPageURL): Ditto.
     24        (WebCore::IconDatabase::synchronousIconURLForPageURL): Ditto.
     25        (WebCore::IconDatabase::retainIconForPageURL): Ditto.
     26        (WebCore::IconDatabase::releaseIconForPageURL): Ditto.
     27        (WebCore::IconDatabase::setIconURLForPageURL): Ditto.
     28        (WebCore::IconDatabase::getOrCreatePageURLRecord): Ditto.
     29        (WebCore::IconDatabase::importIconURLForPageURL): Ditto.
     30        (WebCore::IconDatabase::performURLImport): Ditto.
     31        * loader/icon/IconDatabase.h:
     32        * loader/icon/IconDatabaseBase.h:
     33        (WebCore::IconDatabaseBase::documentCanHaveIcon): Added it as virtual to replace its
     34        default behavior of not allowing favicons when we have IconDatabase enabled.
     35       
     36        * manual-tests/resources/favicon-loads-for-local-files.html: Added.
     37        * manual-tests/resources/favicon.png: Added.
     38
    1392011-07-21  Kulanthaivel Palanichamy  <kulanthaivel@codeaurora.org>
    240
  • trunk/Source/WebCore/loader/icon/IconController.cpp

    r88682 r91540  
    114114        return;
    115115
     116    ASSERT(!m_frame->tree()->parent());
     117    if (!iconDatabase().documentCanHaveIcon(m_frame->document()->url()))
     118        return;
     119
    116120    KURL iconURL(url());
    117121    String urlString(iconURL.string());
  • trunk/Source/WebCore/loader/icon/IconDatabase.cpp

    r90486 r91540  
    100100}
    101101
    102 static inline bool pageCanHaveIcon(const String& pageURL)
    103 {
    104     return protocolIsInHTTPFamily(pageURL);
     102bool IconDatabase::documentCanHaveIcon(const String& documentURL) const
     103{
     104    return !documentURL.isEmpty() && !protocolIs(documentURL, "about");
    105105}
    106106
     
    224224    // We should go our of our way to only copy it if we have to store it
    225225   
    226     if (!isOpen() || !pageCanHaveIcon(pageURLOriginal))
     226    if (!isOpen() || !documentCanHaveIcon(pageURLOriginal))
    227227        return 0;
    228228
     
    311311    // Also, in the case we have a real answer for the caller, we must deep copy that as well
    312312   
    313     if (!isOpen() || !pageCanHaveIcon(pageURLOriginal))
     313    if (!isOpen() || !documentCanHaveIcon(pageURLOriginal))
    314314        return String();
    315315       
     
    401401    // Cannot do anything with pageURLOriginal that would end up storing it without deep copying first
    402402   
    403     if (!isEnabled() || !pageCanHaveIcon(pageURLOriginal))
     403    if (!isEnabled() || !documentCanHaveIcon(pageURLOriginal))
    404404        return;
    405405       
     
    445445    // Cannot do anything with pageURLOriginal that would end up storing it without deep copying first
    446446   
    447     if (!isEnabled() || !pageCanHaveIcon(pageURLOriginal))
     447    if (!isEnabled() || !documentCanHaveIcon(pageURLOriginal))
    448448        return;
    449449   
     
    580580    ASSERT(!iconURLOriginal.isEmpty());
    581581       
    582     if (!isOpen() || !pageCanHaveIcon(pageURLOriginal))
     582    if (!isOpen() || !documentCanHaveIcon(pageURLOriginal))
    583583        return;
    584584   
     
    890890    ASSERT(!m_urlAndIconLock.tryLock());
    891891
    892     if (!pageCanHaveIcon(pageURL))
     892    if (!documentCanHaveIcon(pageURL))
    893893        return 0;
    894894
     
    928928    ASSERT(!iconURL.isEmpty());
    929929    ASSERT(!pageURL.isEmpty());
    930     ASSERT(pageCanHaveIcon(pageURL));
     930    ASSERT(documentCanHaveIcon(pageURL));
    931931   
    932932    setIconURLForPageURLInSQLDatabase(iconURL, pageURL);   
     
    12351235            // If database cleanup *is* allowed, we don't want to bother pulling in a page url from disk that noone is actually interested
    12361236            // in - we'll prune it later instead!
    1237             if (!pageRecord && databaseCleanupCounter && pageCanHaveIcon(pageURL)) {
     1237            if (!pageRecord && databaseCleanupCounter && documentCanHaveIcon(pageURL)) {
    12381238                pageRecord = new PageURLRecord(pageURL);
    12391239                m_pageURLToRecordMap.set(pageURL, pageRecord);
  • trunk/Source/WebCore/loader/icon/IconDatabase.h

    r84892 r91540  
    137137    virtual bool isOpen() const;
    138138    virtual String databasePath() const;
     139    virtual bool documentCanHaveIcon(const String& documentURL) const;
    139140    static String defaultDatabaseFilename();
    140141
  • trunk/Source/WebCore/loader/icon/IconDatabaseBase.h

    r81892 r91540  
    166166    // Used internally by WebCore
    167167    virtual bool isEnabled() const { return false; }
     168    virtual bool documentCanHaveIcon(const String&) const { return false; }
    168169       
    169170    virtual void retainIconForPageURL(const String&) { }
Note: See TracChangeset for help on using the changeset viewer.